From 8874cd66a5555ddcaa8262bd233ebe3e9f6c1990 Mon Sep 17 00:00:00 2001 From: Martin von Zweigbergk Date: Wed, 29 Oct 2014 08:43:39 -0700 Subject: [PATCH] match: add isexact() method to hide internals Comparing a function reference seems bad. --- mercurial/dirstate.py | 6 +++--- mercurial/manifest.py | 4 ++-- mercurial/match.py | 3 +++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py index 60ac547a5a..6098fda27f 100644 --- a/mercurial/dirstate.py +++ b/mercurial/dirstate.py @@ -611,7 +611,7 @@ class dirstate(object): dirsnotfound = [] notfoundadd = dirsnotfound.append - if match.matchfn != match.exact and self._checkcase: + if not match.isexact() and self._checkcase: normalize = self._normalize else: normalize = None @@ -711,7 +711,7 @@ class dirstate(object): join = self._join exact = skipstep3 = False - if matchfn == match.exact: # match.exact + if match.isexact(): # match.exact exact = True dirignore = util.always # skip step 2 elif match.files() and not match.anypats(): # match.match, no patterns @@ -912,7 +912,7 @@ class dirstate(object): if match.always(): return dmap.keys() files = match.files() - if match.matchfn == match.exact: + if match.isexact(): # fast path -- filter the other way around, since typically files is # much smaller than dmap return [f for f in files if f in dmap] diff --git a/mercurial/manifest.py b/mercurial/manifest.py index c7cd623c59..8033492ee3 100644 --- a/mercurial/manifest.py +++ b/mercurial/manifest.py @@ -164,7 +164,7 @@ class manifestdict(object): return self.copy() files = match.files() - if (len(files) < 100 and (match.matchfn == match.exact or + if (len(files) < 100 and (match.isexact() or (not match.anypats() and util.all(fn in self for fn in files)))): return self.intersectfiles(files) @@ -519,7 +519,7 @@ class treemanifest(object): return self.copy() files = match.files() - if (match.matchfn == match.exact or + if (match.isexact() or (not match.anypats() and util.all(fn in self for fn in files))): return self.intersectfiles(files) diff --git a/mercurial/match.py b/mercurial/match.py index 16bd08d28b..ff51ff158e 100644 --- a/mercurial/match.py +++ b/mercurial/match.py @@ -171,6 +171,9 @@ class match(object): - optimization might be possible and necessary.''' return self._always + def isexact(self): + return self.matchfn == self.exact + def exact(root, cwd, files): return match(root, cwd, files, exact=True)