# HG changeset patch # User Pierre-Yves David # Date 1677015124 -3600 # Node ID 72ef6c4888da80c302ecf4dc9a33caed564fee30 # Parent c6df5349183b36390088f64f4fb34760051ceaaa dirstate: start tracking that we are within a `running_status` context diff -r c6df5349183b -r 72ef6c4888da mercurial/dirstate.py --- a/mercurial/dirstate.py Mon Feb 20 15:28:08 2023 +0100 +++ b/mercurial/dirstate.py Tue Feb 21 22:32:04 2023 +0100 @@ -175,6 +175,8 @@ self._changing_level = 0 # the change currently underway self._change_type = None + # number of open _running_status context + self._running_status = 0 # True if the current dirstate changing operations have been # invalidated (used to make sure all nested contexts have been exited) self._invalidated_context = False @@ -233,7 +235,16 @@ E1: elif lock was acquired → write the changes E2: else → discard the changes """ - yield + self._running_status += 1 + try: + yield + except Exception: + self.invalidate() + raise + finally: + self._running_status -= 1 + if self._invalidated_context: + self.invalidate() @contextlib.contextmanager @check_invalidated @@ -598,8 +609,10 @@ delattr(self, a) self._dirty = False self._dirty_tracked_set = False - self._invalidated_context = ( - self._changing_level > 0 or self._attached_to_a_transaction + self._invalidated_context = bool( + self._changing_level > 0 + or self._attached_to_a_transaction + or self._running_status ) self._origpl = None