Mercurial > hg
changeset 36964:79b73be4dda5
rev-branch-cache: add a function to generate a part
The function is able to produce a rbc part consumed by the function introduced
into previous changesets. More details on usage and impact in the next
changesets.
author | Boris Feld <boris.feld@octobus.net> |
---|---|
date | Wed, 21 Feb 2018 17:26:22 +0100 |
parents | 9988fc10f49e |
children | b89a7ef29013 |
files | mercurial/bundle2.py |
diffstat | 1 files changed, 23 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Wed Feb 21 17:35:04 2018 +0100 +++ b/mercurial/bundle2.py Wed Feb 21 17:26:22 2018 +0100 @@ -147,6 +147,7 @@ from __future__ import absolute_import, division +import collections import errno import os import re @@ -1624,6 +1625,28 @@ if chunks: bundler.newpart('hgtagsfnodes', data=''.join(chunks)) +def addpartrevbranchcache(repo, bundler, outgoing): + # we include the rev branch cache for the bundle changeset + # (as an optional parts) + cache = repo.revbranchcache() + cl = repo.unfiltered().changelog + branchesdata = collections.defaultdict(lambda: (set(), set())) + for node in outgoing.missing: + branch, close = cache.branchinfo(cl.rev(node)) + branchesdata[branch][close].add(node) + + def generate(): + for branch, (nodes, closed) in sorted(branchesdata.items()): + utf8branch = encoding.fromlocal(branch) + yield rbcstruct.pack(len(utf8branch), len(nodes), len(closed)) + yield utf8branch + for n in sorted(nodes): + yield n + for n in sorted(closed): + yield n + + bundler.newpart('cache:rev-branch-cache', data=generate()) + def buildobsmarkerspart(bundler, markers): """add an obsmarker part to the bundler with <markers>