Patchwork [5,of,7] dirstate: move delaywrite logic from write to _write

login
register
mail settings
Submitter Matt Mackall
Date Dec. 17, 2015, 2:59 a.m.
Message ID <02dd1df03cf2320ba0e2.1450321181@ruin.waste.org>
Download mbox | patch
Permalink /patch/12091/
State Accepted
Commit 6c6b48aca328834995f5904bc951f44305f9e3b4
Headers show

Comments

Matt Mackall - Dec. 17, 2015, 2:59 a.m.
# HG changeset patch
# User Matt Mackall <mpm@selenic.com>
# Date 1450320413 21600
#      Wed Dec 16 20:46:53 2015 -0600
# Node ID 02dd1df03cf2320ba0e25fc660ba6059e828240e
# Parent  48db46e1cd5734564f435f015de1c5cbb99481a0
dirstate: move delaywrite logic from write to _write

This will allow us to be smarter in upcoming patches.

Patch

diff -r 48db46e1cd57 -r 02dd1df03cf2 mercurial/dirstate.py
--- a/mercurial/dirstate.py	Mon Dec 07 16:16:06 2015 -0600
+++ b/mercurial/dirstate.py	Wed Dec 16 20:46:53 2015 -0600
@@ -662,13 +662,6 @@ 
         if not self._dirty:
             return
 
-        # enough 'delaywrite' prevents 'pack_dirstate' from dropping
-        # 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)
-
         filename = self._filename
         if tr is False: # not explicitly specified
             if (self._ui.configbool('devel', 'all-warnings')
@@ -710,6 +703,14 @@ 
         # use the modification time of the newly created temporary file as the
         # filesystem's notion of 'now'
         now = util.fstat(st).st_mtime & _rangemask
+
+        # enough 'delaywrite' prevents 'pack_dirstate' from dropping
+        # 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)
+
         st.write(parsers.pack_dirstate(self._map, self._copymap, self._pl, now))
         st.close()
         self._lastnormaltime = 0