subrepo: use vfs.walk instead of os.walk
authorFUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 11 Apr 2015 23:00:04 +0900
changeset 24726 747748766421
parent 24725 ee751d47cf2c
child 24727 5668202cfaaf
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()".
mercurial/subrepo.py
--- a/mercurial/subrepo.py	Sat Apr 11 23:00:04 2015 +0900
+++ b/mercurial/subrepo.py	Sat Apr 11 23:00:04 2015 +0900
@@ -303,7 +303,7 @@
         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 @@
         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"""