changeset 12211:798d72f3621c

dirstate: use one pass to filter out files in subrepos
author Martin Geisler <mg@lazybytes.net>
date Fri, 10 Sep 2010 23:53:51 +0200
parents 21eb85e9ea94
children e1cf13e9e051 bd98796c0b6f
files mercurial/dirstate.py
diffstat 1 files changed, 13 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Fri Sep 10 23:53:49 2010 +0200
+++ b/mercurial/dirstate.py	Fri Sep 10 23:53:51 2010 +0200
@@ -497,16 +497,25 @@
         elif match.files() and not match.anypats(): # match.match, no patterns
             skipstep3 = True
 
-        files = set(match.files())
-        for s in subrepos:
-            files = [f for f in files if not f.startswith(s + "/")]
+        files = sorted(match.files())
+        subrepos.sort()
+        i, j = 0, 0
+        while i < len(files) and j < len(subrepos):
+            subpath = subrepos[j] + "/"
+            if not files[i].startswith(subpath):
+                i += 1
+                continue
+            while files and files[i].startswith(subpath):
+                del files[i]
+            j += 1
+
         if not files or '.' in files:
             files = ['']
         results = dict.fromkeys(subrepos)
         results['.hg'] = None
 
         # step 1: find all explicit files
-        for ff in sorted(files):
+        for ff in files:
             nf = normalize(normpath(ff), False)
             if nf in results:
                 continue