Ensure that dirstate.walk only yields names once.
authorBryan O'Sullivan <bos@serpentine.com>
Sun, 31 Jul 2005 17:54:00 -0800
changeset 821 72d9bd4841f3
parent 820 89985a1b3427
child 822 b678e6d4f92d
Ensure that dirstate.walk only yields names once. Its predecessor code used to do this, and now it does, too.
mercurial/hg.py
--- a/mercurial/hg.py	Sun Jul 31 17:42:46 2005 -0800
+++ b/mercurial/hg.py	Sun Jul 31 17:54:00 2005 -0800
@@ -440,6 +440,10 @@
         dc = self.map.copy()
         # walk all files by default
         if not files: files = [self.root]
+        known = {'.hg': 1}
+        def seen(fn):
+            if fn in known: return True
+            known[fn] = 1
         def traverse():
             for f in util.unique(files):
                 f = os.path.join(self.root, f)
@@ -447,7 +451,7 @@
                     for dir, subdirs, fl in os.walk(f):
                         d = dir[len(self.root) + 1:]
                         nd = os.path.normpath(d)
-                        if nd == '.hg':
+                        if seen(nd):
                             subdirs[:] = []
                             continue
                         for sd in subdirs:
@@ -468,6 +472,7 @@
 
         for src, fn in util.unique(traverse()):
             fn = os.path.normpath(fn)
+            if seen(fn): continue
             if fn in dc:
                 del dc[fn]
             elif self.ignore(fn):