# HG changeset patch # User Pierre-Yves David # Date 1676321505 -3600 # Node ID d50d45cd5a5f1bf7d8d30f0781da86aaa0c00dd8 # Parent 0dc2fb4b4b117c1d59e5e9548b454d0319ced613 dirstate: invalidate the dirstate change on transaction failure If the change context lives inside a transaction, the change are not flushed to disk on exit as this is delegated to the transaction. As a result we should also delegate the part that do cleanup on failure. The issue was caught by tests with other change, but it seems useful to fix this as soon as possible. diff -r 0dc2fb4b4b11 -r d50d45cd5a5f mercurial/dirstate.py --- a/mercurial/dirstate.py Thu Jan 26 17:16:24 2023 +0100 +++ b/mercurial/dirstate.py Mon Feb 13 21:51:45 2023 +0100 @@ -204,7 +204,11 @@ # Exception catching (and the associated `invalidate` # calling) might have been called by a nested context # instead of the top level one. - self.write(repo.currenttransaction()) + tr = repo.currenttransaction() + if tr is not None: + abort_cb = lambda tr: self.invalidate() + tr.addabort(b'dirstate', abort_cb) + self.write(tr) @contextlib.contextmanager def changing_parents(self, repo):