merge with stable
authorMartin von Zweigbergk <martinvonz@google.com>
Mon, 20 Aug 2018 09:48:08 -0700
changeset 39197 d859b48730b8
parent 39195 1e7a462cb946 (current diff)
parent 39196 8c6775e812d8 (diff)
child 39201 45e05d39d9ce
merge with stable
mercurial/context.py
--- a/mercurial/context.py	Sat Aug 18 10:06:56 2018 +0900
+++ b/mercurial/context.py	Mon Aug 20 09:48:08 2018 -0700
@@ -1742,13 +1742,19 @@
         wvfs = self._repo.wvfs
         f = self._path
         wvfs.audit(f)
-        if wvfs.isdir(f) and not wvfs.islink(f):
-            wvfs.rmtree(f, forcibly=True)
         if self._repo.ui.configbool('experimental', 'merge.checkpathconflicts'):
+            # remove files under the directory as they should already be
+            # warned and backed up
+            if wvfs.isdir(f) and not wvfs.islink(f):
+                wvfs.rmtree(f, forcibly=True)
             for p in reversed(list(util.finddirs(f))):
                 if wvfs.isfileorlink(p):
                     wvfs.unlink(p)
                     break
+        else:
+            # don't remove files if path conflicts are not processed
+            if wvfs.isdir(f) and not wvfs.islink(f):
+                wvfs.removedirs(f)
 
     def setflags(self, l, x):
         self._repo.wvfs.setflags(self._path, l, x)
--- a/tests/test-merge1.t	Sat Aug 18 10:06:56 2018 +0900
+++ b/tests/test-merge1.t	Mon Aug 20 09:48:08 2018 -0700
@@ -30,23 +30,24 @@
 
   $ mkdir b && touch b/nonempty
   $ hg up
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  abort: Directory not empty: '$TESTTMP/t/b'
+  [255]
   $ hg ci
-  nothing changed
-  [1]
+  abort: last update was interrupted
+  (use 'hg update' to get a consistent checkout)
+  [255]
   $ hg sum
-  parent: 1:b8bb4a988f25 tip
-   commit #1
+  parent: 0:538afb845929 
+   commit #0
   branch: default
-  commit: (clean)
-  update: (current)
+  commit: 1 unknown (interrupted update)
+  update: 1 new changesets (update)
   phases: 2 draft
 
-The following line is commented out because the file doesn't exist at the moment, and some OSes error out even with `rm -f`.
-$ rm b/nonempty
+  $ rm b/nonempty
 
   $ hg up
-  0 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   $ hg sum
   parent: 1:b8bb4a988f25 tip
    commit #1
--- a/tests/test-update-names.t	Sat Aug 18 10:06:56 2018 +0900
+++ b/tests/test-update-names.t	Mon Aug 20 09:48:08 2018 -0700
@@ -50,7 +50,10 @@
   $ hg st
   ? name/file
   $ hg up 1
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  abort: Directory not empty: '$TESTTMP/r1/r2/name'
+  [255]
+  $ cat name/file
+  text
   $ cd ..
 
 #if symlink