# HG changeset patch # User Martin von Zweigbergk # Date 1416441418 28800 # Node ID d44d53bc9a1ea53709c7d8685a08e323ab4724e0 # Parent 582cfcc843c78637e21971fd311b517a8ebf81cd matcher: make e.g. 'relpath:.' lead to fast paths Several commands take the fast path when match.always() is true. However, when the user passes "." on the command line, that results in a matcher for which match.always() == False. Let's make it so such matchers return True, and have an empty list of .files(). This makes e.g. "hg log ." as fast as "hg log" and "hg revert ." as fast as "hg revert --all" (when run from repo root). diff -r 582cfcc843c7 -r d44d53bc9a1e mercurial/match.py --- a/mercurial/match.py Wed Mar 25 14:56:54 2015 -0400 +++ b/mercurial/match.py Wed Nov 19 15:56:58 2014 -0800 @@ -34,6 +34,15 @@ other.append((kind, pat)) return fset, other +def _kindpatsalwaysmatch(kindpats): + """"Checks whether the kindspats match everything, as e.g. + 'relpath:.' does. + """ + for kind, pat in kindpats: + if pat != '' or kind not in ['relpath', 'glob']: + return False + return True + class match(object): def __init__(self, root, cwd, patterns, include=[], exclude=[], default='glob', exact=False, auditor=None, ctx=None): @@ -84,10 +93,11 @@ matchfns.append(self.exact) elif patterns: kindpats = _normalize(patterns, default, root, cwd, auditor) - self._files = _roots(kindpats) - self._anypats = self._anypats or _anypats(kindpats) - self.patternspat, pm = _buildmatch(ctx, kindpats, '$') - matchfns.append(pm) + if not _kindpatsalwaysmatch(kindpats): + self._files = _roots(kindpats) + self._anypats = self._anypats or _anypats(kindpats) + self.patternspat, pm = _buildmatch(ctx, kindpats, '$') + matchfns.append(pm) if not matchfns: m = util.always diff -r 582cfcc843c7 -r d44d53bc9a1e mercurial/scmutil.py --- a/mercurial/scmutil.py Wed Mar 25 14:56:54 2015 -0400 +++ b/mercurial/scmutil.py Wed Nov 19 15:56:58 2014 -0800 @@ -725,6 +725,8 @@ def badfn(f, msg): ctx.repo().ui.warn("%s: %s\n" % (m.rel(f), msg)) m.bad = badfn + if m.always(): + pats = [] return m, pats def match(ctx, pats=[], opts={}, globbed=False, default='relpath'):