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

login
register
mail settings
Submitter Siddharth Agarwal
Date Sept. 30, 2014, 11:08 p.m.
Message ID <3341e34839e9da4e028a.1412118500@devbig136.prn2.facebook.com>
Download mbox | patch
Permalink /patch/6052/
State Accepted
Headers show

Comments

Siddharth Agarwal - Sept. 30, 2014, 11:08 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@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.

Patch

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()