comparison mercurial/subrepo.py @ 24726:747748766421

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()".
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
date Sat, 11 Apr 2015 23:00:04 +0900
parents 95eb067b2b5e
children a48b65ab428d
comparison
equal deleted inserted replaced
24725:ee751d47cf2c 24726:747748766421
301 return os.path.dirname(repo.sharedpath) 301 return os.path.dirname(repo.sharedpath)
302 if abort: 302 if abort:
303 raise util.Abort(_("default path for subrepository not found")) 303 raise util.Abort(_("default path for subrepository not found"))
304 304
305 def _sanitize(ui, vfs, ignore): 305 def _sanitize(ui, vfs, ignore):
306 for dirname, dirs, names in os.walk(vfs.base): 306 for dirname, dirs, names in vfs.walk():
307 for i, d in enumerate(dirs): 307 for i, d in enumerate(dirs):
308 if d.lower() == ignore: 308 if d.lower() == ignore:
309 del dirs[i] 309 del dirs[i]
310 break 310 break
311 if os.path.basename(dirname).lower() != '.hg': 311 if os.path.basename(dirname).lower() != '.hg':
312 continue 312 continue
313 for f in names: 313 for f in names:
314 if f.lower() == 'hgrc': 314 if f.lower() == 'hgrc':
315 ui.warn(_("warning: removing potentially hostile 'hgrc' " 315 ui.warn(_("warning: removing potentially hostile 'hgrc' "
316 "in '%s'\n") % dirname) 316 "in '%s'\n") % vfs.join(dirname))
317 os.unlink(os.path.join(dirname, f)) 317 vfs.unlink(vfs.reljoin(dirname, f))
318 318
319 def subrepo(ctx, path): 319 def subrepo(ctx, path):
320 """return instance of the right subrepo class for subrepo in path""" 320 """return instance of the right subrepo class for subrepo in path"""
321 # subrepo inherently violates our import layering rules 321 # subrepo inherently violates our import layering rules
322 # because it wants to make repo objects from deep inside the stack 322 # because it wants to make repo objects from deep inside the stack