##// END OF EJS Templates
dirstate: have `running_status` write the dirstate when holding the lock...
marmoute -
r51042:0be70c7b default
parent child Browse files
Show More
@@ -213,9 +213,9 b' class dirstate:'
213 This context is not mutally exclusive with the `changing_*` context. It
213 This context is not mutally exclusive with the `changing_*` context. It
214 also do not warrant for the `wlock` to be taken.
214 also do not warrant for the `wlock` to be taken.
215
215
216 If the wlock is taken, this context will (in the future) behave in a
216 If the wlock is taken, this context will behave in a simple way, and
217 simple way, and ensure the data are scheduled for write when leaving
217 ensure the data are scheduled for write when leaving the top level
218 the top level context.
218 context.
219
219
220 If the lock is not taken, it will only warrant that the data are either
220 If the lock is not taken, it will only warrant that the data are either
221 committed (written) and rolled back (invalidated) when exiting the top
221 committed (written) and rolled back (invalidated) when exiting the top
@@ -235,8 +235,10 b' class dirstate:'
235 E1: elif lock was acquired β†’ write the changes
235 E1: elif lock was acquired β†’ write the changes
236 E2: else β†’ discard the changes
236 E2: else β†’ discard the changes
237 """
237 """
238 has_lock = repo.currentwlock() is not None
238 is_changing = self.is_changing_any
239 is_changing = self.is_changing_any
239 has_tr = repo.currenttransaction is not None
240 tr = repo.currenttransaction()
241 has_tr = tr is not None
240 nested = bool(self._running_status)
242 nested = bool(self._running_status)
241
243
242 first_and_alone = not (is_changing or has_tr or nested)
244 first_and_alone = not (is_changing or has_tr or nested)
@@ -248,6 +250,8 b' class dirstate:'
248 msg = "entering a status context, but dirstate is already dirty"
250 msg = "entering a status context, but dirstate is already dirty"
249 raise error.ProgrammingError(msg)
251 raise error.ProgrammingError(msg)
250
252
253 should_write = has_lock and not (nested or is_changing)
254
251 self._running_status += 1
255 self._running_status += 1
252 try:
256 try:
253 yield
257 yield
@@ -257,8 +261,13 b' class dirstate:'
257 finally:
261 finally:
258 self._running_status -= 1
262 self._running_status -= 1
259 if self._invalidated_context:
263 if self._invalidated_context:
264 should_write = False
260 self.invalidate()
265 self.invalidate()
261
266
267 if should_write:
268 assert repo.currenttransaction() is tr
269 self.write(tr)
270
262 @contextlib.contextmanager
271 @contextlib.contextmanager
263 @check_invalidated
272 @check_invalidated
264 def _changing(self, repo, change_type):
273 def _changing(self, repo, change_type):
General Comments 0
You need to be logged in to leave comments. Login now