purge: avoid full walks when directories aren't purged
If match.traversedir is not None, we're forced to do full walks. However when
we aren't purging directories we don't need to set match.traversedir to
anything.
This speeds up non-full walks such as the one hgwatchman makes possible. For
mozilla-central with hgwatchman enabled, 'hg purge --files' goes from 0.88
seconds to 0.22.
--- a/hgext/purge.py Thu Aug 21 16:05:29 2014 -0700
+++ b/hgext/purge.py Wed Aug 20 15:07:25 2014 -0700
@@ -95,9 +95,10 @@
else:
ui.write('%s%s' % (name, eol))
- directories = []
match = scmutil.match(repo[None], dirs, opts)
- match.explicitdir = match.traversedir = directories.append
+ if removedirs:
+ directories = []
+ match.explicitdir = match.traversedir = directories.append
status = repo.status(match=match, ignored=opts['all'], unknown=True)
if removefiles: