mercurial/dirstate.py
changeset 6588 10c23c1d5f33
parent 6587 a259e217bc0c
child 6589 0f98cae7c77f
equal deleted inserted replaced
6587:a259e217bc0c 6588:10c23c1d5f33
   420         # filter out the src and stat
   420         # filter out the src and stat
   421         for src, f, st in self.statwalk(match.files(), match, badfn=match.bad):
   421         for src, f, st in self.statwalk(match.files(), match, badfn=match.bad):
   422             yield f
   422             yield f
   423 
   423 
   424     def statwalk(self, files, match, unknown=True,
   424     def statwalk(self, files, match, unknown=True,
   425                  ignored=False, badfn=None, directories=False):
   425                  ignored=False, badfn=None):
   426         '''
   426         '''
   427         walk recursively through the directory tree, finding all files
   427         walk recursively through the directory tree, finding all files
   428         matched by the match function
   428         matched by the match function
   429 
   429 
   430         results are yielded in a tuple (src, filename, st), where src
   430         results are yielded in a tuple (src, filename, st), where src
   431         is one of:
   431         is one of:
   432         'f' the file was found in the directory tree
   432         'f' the file was found in the directory tree
   433         'd' the file is a directory of the tree
       
   434         'm' the file was only in the dirstate and not in the tree
   433         'm' the file was only in the dirstate and not in the tree
   435 
   434 
   436         and st is the stat result if the file was found in the directory.
   435         and st is the stat result if the file was found in the directory.
   437         '''
   436         '''
   438 
   437 
   483         def findfiles(s):
   482         def findfiles(s):
   484             work = [s]
   483             work = [s]
   485             wadd = work.append
   484             wadd = work.append
   486             found = []
   485             found = []
   487             add = found.append
   486             add = found.append
   488             if directories:
   487             if hasattr(match, 'dir'):
   489                 add((normpath(s[common_prefix_len:]), 'd', lstat(s)))
   488                 match.dir(normpath(s[common_prefix_len:]))
   490             while work:
   489             while work:
   491                 top = work.pop()
   490                 top = work.pop()
   492                 entries = listdir(top, stat=True)
   491                 entries = listdir(top, stat=True)
   493                 # nd is the top of the repository dir tree
   492                 # nd is the top of the repository dir tree
   494                 nd = normpath(top[common_prefix_len:])
   493                 nd = normpath(top[common_prefix_len:])
   511                     p = join(top, f)
   510                     p = join(top, f)
   512                     # don't trip over symlinks
   511                     # don't trip over symlinks
   513                     if kind == stat.S_IFDIR:
   512                     if kind == stat.S_IFDIR:
   514                         if not ignore(np):
   513                         if not ignore(np):
   515                             wadd(p)
   514                             wadd(p)
   516                             if directories:
   515                             if hasattr(match, 'dir'):
   517                                 add((np, 'd', st))
   516                                 match.dir(np)
   518                         if np in dc and match(np):
   517                         if np in dc and match(np):
   519                             add((np, 'm', st))
   518                             add((np, 'm', st))
   520                     elif imatch(np):
   519                     elif imatch(np):
   521                         if supported(np, st.st_mode):
   520                         if supported(np, st.st_mode):
   522                             add((np, 'f', st))
   521                             add((np, 'f', st))