diff mercurial/dirstate.py @ 27397:6c6b48aca328

dirstate: move delaywrite logic from write to _write This will allow us to be smarter in upcoming patches.
author Matt Mackall <mpm@selenic.com>
date Wed, 16 Dec 2015 20:46:53 -0600
parents 54ace3372f84
children c81675776c95
line wrap: on
line diff
--- 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