changeset 39481:3dd34b401bc2

merge: use vfs methods for I/O All I/O is supposed to be performed via vfs instances so filesystems can be abstracted. The previous commit ported the old code in purge, which didn't go through the vfs layer. This commit ports the purge code to use the vfs layer. The vfs layer didn't have a method to remove a single directory, so it was added as part of implementing this. Differential Revision: https://phab.mercurial-scm.org/D4478
author Gregory Szorc <gregory.szorc@gmail.com>
date Tue, 04 Sep 2018 15:55:23 -0700
parents 7fea205fd5dc
children 4062bbb1d10f
files mercurial/merge.py mercurial/vfs.py
diffstat 2 files changed, 8 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/merge.py	Thu Sep 06 18:30:12 2018 -0700
+++ b/mercurial/merge.py	Tue Sep 04 15:55:23 2018 -0700
@@ -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
--- a/mercurial/vfs.py	Thu Sep 06 18:30:12 2018 -0700
+++ b/mercurial/vfs.py	Tue Sep 04 15:55:23 2018 -0700
@@ -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