[PATCH 1 of 7 V3] revbranchcache: add a public function to update the data

Boris Feld boris.feld at octobus.net
Thu Mar 15 14:30:51 UTC 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1516281665 -3600
#      Thu Jan 18 14:21:05 2018 +0100
# Node ID ec581b3db32120b39cd7c4b9019955c0b0374d60
# Parent  3f3418a4a7743c7019cd4ec5fc1ac1ce7c1b61ab
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ec581b3db321
revbranchcache: add a public function to update the data

We want to exchange more cached data over the wire. To do so, we need a clean
way to update the cache on the receiving ends.

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -454,6 +454,26 @@ class revbranchcache(object):
         self._setcachedata(rev, reponode, branchidx)
         return b, close
 
+    def setdata(self, branch, rev, node, close):
+        """add new data information to the cache"""
+        if branch in self._namesreverse:
+            branchidx = self._namesreverse[branch]
+        else:
+            branchidx = len(self._names)
+            self._names.append(branch)
+            self._namesreverse[branch] = branchidx
+        if close:
+            branchidx |= _rbccloseflag
+        self._setcachedata(rev, node, branchidx)
+        # If no cache data were readable (non exists, bad permission, etc)
+        # the cache was bypassing itself by setting:
+        #
+        #   self.branchinfo = self._branchinfo
+        #
+        # Since we now have data in the cache, we need to drop this bypassing.
+        if 'branchinfo' in vars(self):
+            del self.branchinfo
+
     def _setcachedata(self, rev, node, branchidx):
         """Writes the node's branch data to the in-memory cache data."""
         if rev == nullrev:


More information about the Mercurial-devel mailing list