D4478: merge: use vfs methods for I/O

indygreg (Gregory Szorc) phabricator at mercurial-scm.org
Thu Sep 6 21:33:38 EDT 2018


indygreg updated this revision to Diff 10826.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D4478?vs=10776&id=10826

REVISION DETAIL
  https://phab.mercurial-scm.org/D4478

AFFECTED FILES
  mercurial/merge.py
  mercurial/vfs.py

CHANGE DETAILS

diff --git a/mercurial/vfs.py b/mercurial/vfs.py
--- a/mercurial/vfs.py
+++ b/mercurial/vfs.py
@@ -213,6 +213,10 @@
         """
         return util.removedirs(self.join(path))
 
+    def rmdir(self, path=None):
+        """Remove an empty directory."""
+        return os.rmdir(self.join(path))
+
     def rmtree(self, path=None, ignore_errors=False, forcibly=False):
         """Remove a directory tree recursively
 
diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -9,7 +9,6 @@
 
 import errno
 import hashlib
-import os
 import shutil
 import struct
 
@@ -2267,7 +2266,7 @@
 
     def remove(removefn, path):
         try:
-            removefn(repo.wvfs.join(path))
+            removefn(path)
         except OSError:
             m = _('%s cannot be removed') % path
             if abortonerror:
@@ -2293,15 +2292,15 @@
             for f in sorted(status.unknown + status.ignored):
                 if not noop:
                     repo.ui.note(_('removing file %s\n') % f)
-                    remove(util.unlink, f)
+                    remove(repo.wvfs.unlink, f)
                 res.append(f)
 
         if removeemptydirs:
             for f in sorted(directories, reverse=True):
-                if matcher(f) and not os.listdir(repo.wvfs.join(f)):
+                if matcher(f) and not repo.wvfs.listdir(f):
                     if not noop:
                         repo.ui.note(_('removing directory %s\n') % f)
-                        remove(os.rmdir, f)
+                        remove(repo.wvfs.rmdir, f)
                     res.append(f)
 
         return res



To: indygreg, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list