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.
--- 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):