changeset 8684:5bb7780b57c7

match: fold plan cases down to two special cases - merge always and match with patterns - make always and match with patterns the default - invert dostep3 to skipstep3 - move dirignore test inside exact case
author Matt Mackall <mpm@selenic.com>
date Sun, 31 May 2009 17:54:18 -0500
parents 99eb4dcb37ce
children ad1907abf897
files mercurial/dirstate.py
diffstat 1 files changed, 8 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Sun May 31 17:54:18 2009 -0500
+++ b/mercurial/dirstate.py	Sun May 31 17:54:18 2009 -0500
@@ -460,21 +460,12 @@
         work = []
         wadd = work.append
 
-        if match.anypats(): # match.match or .exact with patterns
-            dostep3 = True
-            exact = False
-        elif matchfn == match.exact: # match.exact without patterns
-            dostep3 = False
+        exact = skipstep3 = False
+        if matchfn == match.exact: # match.exact
             exact = True
-        elif match.files(): # match.match without patterns
-            dostep3 = False
-            exact = False
-        else: # match.always
-            dostep3 = True
-            exact = False
-
-        if exact: # skip step 2
-            dirignore = util.always
+            dirignore = util.always # skip step 2
+        elif match.files() and not match.anypats(): # match.match, no patterns
+            skipstep3 = True
 
         files = set(match.files())
         if not files or '.' in files:
@@ -491,7 +482,7 @@
                 st = lstat(join(nf))
                 kind = getkind(st.st_mode)
                 if kind == dirkind:
-                    dostep3 = True
+                    skipstep3 = False
                     if nf in dmap:
                         #file deleted on disk but still in dirstate
                         results[nf] = None
@@ -510,7 +501,7 @@
                     prefix = nf + "/"
                     for fn in dmap:
                         if fn.startswith(prefix):
-                            dostep3 = True
+                            skipstep3 = False
                             break
                     else:
                         badfn(ff, inst.strerror)
@@ -550,7 +541,7 @@
                         results[nf] = None
 
         # step 3: report unseen items in the dmap hash
-        if dostep3 and not exact:
+        if not skipstep3 and not exact:
             visit = sorted([f for f in dmap if f not in results and matchfn(f)])
             for nf, st in zip(visit, util.statfiles([join(i) for i in visit])):
                 if not st is None and not getkind(st.st_mode) in (regkind, lnkkind):