mercurial/manifest.py
changeset 24636 36872036169b
parent 24635 21e1ece30f8c
child 24646 5693c834bcb4
equal deleted inserted replaced
24635:21e1ece30f8c 24636:36872036169b
   579         if match.always():
   579         if match.always():
   580             return self.copy()
   580             return self.copy()
   581 
   581 
   582         return self._matches(match)
   582         return self._matches(match)
   583 
   583 
   584     def _matches(self, match):
   584     def _matches(self, match, alldirs=False):
   585         '''recursively generate a new manifest filtered by the match argument.
   585         '''recursively generate a new manifest filtered by the match argument.
   586         '''
   586 
       
   587         Will visit all subdirectories if alldirs is True, otherwise it will
       
   588         only visit subdirectories for which match.visitdir is True.'''
   587 
   589 
   588         ret = treemanifest(self._dir)
   590         ret = treemanifest(self._dir)
       
   591         if not alldirs:
       
   592             # substring to strip trailing slash
       
   593             visit = match.visitdir(self._dir[:-1] or '.')
       
   594             if not visit:
       
   595                 return ret
       
   596             alldirs = (visit == 'all')
   589 
   597 
   590         for fn in self._files:
   598         for fn in self._files:
   591             fullp = self._subpath(fn)
   599             fullp = self._subpath(fn)
   592             if not match(fullp):
   600             if not match(fullp):
   593                 continue
   601                 continue
   594             ret._files[fn] = self._files[fn]
   602             ret._files[fn] = self._files[fn]
   595             if fn in self._flags:
   603             if fn in self._flags:
   596                 ret._flags[fn] = self._flags[fn]
   604                 ret._flags[fn] = self._flags[fn]
   597 
   605 
   598         for dir, subm in self._dirs.iteritems():
   606         for dir, subm in self._dirs.iteritems():
   599             m = subm._matches(match)
   607             m = subm._matches(match, alldirs)
   600             if not m._isempty():
   608             if not m._isempty():
   601                 ret._dirs[dir] = m
   609                 ret._dirs[dir] = m
   602 
   610 
   603         return ret
   611         return ret
   604 
   612