##// END OF EJS Templates
dirstate: add begin/endparentchange to dirstate...
Durham Goode -
r22404:12bc7f06 default
parent child Browse files
Show More
@@ -44,6 +44,30 b' class dirstate(object):'
44 self._lastnormaltime = 0
44 self._lastnormaltime = 0
45 self._ui = ui
45 self._ui = ui
46 self._filecache = {}
46 self._filecache = {}
47 self._parentwriters = 0
48
49 def beginparentchange(self):
50 '''Marks the beginning of a set of changes that involve changing
51 the dirstate parents. If there is an exception during this time,
52 the dirstate will not be written when the wlock is released. This
53 prevents writing an incoherent dirstate where the parent doesn't
54 match the contents.
55 '''
56 self._parentwriters += 1
57
58 def endparentchange(self):
59 '''Marks the end of a set of changes that involve changing the
60 dirstate parents. Once all parent changes have been marked done,
61 the wlock will be free to write the dirstate on release.
62 '''
63 if self._parentwriters > 0:
64 self._parentwriters -= 1
65
66 def pendingparentchange(self):
67 '''Returns true if the dirstate is in the middle of a set of changes
68 that modify the dirstate parent.
69 '''
70 return self._parentwriters > 0
47
71
48 @propertycache
72 @propertycache
49 def _map(self):
73 def _map(self):
@@ -300,6 +324,7 b' class dirstate(object):'
300 delattr(self, a)
324 delattr(self, a)
301 self._lastnormaltime = 0
325 self._lastnormaltime = 0
302 self._dirty = False
326 self._dirty = False
327 self._parentwriters = 0
303
328
304 def copy(self, source, dest):
329 def copy(self, source, dest):
305 """Mark dest as a copy of source. Unmark dest if source is None."""
330 """Mark dest as a copy of source. Unmark dest if source is None."""
@@ -1102,7 +1102,11 b' class localrepository(object):'
1102 return l
1102 return l
1103
1103
1104 def unlock():
1104 def unlock():
1105 self.dirstate.write()
1105 if self.dirstate.pendingparentchange():
1106 self.dirstate.invalidate()
1107 else:
1108 self.dirstate.write()
1109
1106 self._filecache['dirstate'].refresh()
1110 self._filecache['dirstate'].refresh()
1107
1111
1108 l = self._lock(self.vfs, "wlock", wait, unlock,
1112 l = self._lock(self.vfs, "wlock", wait, unlock,
General Comments 0
You need to be logged in to leave comments. Login now