[PATCH 2 of 4] files: use ctx.matches instead of ctx.walk

Siddharth Agarwal sid0 at fb.com
Tue Sep 30 18:08:20 CDT 2014


# HG changeset patch
# User Siddharth Agarwal <sid0 at fb.com>
# Date 1412113198 25200
#      Tue Sep 30 14:39:58 2014 -0700
# Node ID 3341e34839e9da4e028a2752935e73a967ce2697
# Parent  cd1e5a9bcba5ffd16df59046db42428a0d779dbc
files: use ctx.matches instead of ctx.walk

ctx.matches() is an optimized form of ctx.walk() when we don't care about the
state of files on disk.

For a large repo, 'hg files > /dev/null' drops from 3.7 seconds to 2.3.

diff --git a/mercurial/commands.py b/mercurial/commands.py
--- a/mercurial/commands.py
+++ b/mercurial/commands.py
@@ -3219,7 +3219,7 @@
     fmt = '%s' + end
 
     m = scmutil.match(ctx, pats, opts)
-    for f in ctx.walk(m):
+    for f in ctx.matches(m):
         if rev is None and repo.dirstate[f] in 'r?!':
             continue
         fm.startitem()


More information about the Mercurial-devel mailing list