Patchwork [1,of,4] revbranchcache: add a public function to update the data

login
register
mail settings
Submitter Boris Feld
Date Jan. 18, 2018, 3:38 p.m.
Message ID <4ad1a1054450063cc9aa.1516289924@FB>
Download mbox | patch
Permalink /patch/26904/
State Accepted
Headers show

Comments

Boris Feld - Jan. 18, 2018, 3:38 p.m.
# HG changeset patch
# User Boris Feld <boris.feld@octobus.net>
# Date 1516281665 -3600
#      Thu Jan 18 14:21:05 2018 +0100
# Node ID 4ad1a1054450063cc9aa19ab2037722c64877eb7
# Parent  9c575c22dcf4305db2160dc45350ba8e40cf5e60
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 4ad1a1054450
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.

Patch

diff --git a/mercurial/branchmap.py b/mercurial/branchmap.py
--- a/mercurial/branchmap.py
+++ b/mercurial/branchmap.py
@@ -451,6 +451,18 @@  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)
+
     def _setcachedata(self, rev, node, branchidx):
         """Writes the node's branch data to the in-memory cache data."""
         if rev == nullrev: