mercurial/dirstate.py
changeset 50025 d50d45cd5a5f
parent 50024 0dc2fb4b4b11
child 50026 3550e4a88ccd
--- 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):