comparison mercurial/hg.py @ 821:72d9bd4841f3

Ensure that dirstate.walk only yields names once. Its predecessor code used to do this, and now it does, too.
author Bryan O'Sullivan <bos@serpentine.com>
date Sun, 31 Jul 2005 17:54:00 -0800
parents 89985a1b3427
children b678e6d4f92d
comparison
equal deleted inserted replaced
820:89985a1b3427 821:72d9bd4841f3
438 def walk(self, files = None, match = util.always): 438 def walk(self, files = None, match = util.always):
439 self.read() 439 self.read()
440 dc = self.map.copy() 440 dc = self.map.copy()
441 # walk all files by default 441 # walk all files by default
442 if not files: files = [self.root] 442 if not files: files = [self.root]
443 known = {'.hg': 1}
444 def seen(fn):
445 if fn in known: return True
446 known[fn] = 1
443 def traverse(): 447 def traverse():
444 for f in util.unique(files): 448 for f in util.unique(files):
445 f = os.path.join(self.root, f) 449 f = os.path.join(self.root, f)
446 if os.path.isdir(f): 450 if os.path.isdir(f):
447 for dir, subdirs, fl in os.walk(f): 451 for dir, subdirs, fl in os.walk(f):
448 d = dir[len(self.root) + 1:] 452 d = dir[len(self.root) + 1:]
449 nd = os.path.normpath(d) 453 nd = os.path.normpath(d)
450 if nd == '.hg': 454 if seen(nd):
451 subdirs[:] = [] 455 subdirs[:] = []
452 continue 456 continue
453 for sd in subdirs: 457 for sd in subdirs:
454 ds = os.path.join(nd, sd +'/') 458 ds = os.path.join(nd, sd +'/')
455 if self.ignore(ds) or not match(ds): 459 if self.ignore(ds) or not match(ds):
466 # yield only files that match: all in dirstate, others only if 470 # yield only files that match: all in dirstate, others only if
467 # not in .hgignore 471 # not in .hgignore
468 472
469 for src, fn in util.unique(traverse()): 473 for src, fn in util.unique(traverse()):
470 fn = os.path.normpath(fn) 474 fn = os.path.normpath(fn)
475 if seen(fn): continue
471 if fn in dc: 476 if fn in dc:
472 del dc[fn] 477 del dc[fn]
473 elif self.ignore(fn): 478 elif self.ignore(fn):
474 continue 479 continue
475 if match(fn): 480 if match(fn):