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