comparison mercurial/dirstate.py @ 50195:8ba5028de859

dirstate: check that dirstate is clean at the initial context opening More checking that we are not doing anything weird.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 20 Feb 2023 16:57:10 +0100
parents 72ef6c4888da
children 0be70c7b609c
comparison
equal deleted inserted replaced
50194:72ef6c4888da 50195:8ba5028de859
233 D: try to take the w-lock (this will invalidate the changes if they were raced) 233 D: try to take the w-lock (this will invalidate the changes if they were raced)
234 E0: if dirstate changed on disk → discard change (done by dirstate internal) 234 E0: if dirstate changed on disk → discard change (done by dirstate internal)
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 is_changing = self.is_changing_any
239 has_tr = repo.currenttransaction is not None
240 nested = bool(self._running_status)
241
242 first_and_alone = not (is_changing or has_tr or nested)
243
244 # enforce no change happened outside of a proper context.
245 if first_and_alone and self._dirty:
246 has_tr = repo.currenttransaction() is not None
247 if not has_tr and self._changing_level == 0 and self._dirty:
248 msg = "entering a status context, but dirstate is already dirty"
249 raise error.ProgrammingError(msg)
250
238 self._running_status += 1 251 self._running_status += 1
239 try: 252 try:
240 yield 253 yield
241 except Exception: 254 except Exception:
242 self.invalidate() 255 self.invalidate()