changeset 22265:fe22d86a8992

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.
author Siddharth Agarwal <sid0@fb.com>
date Wed, 20 Aug 2014 15:07:25 -0700
parents 4bc1fd86e915
children 711de9dcb1d3
files hgext/purge.py
diffstat 1 files changed, 3 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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: