dirstate: distinct transaction callback from largefile
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 20 Feb 2023 23:46:20 +0100
changeset 50123 4e95341c89aa
parent 50122 72b4d9284411
child 50124 18149ecb5122
dirstate: distinct transaction callback from largefile This has not caused any issue so far because the large-files dirstate bypass the transaction logic. We might want to change that. In anyway, let us disarm this bug nest before it actually explode.
hgext/largefiles/lfutil.py
mercurial/dirstate.py
--- a/hgext/largefiles/lfutil.py	Mon Feb 20 16:31:36 2023 +0100
+++ b/hgext/largefiles/lfutil.py	Mon Feb 20 23:46:20 2023 +0100
@@ -160,6 +160,7 @@
 
 class largefilesdirstate(dirstate.dirstate):
     _large_file_dirstate = True
+    _tr_key_suffix = b'-large-files'
 
     def __getitem__(self, key):
         return super(largefilesdirstate, self).__getitem__(unixpath(key))
--- a/mercurial/dirstate.py	Mon Feb 20 16:31:36 2023 +0100
+++ b/mercurial/dirstate.py	Mon Feb 20 23:46:20 2023 +0100
@@ -133,6 +133,10 @@
 
 @interfaceutil.implementer(intdirstate.idirstate)
 class dirstate:
+
+    # used by largefile to avoid overwritting transaction callbacK
+    _tr_key_suffix = b''
+
     def __init__(
         self,
         opener,
@@ -951,7 +955,10 @@
 
             # make sure we invalidate the current change on abort
             if tr is not None:
-                tr.addabort(b'dirstate-invalidate', on_abort)
+                tr.addabort(
+                    b'dirstate-invalidate%s' % self._tr_key_suffix,
+                    on_abort,
+                )
 
             self._attached_to_a_transaction = True
 
@@ -961,7 +968,7 @@
 
             # delay writing in-memory changes out
             tr.addfilegenerator(
-                b'dirstate-1-main',
+                b'dirstate-1-main%s' % self._tr_key_suffix,
                 (self._filename,),
                 on_success,
                 location=b'plain',
@@ -969,7 +976,7 @@
             )
             if write_key:
                 tr.addfilegenerator(
-                    b'dirstate-2-key-post',
+                    b'dirstate-2-key-post%s' % self._tr_key_suffix,
                     (self._filename_th,),
                     lambda f: self._write_tracked_hint(tr, f),
                     location=b'plain',