Patchwork [6,of,7] dirstate: only invoke delaywrite if relevant

login
register
mail settings
Submitter Matt Mackall
Date Dec. 17, 2015, 2:59 a.m.
Message ID <1aa6cdd42ae70bb2be97.1450321182@ruin.waste.org>
Download mbox | patch
Permalink /patch/12092/
State Accepted
Commit c81675776c954cd4af5438332dfe71235a52f6c5
Headers show

Comments

Matt Mackall - Dec. 17, 2015, 2:59 a.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1450320558 21600
#      Wed Dec 16 20:49:18 2015 -0600
# Node ID 1aa6cdd42ae70bb2be9718b99316ca13b0d1443d
# Parent  02dd1df03cf2320ba0e25fc660ba6059e828240e
dirstate: only invoke delaywrite if relevant

This avoids a significant amount of sleeping in some of our longest
tests.

Patch

diff -r 02dd1df03cf2 -r 1aa6cdd42ae7 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Dec 16 20:46:53 2015 -0600
+++ b/mercurial/dirstate.py	Wed Dec 16 20:49:18 2015 -0600
@@ -708,8 +708,12 @@ 
         # timestamp of each entries in dirstate, because of 'now > mtime'
         delaywrite = self._ui.configint('debug', 'dirstate.delaywrite', 0)
         if delaywrite > 0:
-            import time # to avoid useless import
-            time.sleep(delaywrite)
+            # do we have any files to delay for?
+            for f, e in self._map.iteritems():
+                if e[0] == 'n' and e[3] == now:
+                    import time # to avoid useless import
+                    time.sleep(delaywrite)
+                    break
 
         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
         st.close()