comparison mercurial/hg.py @ 824:0932bc2fb2be

Merge with BOS
author mpm@selenic.com
date Tue, 02 Aug 2005 08:57:32 -0800
parents cf1d9a01dd92 b678e6d4f92d
children 1fe3b14c7044 9c918287d10b
comparison
equal deleted inserted replaced
818:eef752151556 824:0932bc2fb2be
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 if d == '.hg': 453 nd = os.path.normpath(d)
454 if seen(nd):
450 subdirs[:] = [] 455 subdirs[:] = []
451 continue 456 continue
452 for sd in subdirs: 457 for sd in subdirs:
453 ds = os.path.join(d, sd +'/') 458 ds = os.path.join(nd, sd +'/')
454 if self.ignore(ds) or not match(ds): 459 if self.ignore(ds) or not match(ds):
455 subdirs.remove(sd) 460 subdirs.remove(sd)
461 subdirs.sort()
462 fl.sort()
456 for fn in fl: 463 for fn in fl:
457 fn = util.pconvert(os.path.join(d, fn)) 464 fn = util.pconvert(os.path.join(d, fn))
458 yield 'f', fn 465 yield 'f', fn
459 else: 466 else:
460 yield 'f', f[len(self.root) + 1:] 467 yield 'f', f[len(self.root) + 1:]
461 468
462 for k in dc.keys(): 469 ks = dc.keys()
470 ks.sort()
471 for k in ks:
463 yield 'm', k 472 yield 'm', k
464 473
465 # yield only files that match: all in dirstate, others only if 474 # yield only files that match: all in dirstate, others only if
466 # not in .hgignore 475 # not in .hgignore
467 476
468 for src, fn in util.unique(traverse()): 477 for src, fn in util.unique(traverse()):
478 fn = os.path.normpath(fn)
479 if seen(fn): continue
469 if fn in dc: 480 if fn in dc:
470 del dc[fn] 481 del dc[fn]
471 elif self.ignore(fn): 482 elif self.ignore(fn):
472 continue 483 continue
473 if match(fn): 484 if match(fn):
866 return 1 877 return 1
867 878
868 def walk(self, node = None, files = [], match = util.always): 879 def walk(self, node = None, files = [], match = util.always):
869 if node: 880 if node:
870 for fn in self.manifest.read(self.changelog.read(node)[0]): 881 for fn in self.manifest.read(self.changelog.read(node)[0]):
871 yield 'm', fn 882 if match(fn): yield 'm', fn
872 else: 883 else:
873 for src, fn in self.dirstate.walk(files, match): 884 for src, fn in self.dirstate.walk(files, match):
874 yield src, fn 885 yield src, fn
875 886
876 def changes(self, node1 = None, node2 = None, files = [], 887 def changes(self, node1 = None, node2 = None, files = [],