# HG changeset patch # User Siddharth Agarwal # Date 1408572445 25200 # Node ID fe22d86a8992c5e442a45a3bfd673ca59129214a # Parent 4bc1fd86e915d15c9bcef04f9f29bd92915a85ef 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. diff -r 4bc1fd86e915 -r fe22d86a8992 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: