mercurial/match.py
changeset 39261 c9a3f7f5c023
parent 39260 27946fca8a05
child 39460 35ecaa999a12
equal deleted inserted replaced
39260:27946fca8a05 39261:c9a3f7f5c023
   585 
   585 
   586     def visitdir(self, dir):
   586     def visitdir(self, dir):
   587         return dir in self._dirs
   587         return dir in self._dirs
   588 
   588 
   589     def visitchildrenset(self, dir):
   589     def visitchildrenset(self, dir):
   590         if dir in self._dirs:
   590         if not self._fileset or dir not in self._dirs:
   591             candidates = self._dirs - {'.'}
   591             return set()
   592             if dir != '.':
   592 
   593                 d = dir + '/'
   593         candidates = self._fileset | self._dirs - {'.'}
   594                 candidates = set(c[len(d):] for c in candidates if
   594         if dir != '.':
   595                                  c.startswith(d))
   595             d = dir + '/'
   596             # self._dirs includes all of the directories, recursively, so if
   596             candidates = set(c[len(d):] for c in candidates if
   597             # we're attempting to match foo/bar/baz.txt, it'll have '.', 'foo',
   597                              c.startswith(d))
   598             # 'foo/bar' in it. Thus we can safely ignore a candidate that has a
   598         # self._dirs includes all of the directories, recursively, so if
   599             # '/' in it, indicating a it's for a subdir-of-a-subdir; the
   599         # we're attempting to match foo/bar/baz.txt, it'll have '.', 'foo',
   600             # immediate subdir will be in there without a slash.
   600         # 'foo/bar' in it. Thus we can safely ignore a candidate that has a
   601             ret = set(c for c in candidates if '/' not in c)
   601         # '/' in it, indicating a it's for a subdir-of-a-subdir; the
   602             # We need to emit 'this' for foo/bar, not set(), not {'baz.txt'}.
   602         # immediate subdir will be in there without a slash.
   603             if not ret:
   603         ret = {c for c in candidates if '/' not in c}
   604                 return 'this'
   604         # We really do not expect ret to be empty, since that would imply that
   605             return ret
   605         # there's something in _dirs that didn't have a file in _fileset.
   606         return set()
   606         assert ret
       
   607         return ret
   607 
   608 
   608     def isexact(self):
   609     def isexact(self):
   609         return True
   610         return True
   610 
   611 
   611     @encoding.strmethod
   612     @encoding.strmethod