Patchwork [5,of,7,V3] revbranchcache: add the necessary bit to send 'rbc' data over bundle2

mail settings
Submitter Boris Feld
Date March 15, 2018, 2:30 p.m.
Message ID <e4e572bef19bde11ac42.1521124255@FB>
Download mbox | patch
Permalink /patch/29538/
State Superseded
Headers show


Boris Feld - March 15, 2018, 2:30 p.m.
# HG changeset patch
# User Boris Feld <>
# Date 1516283882 -3600
#      Thu Jan 18 14:58:02 2018 +0100
# Node ID e4e572bef19bde11ac42e68f3acaad02f83b0fbb
# Parent  1c52141b19cb805877b648d5ae4320a4f76f50ba
# EXP-Topic wire-rbc
# Available At
#              hg pull -r e4e572bef19b
revbranchcache: add the necessary bit to send 'rbc' data over bundle2

Getbundle is now capable of sending rev-branch-cache information for the
changesets it bundle. The data sent are mostly nodes so it is quite compact.
The goal of the rev-branch-cache is to speed up branch map computation,
especially when the branchmap gets invalidated so we send data for all
exchanged changesets. In addition, computing the relevant heads to send in
case of partial pulling would be challenging.

The feature is still inactive since the capability is not advertised yet.


diff --git a/mercurial/ b/mercurial/
--- a/mercurial/
+++ b/mercurial/
@@ -1939,6 +1939,28 @@  def _getbundletagsfnodes(bundler, repo, 
     outgoing = _computeoutgoing(repo, heads, common)
     bundle2.addparttagsfnodescache(repo, bundler, outgoing)
+def _getbundlerevbranchcache(bundler, repo, source, bundlecaps=None,
+                             b2caps=None, heads=None, common=None,
+                             **kwargs):
+    """Transfer the rev-branch-cache mapping
+    The payload is a series of data related to each branch
+    1) branch name length
+    2) number of open heads
+    3) number of closed heads
+    4) open heads nodes
+    5) closed heads nodes
+    """
+    # Don't send unless:
+    # - changeset are being exchanged,
+    # - the client supports it.
+    if not (kwargs.get(r'cg', True)) or 'rev-branch-cache' not in b2caps:
+        return
+    outgoing = _computeoutgoing(repo, heads, common)
+    bundle2.addpartrevbranchcache(repo, bundler, outgoing)
 def check_heads(repo, their_heads, context):
     """check if the heads of a repo have been modified