diff mercurial/localrepo.py @ 22404:12bc7f06fc41

dirstate: add begin/endparentchange to dirstate It's possible for the dirstate to become incoherent (issue4353) if there is an exception in the middle of the dirstate parent and entries being written (like if the user ctrl+c's). This change adds begin/endparentchange which a future patch will require to be set before changing the dirstate parent. This will allow us to prevent writing the dirstate in the event of an exception while changing the parent.
author Durham Goode <durham@fb.com>
date Fri, 05 Sep 2014 11:34:29 -0700
parents c9b32c6a2944
children 6f63c47cbb86
line wrap: on
line diff
--- a/mercurial/localrepo.py	Mon Sep 08 20:57:44 2014 +0200
+++ b/mercurial/localrepo.py	Fri Sep 05 11:34:29 2014 -0700
@@ -1102,7 +1102,11 @@
             return l
 
         def unlock():
-            self.dirstate.write()
+            if self.dirstate.pendingparentchange():
+                self.dirstate.invalidate()
+            else:
+                self.dirstate.write()
+
             self._filecache['dirstate'].refresh()
 
         l = self._lock(self.vfs, "wlock", wait, unlock,