comparison mercurial/fileset.py @ 38685:80466fd85ac9

fileset: rewrite andset() to not use mctx.narrow() New code is less efficient than the original, but it helps porting andset() to matcher composition. This will be cleaned up later. This effectively disables the fullmatchctx magic since mctx will never be demoted to the matchctx. The fullmatchctx class will be removed later.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 09 Jun 2018 18:11:49 +0900
parents 07b551a4df44
children 131aae58a316
comparison
equal deleted inserted replaced
38684:07b551a4df44 38685:80466fd85ac9
152 def kindpatset(mctx, x, y): 152 def kindpatset(mctx, x, y):
153 return stringset(mctx, _getkindpat(x, y, matchmod.allpatternkinds, 153 return stringset(mctx, _getkindpat(x, y, matchmod.allpatternkinds,
154 _("pattern must be a string"))) 154 _("pattern must be a string")))
155 155
156 def andset(mctx, x, y): 156 def andset(mctx, x, y):
157 return getset(mctx.narrow(getset(mctx, x)), y) 157 xl = set(getset(mctx, x))
158 yl = getset(mctx, y)
159 return [f for f in yl if f in xl]
158 160
159 def orset(mctx, x, y): 161 def orset(mctx, x, y):
160 # needs optimizing 162 # needs optimizing
161 xl = getset(mctx, x) 163 xl = getset(mctx, x)
162 yl = getset(mctx, y) 164 yl = getset(mctx, y)
625 else: 627 else:
626 removed = set() 628 removed = set()
627 unknown = set() 629 unknown = set()
628 return (f for f in self.subset 630 return (f for f in self.subset
629 if (f in self.ctx and f not in removed) or f in unknown) 631 if (f in self.ctx and f not in removed) or f in unknown)
630 def narrow(self, files): 632
631 return matchctx(self.ctx, self.filter(files), self._status, self._badfn)
632 def switch(self, ctx, status=None): 633 def switch(self, ctx, status=None):
633 subset = self.filter(_buildsubset(ctx, status)) 634 subset = self.filter(_buildsubset(ctx, status))
634 return matchctx(ctx, subset, status, self._badfn) 635 return matchctx(ctx, subset, status, self._badfn)
635 636
636 class fullmatchctx(matchctx): 637 class fullmatchctx(matchctx):