Patchwork [2,of,6] dirstate.walk: move dirignore filter out of explicit walk code

login
register
mail settings
Submitter Siddharth Agarwal
Date May 7, 2013, 9:32 p.m.
Message ID <924523a3e1fbd533419c.1367962329@dev1091.prn1.facebook.com>
Download mbox | patch
Permalink /patch/1583/
State Accepted
Commit 252de7b77cfd41f125faad841ce038348821404b
Headers show

Comments

Siddharth Agarwal - May 7, 2013, 9:32 p.m.
# HG changeset patch
# User Siddharth Agarwal <sid0@fb.com>
# Date 1367945230 25200
#      Tue May 07 09:47:10 2013 -0700
# Node ID 924523a3e1fbd533419ce22c8bd036576b1d274d
# Parent  869ee5ce0194c7b931d18754ff044f395a249984
dirstate.walk: move dirignore filter out of explicit walk code

This is a move towards factoring this code out into a separate function.
Siddharth Agarwal - May 9, 2013, 8:42 p.m.
On 05/09/2013 12:26 PM, Kevin Bullock wrote:
> Seems like this could have some performance implications?

The explicit walk code only runs for files that are explicitly specified 
in match.files(), so no, not really. The most common case (hg status/hg 
diff) indeed doesn't have any explicit files at all, so this will have 
zero perf impact.

Patch

diff --git a/mercurial/dirstate.py b/mercurial/dirstate.py
--- a/mercurial/dirstate.py
+++ b/mercurial/dirstate.py
@@ -626,8 +626,7 @@ 
                         results[nf] = None
                     if matchedir:
                         matchedir(nf)
-                    if not dirignore(nf):
-                        wadd(nf)
+                    wadd(nf)
                 elif kind == regkind or kind == lnkkind:
                     results[nf] = st
                 else:
@@ -649,6 +648,9 @@ 
                     else:
                         badfn(ff, inst.strerror)
 
+        work = [d for d in work if not dirignore(d)]
+        wadd = work.append
+
         # step 2: visit subdirectories
         while work:
             nd = work.pop()