branchcache: fix the copy code
authorPierre-Yves David <pierre-yves.david@octobus.net>
Mon, 19 Feb 2024 12:09:06 +0100
changeset 51453 bb8612053547
parent 51452 5515876173ba
child 51454 84fca6d79e25
branchcache: fix the copy code We copy some internal attribute along too. This should prevent inconsistency in the resulting branchmap.
mercurial/branchmap.py
--- a/mercurial/branchmap.py	Mon Feb 19 13:11:42 2024 +0100
+++ b/mercurial/branchmap.py	Mon Feb 19 12:09:06 2024 +0100
@@ -432,16 +432,26 @@
         return self._entries.values()
 
     def copy(self, repo):
-        """return an deep copy of the branchcache object"""
-        return type(self)(
-            repo,
-            self._entries,
-            self.tipnode,
-            self.tiprev,
-            self.filteredhash,
-            self._closednodes,
+        """return a deep copy of the branchcache object"""
+        other = type(self)(
+            repo=repo,
+            # we always do a shally copy of self._entries, and the values is
+            # always replaced, so no need to deepcopy until the above remains
+            # true.
+            entries=self._entries,
+            tipnode=self.tipnode,
+            tiprev=self.tiprev,
+            filteredhash=self.filteredhash,
+            closednodes=set(self._closednodes),
             verify_node=self._verify_node,
         )
+        # we copy will likely schedule a write anyway, but that does not seems
+        # to hurt to overschedule
+        other._delayed = self._delayed
+        # also copy information about the current verification state
+        other._closedverified = self._closedverified
+        other._verifiedbranches = set(self._verifiedbranches)
+        return other
 
     def write(self, repo):
         assert self._filtername == repo.filtername, (