##// END OF EJS Templates
walk: use match.dir in statwalk
Matt Mackall -
r6588:10c23c1d default
parent child Browse files
Show More
@@ -86,11 +86,10 b' def purge(ui, repo, *dirs, **opts):'
86 files = []
86 files = []
87 missing = []
87 missing = []
88 match = cmdutil.match(repo, dirs, opts)
88 match = cmdutil.match(repo, dirs, opts)
89 match.dir = directories.append
89 for src, f, st in repo.dirstate.statwalk(match.files(), match,
90 for src, f, st in repo.dirstate.statwalk(match.files(), match,
90 ignored=ignored, directories=True):
91 ignored=ignored):
91 if src == 'd':
92 if src == 'm':
92 directories.append(f)
93 elif src == 'm':
94 missing.append(f)
93 missing.append(f)
95 elif src == 'f' and f not in repo.dirstate:
94 elif src == 'f' and f not in repo.dirstate:
96 files.append(f)
95 files.append(f)
@@ -422,7 +422,7 b' class dirstate(object):'
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
@@ -430,7 +430,6 b' class dirstate(object):'
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.
@@ -485,8 +484,8 b' class dirstate(object):'
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)
@@ -513,8 +512,8 b' class dirstate(object):'
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):
General Comments 0
You need to be logged in to leave comments. Login now