mercurial/util.py
changeset 38493 da2a7d8354b2
parent 38380 63e6f5ae84bc
child 38575 152f4822d210
--- a/mercurial/util.py	Thu Jun 28 21:24:47 2018 +0530
+++ b/mercurial/util.py	Thu Jun 28 18:07:22 2018 -0700
@@ -2139,17 +2139,18 @@
         else:
             self.close()
 
-def unlinkpath(f, ignoremissing=False):
+def unlinkpath(f, ignoremissing=False, rmdir=True):
     """unlink and remove the directory if it is empty"""
     if ignoremissing:
         tryunlink(f)
     else:
         unlink(f)
-    # try removing directories that might now be empty
-    try:
-        removedirs(os.path.dirname(f))
-    except OSError:
-        pass
+    if rmdir:
+        # try removing directories that might now be empty
+        try:
+            removedirs(os.path.dirname(f))
+        except OSError:
+            pass
 
 def tryunlink(f):
     """Attempt to remove a file, ignoring ENOENT errors."""