[PATCH 1 of 3 VFS] subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Apr 11 14:17:45 UTC 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1428760804 -32400
#      Sat Apr 11 23:00:04 2015 +0900
# Node ID 2e5a665f2c4fc7b26b69af765337d45bc9ad4e07
# Parent  52ff737c63d2b2cb41185549aa9c35bc47317032
subrepo: pass wvfs to _sanitize instead of absolute path to a subrepository

As a preparation for vfs migration of "_sanitize()", this patch passes
"wvfs" to "_sanitize()" and use "wvfs.base" instead of absolute path
to a subrepository.

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -302,8 +302,8 @@ def _abssource(repo, push=False, abort=T
     if abort:
         raise util.Abort(_("default path for subrepository not found"))
 
-def _sanitize(ui, path, ignore):
-    for dirname, dirs, names in os.walk(path):
+def _sanitize(ui, vfs, ignore):
+    for dirname, dirs, names in os.walk(vfs.base):
         for i, d in enumerate(dirs):
             if d.lower() == ignore:
                 del dirs[i]
@@ -1132,7 +1132,7 @@ class svnsubrepo(abstractsubrepo):
         # update to a directory which has since been deleted and recreated.
         args.append('%s@%s' % (state[0], state[1]))
         status, err = self._svncommand(args, failok=True)
-        _sanitize(self.ui, self._ctx.repo().wjoin(self._path), '.svn')
+        _sanitize(self.ui, self.wvfs, '.svn')
         if not re.search('Checked out revision [0-9]+.', status):
             if ('is already a working copy for a different URL' in err
                 and (self._wcchanged()[:2] == (False, False))):
@@ -1433,7 +1433,7 @@ class gitsubrepo(abstractsubrepo):
                 self._gitcommand(['reset', 'HEAD'])
                 cmd.append('-f')
             self._gitcommand(cmd + args)
-            _sanitize(self.ui, self._abspath, '.git')
+            _sanitize(self.ui, self.wvfs, '.git')
 
         def rawcheckout():
             # no branch to checkout, check it out with no branch
@@ -1482,7 +1482,7 @@ class gitsubrepo(abstractsubrepo):
             if tracking[remote] != self._gitcurrentbranch():
                 checkout([tracking[remote]])
             self._gitcommand(['merge', '--ff', remote])
-            _sanitize(self.ui, self._abspath, '.git')
+            _sanitize(self.ui, self.wvfs, '.git')
         else:
             # a real merge would be required, just checkout the revision
             rawcheckout()
@@ -1518,7 +1518,7 @@ class gitsubrepo(abstractsubrepo):
                 self.get(state) # fast forward merge
             elif base != self._state[1]:
                 self._gitcommand(['merge', '--no-commit', revision])
-            _sanitize(self.ui, self._abspath, '.git')
+            _sanitize(self.ui, self.wvfs, '.git')
 
         if self.dirty():
             if self._gitstate() != revision:


More information about the Mercurial-devel mailing list