purge: avoid full walks when directories aren't purged
authorSiddharth Agarwal <sid0@fb.com>
Wed, 20 Aug 2014 15:07:25 -0700
changeset 22265 fe22d86a8992
parent 22264 4bc1fd86e915
child 22266 711de9dcb1d3
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.
hgext/purge.py
--- 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: