dirstate: only invoke delaywrite if relevant
authorMatt Mackall <mpm@selenic.com>
Wed, 16 Dec 2015 20:49:18 -0600
changeset 27398 c81675776c95
parent 27397 6c6b48aca328
child 27399 425dc70037f7
dirstate: only invoke delaywrite if relevant This avoids a significant amount of sleeping in some of our longest tests.
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()