changeset 8577:c7bab7fede4c

match: simplify _matcher - get rid of special case - simplify anypats logic - fold inckinds and exckinds
author Matt Mackall <mpm@selenic.com>
date Sun, 24 May 2009 02:56:14 -0500
parents ec4ed21db4b2
children 8388ef8d21cd
files mercurial/match.py
diffstat 1 files changed, 8 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
+++ b/mercurial/match.py	Sun May 24 02:56:14 2009 -0500
@@ -222,22 +222,18 @@
     - a bool indicating if any patterns were passed in
     """
 
-    # a common case: no patterns at all
-    if not names and not inc and not exc:
-        return [], lambda f: True, False
-
-    pats = _normalizepats(names, dflt_pat, root, cwd)
-    roots = _roots(pats)
-    anypats = _anypats(pats)
+    roots = []
+    anypats = bool(inc or exc)
 
     if names:
+        pats = _normalizepats(names, dflt_pat, root, cwd)
+        roots = _roots(pats)
+        anypats = anypats or _anypats(pats)
         patmatch = _matchfn(pats, '$')
     if inc:
-        inckinds = _normalizepats(inc, 'glob', root, cwd)
-        incmatch = _matchfn(inckinds, '(?:/|$)')
+        incmatch = _matchfn(_normalizepats(inc, 'glob', root, cwd), '(?:/|$)')
     if exc:
-        exckinds = _normalizepats(exc, 'glob', root, cwd)
-        excmatch = _matchfn(exckinds, '(?:/|$)')
+        excmatch = _matchfn(_normalizepats(exc, 'glob', root, cwd), '(?:/|$)')
 
     if names:
         if inc:
@@ -262,4 +258,4 @@
             else:
                 m = lambda f: True
 
-    return (roots, m, (inc or exc or anypats) and True)
+    return (roots, m, anypats)