[PATCH] dirstate: batch calls to statfiles (issue4878)

Matt Mackall mpm at selenic.com
Sun Oct 11 21:29:10 UTC 2015


# HG changeset patch
# User Matt Mackall <mpm at selenic.com>
# Date 1444166780 18000
#      Tue Oct 06 16:26:20 2015 -0500
# Node ID 109083f503a8c778e3f8fd3a1aeb9eeacd4ebc47
# Parent  3f234db6fe8d7cc3d39083f7e7523444bc21e5a2
dirstate: batch calls to statfiles (issue4878)

This makes it more interruptible.

diff -r 3f234db6fe8d -r 109083f503a8 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Thu Sep 24 13:58:18 2015 -0400
+++ b/mercurial/dirstate.py	Tue Oct 06 16:26:20 2015 -0500
@@ -928,8 +928,14 @@
                 # We may not have walked the full directory tree above,
                 # so stat and check everything we missed.
                 nf = iter(visit).next
-                for st in util.statfiles([join(i) for i in visit]):
-                    results[nf()] = st
+                pos = 0
+                while pos < len(visit):
+                    # visit in mid-sized batches so that we don't
+                    # block signals indefinitely
+                    xr = xrange(pos, min(len(visit), pos + 1000))
+                    for st in util.statfiles([join(visit[n]) for n in xr]):
+                        results[nf()] = st
+                    pos += 1000
         return results
 
     def status(self, match, subrepos, ignored, clean, unknown):


More information about the Mercurial-devel mailing list