mercurial/context.py
changeset 39197 d859b48730b8
parent 39132 873f3a56993f
parent 39196 8c6775e812d8
child 39292 f6f52841e1ff
--- 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)