dirstate: move delaywrite logic from write to _write
authorMatt Mackall <mpm@selenic.com>
Wed, 16 Dec 2015 20:46:53 -0600
changeset 27397 6c6b48aca328
parent 27396 64c584070fc7
child 27398 c81675776c95
dirstate: move delaywrite logic from write to _write This will allow us to be smarter in upcoming patches.
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