comparison mercurial/bundle2.py @ 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
comparison
equal deleted inserted replaced
36963:9988fc10f49e 36964:79b73be4dda5
145 preserve. 145 preserve.
146 """ 146 """
147 147
148 from __future__ import absolute_import, division 148 from __future__ import absolute_import, division
149 149
150 import collections
150 import errno 151 import errno
151 import os 152 import os
152 import re 153 import re
153 import string 154 import string
154 import struct 155 import struct
1622 chunks.extend([node, fnode]) 1623 chunks.extend([node, fnode])
1623 1624
1624 if chunks: 1625 if chunks:
1625 bundler.newpart('hgtagsfnodes', data=''.join(chunks)) 1626 bundler.newpart('hgtagsfnodes', data=''.join(chunks))
1626 1627
1628 def addpartrevbranchcache(repo, bundler, outgoing):
1629 # we include the rev branch cache for the bundle changeset
1630 # (as an optional parts)
1631 cache = repo.revbranchcache()
1632 cl = repo.unfiltered().changelog
1633 branchesdata = collections.defaultdict(lambda: (set(), set()))
1634 for node in outgoing.missing:
1635 branch, close = cache.branchinfo(cl.rev(node))
1636 branchesdata[branch][close].add(node)
1637
1638 def generate():
1639 for branch, (nodes, closed) in sorted(branchesdata.items()):
1640 utf8branch = encoding.fromlocal(branch)
1641 yield rbcstruct.pack(len(utf8branch), len(nodes), len(closed))
1642 yield utf8branch
1643 for n in sorted(nodes):
1644 yield n
1645 for n in sorted(closed):
1646 yield n
1647
1648 bundler.newpart('cache:rev-branch-cache', data=generate())
1649
1627 def buildobsmarkerspart(bundler, markers): 1650 def buildobsmarkerspart(bundler, markers):
1628 """add an obsmarker part to the bundler with <markers> 1651 """add an obsmarker part to the bundler with <markers>
1629 1652
1630 No part is created if markers is empty. 1653 No part is created if markers is empty.
1631 Raises ValueError if the bundler doesn't support any known obsmarker format. 1654 Raises ValueError if the bundler doesn't support any known obsmarker format.