[PATCH 3 of 3 VFS] subrepo: use vfs.walk instead of os.walk

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sat Apr 11 09:17:47 CDT 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 7238eab705505fc7d88d9a24c020604d3c2f7d86
# Parent  e848285bccb2733268cea52ff5ba94705f8780e5
subrepo: use vfs.walk instead of os.walk

"dirpath" in the tuple yielded by "vfs.walk()" is relative one from
the root of specified vfs, and absolute path in the warning message is
composed by "vfs.join()".

On the other hand, target file "f" exists in "dirpath", and
"reljoin()" is needed to unlink "f" by "vfs.unlink()".

diff --git a/mercurial/subrepo.py b/mercurial/subrepo.py
--- a/mercurial/subrepo.py
+++ b/mercurial/subrepo.py
@@ -303,7 +303,7 @@ def _abssource(repo, push=False, abort=T
         raise util.Abort(_("default path for subrepository not found"))
 
 def _sanitize(ui, vfs, ignore):
-    for dirname, dirs, names in os.walk(vfs.base):
+    for dirname, dirs, names in vfs.walk():
         for i, d in enumerate(dirs):
             if d.lower() == ignore:
                 del dirs[i]
@@ -313,8 +313,8 @@ def _sanitize(ui, vfs, ignore):
         for f in names:
             if f.lower() == 'hgrc':
                 ui.warn(_("warning: removing potentially hostile 'hgrc' "
-                          "in '%s'\n") % dirname)
-                os.unlink(os.path.join(dirname, f))
+                          "in '%s'\n") % vfs.join(dirname))
+                vfs.unlink(vfs.reljoin(dirname, f))
 
 def subrepo(ctx, path):
     """return instance of the right subrepo class for subrepo in path"""


More information about the Mercurial-devel mailing list