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

login
register
mail settings
Submitter Boris Feld
Date March 1, 2018, 8:44 p.m.
Message ID <9072a7903a7890cc61a6.1519937056@FB>
Download mbox | patch
Permalink /patch/28585/
State Superseded
Headers show

Comments

Boris Feld - March 1, 2018, 8:44 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 9072a7903a7890cc61a6b7d0c7fa95e6d6db5b27
# Parent  4b9e9e3f450c7c8a8717e0a2ed9573a067903ce6
# EXP-Topic wire-rbc
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9072a7903a78
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.
Yuya Nishihara - March 3, 2018, 12:22 a.m.
On Thu, 01 Mar 2018 15:44:16 -0500, Boris Feld wrote:
> # HG changeset patch
> # User Boris Feld <boris.feld@octobus.net>
> # Date 1516281665 -3600
> #      Thu Jan 18 14:21:05 2018 +0100
> # Node ID 9072a7903a7890cc61a6b7d0c7fa95e6d6db5b27
> # Parent  4b9e9e3f450c7c8a8717e0a2ed9573a067903ce6
> # EXP-Topic wire-rbc
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9072a7903a78
> revbranchcache: add a public function to update the data

The series looks good to me. Can you rebase onto the current tip?
Boris FELD - March 15, 2018, 2:31 p.m.
I just sent a V3, I didn't saw your email sorry.


On 03/03/2018 01:22, Yuya Nishihara wrote:
> On Thu, 01 Mar 2018 15:44:16 -0500, Boris Feld wrote:
>> # HG changeset patch
>> # User Boris Feld <boris.feld@octobus.net>
>> # Date 1516281665 -3600
>> #      Thu Jan 18 14:21:05 2018 +0100
>> # Node ID 9072a7903a7890cc61a6b7d0c7fa95e6d6db5b27
>> # Parent  4b9e9e3f450c7c8a8717e0a2ed9573a067903ce6
>> # EXP-Topic wire-rbc
>> # Available At https://bitbucket.org/octobus/mercurial-devel/
>> #              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 9072a7903a78
>> revbranchcache: add a public function to update the data
> The series looks good to me. Can you rebase onto the current tip?
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

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: