# HG changeset patch # User Jesse Glick # Date 2012-05-04 19:54:55 # Node ID 9a21fc2c7d323078442d0386b3f2b390aec5c8e4 # Parent 98a9266db80306efe6994d972f7962fe8aeb51c4 localrepo: optimize internode status calls using match.always Introduce match.always() to check if a match object always says yes, i.e. None was passed in. If so, mfmatches should not bother iterating every file in the repository. diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py --- a/mercurial/localrepo.py +++ b/mercurial/localrepo.py @@ -1333,6 +1333,8 @@ class localrepository(repo.repository): def mfmatches(ctx): mf = ctx.manifest().copy() + if match.always(): + return mf for fn in mf.keys(): if not match(fn): del mf[fn] diff --git a/mercurial/match.py b/mercurial/match.py --- a/mercurial/match.py +++ b/mercurial/match.py @@ -118,6 +118,8 @@ class match(object): return self._files def anypats(self): return self._anypats + def always(self): + return False class exact(match): def __init__(self, root, cwd, files): @@ -126,6 +128,8 @@ class exact(match): class always(match): def __init__(self, root, cwd): match.__init__(self, root, cwd, []) + def always(self): + return True class narrowmatcher(match): """Adapt a matcher to work on a subdirectory only.