Mercurial > hg
changeset 50146: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 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 13 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Tue Feb 21 22:32:04 2023 +0100 +++ b/mercurial/dirstate.py Mon Feb 20 16:57:10 2023 +0100 @@ -235,6 +235,19 @@ E1: elif lock was acquired → write the changes E2: else → discard the changes """ + is_changing = self.is_changing_any + has_tr = repo.currenttransaction is not None + nested = bool(self._running_status) + + first_and_alone = not (is_changing or has_tr or nested) + + # enforce no change happened outside of a proper context. + if first_and_alone and self._dirty: + has_tr = repo.currenttransaction() is not None + if not has_tr and self._changing_level == 0 and self._dirty: + msg = "entering a status context, but dirstate is already dirty" + raise error.ProgrammingError(msg) + self._running_status += 1 try: yield