changeset 51518:bb8612053547

branchcache: fix the copy code We copy some internal attribute along too. This should prevent inconsistency in the resulting branchmap.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Mon, 19 Feb 2024 12:09:06 +0100
parents 5515876173ba
children 84fca6d79e25
files mercurial/branchmap.py
diffstat 1 files changed, 18 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- 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, (