# HG changeset patch # User Pierre-Yves David # Date 1676773272 -3600 # Node ID 3433723d1b9ba029d6421ef3d19234bb44b9b62d # Parent 9b49809eb6128f000881ea402a2e6b93a151edc7 dirstate: warn if dirty when starting an edition The dirstate should be clean before we start changing it. Otherwise we might write unrelated changes. Having a dirty dirstate laying around is also suspicious. This is similar to what we do when opening a new transaction, but this time this affect dirstate changes outside of a transaction. diff -r 9b49809eb612 -r 3433723d1b9b mercurial/dirstate.py --- a/mercurial/dirstate.py Tue Feb 21 03:22:51 2023 +0100 +++ b/mercurial/dirstate.py Sun Feb 19 03:21:12 2023 +0100 @@ -190,6 +190,9 @@ raise error.ProgrammingError(msg) has_tr = repo.currenttransaction() is not None + if not has_tr and self._changing_level == 0 and self._dirty: + msg = "entering a changing context, but dirstate is already dirty" + raise error.ProgrammingError(msg) # different type of change are mutually exclusive if self._change_type is None: