changeset 50076:63c4e9639753

dirstate: generalize the dirstate's invalidation on transaction abort The previous code was too specific, we should add the invalidation at next to the `addfilegenerator` in the `write` call.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 16 Feb 2023 02:34:54 +0100
parents 8eb460e0a202
children 605f0ccffb43
files mercurial/dirstate.py
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/dirstate.py	Thu Feb 16 02:22:13 2023 +0100
+++ b/mercurial/dirstate.py	Thu Feb 16 02:34:54 2023 +0100
@@ -217,9 +217,6 @@
                         # calling) might have been called by a nested context
                         # instead of the top level one.
                         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
@@ -917,6 +914,12 @@
 
         write_key = self._use_tracked_hint and self._dirty_tracked_set
         if tr:
+            # make sure we invalidate the current change on abort
+            if tr is not None:
+                tr.addabort(
+                    b'dirstate-invalidate',
+                    lambda tr: self.invalidate(),
+                )
             # delay writing in-memory changes out
             tr.addfilegenerator(
                 b'dirstate-1-main',