mercurial/fileset.py
changeset 31192 951d95b13487
parent 31191 3c3ab84e6e78
child 31193 4140d49d2efb
equal deleted inserted replaced
31191:3c3ab84e6e78 31192:951d95b13487
   495             unknown = set()
   495             unknown = set()
   496         return (f for f in self.subset
   496         return (f for f in self.subset
   497                 if (f in self.ctx and f not in removed) or f in unknown)
   497                 if (f in self.ctx and f not in removed) or f in unknown)
   498     def narrow(self, files):
   498     def narrow(self, files):
   499         return matchctx(self.ctx, self.filter(files), self._status)
   499         return matchctx(self.ctx, self.filter(files), self._status)
       
   500     def switch(self, ctx, status=None):
       
   501         subset = self.filter(_buildsubset(ctx, status))
       
   502         return matchctx(ctx, subset, status)
   500 
   503 
   501 class fullmatchctx(matchctx):
   504 class fullmatchctx(matchctx):
   502     """A match context where any files in any revisions should be valid"""
   505     """A match context where any files in any revisions should be valid"""
   503 
   506 
   504     def __init__(self, ctx, status=None):
   507     def __init__(self, ctx, status=None):
   505         subset = _buildsubset(ctx, status)
   508         subset = _buildsubset(ctx, status)
   506         super(fullmatchctx, self).__init__(ctx, subset, status)
   509         super(fullmatchctx, self).__init__(ctx, subset, status)
       
   510     def switch(self, ctx, status=None):
       
   511         return fullmatchctx(ctx, status)
       
   512 
       
   513 # filesets using matchctx.switch()
       
   514 _switchcallers = [
       
   515 ]
   507 
   516 
   508 def _intree(funcs, tree):
   517 def _intree(funcs, tree):
   509     if isinstance(tree, tuple):
   518     if isinstance(tree, tuple):
   510         if tree[0] == 'func' and tree[1][0] == 'symbol':
   519         if tree[0] == 'func' and tree[1][0] == 'symbol':
   511             if tree[1][1] in funcs:
   520             if tree[1][1] in funcs:
   512                 return True
   521                 return True
       
   522             if tree[1][1] in _switchcallers:
       
   523                 # arguments won't be evaluated in the current context
       
   524                 return False
   513         for s in tree[1:]:
   525         for s in tree[1:]:
   514             if _intree(funcs, s):
   526             if _intree(funcs, s):
   515                 return True
   527                 return True
   516     return False
   528     return False
   517 
   529