Mercurial > public > mercurial-scm > hg-stable
diff mercurial/bundle2.py @ 32262:6068712cbf03
bundle2: move tagsfnodecache generation in a generic function
This will help us reusing the logic for `hg bundle`.
author | Pierre-Yves David <pierre-yves.david@octobus.net> |
---|---|
date | Fri, 05 May 2017 17:28:52 +0200 |
parents | 9dc36df78403 |
children | d7f93ebbbbdf |
line wrap: on
line diff
--- a/mercurial/bundle2.py Fri May 05 17:09:47 2017 +0200 +++ b/mercurial/bundle2.py Fri May 05 17:28:52 2017 +0200 @@ -1375,6 +1375,30 @@ part.addparam('nbchanges', str(cg.extras['clcount']), mandatory=False) +def addparttagsfnodescache(repo, bundler, outgoing): + # we include the tags fnode cache for the bundle changeset + # (as an optional parts) + cache = tags.hgtagsfnodescache(repo.unfiltered()) + chunks = [] + + # .hgtags fnodes are only relevant for head changesets. While we could + # transfer values for all known nodes, there will likely be little to + # no benefit. + # + # We don't bother using a generator to produce output data because + # a) we only have 40 bytes per head and even esoteric numbers of heads + # consume little memory (1M heads is 40MB) b) we don't want to send the + # part if we don't have entries and knowing if we have entries requires + # cache lookups. + for node in outgoing.missingheads: + # Don't compute missing, as this may slow down serving. + fnode = cache.getfnode(node, computemissing=False) + if fnode is not None: + chunks.extend([node, fnode]) + + if chunks: + bundler.newpart('hgtagsfnodes', data=''.join(chunks)) + def writebundle(ui, cg, filename, bundletype, vfs=None, compression=None, compopts=None): """Write a bundle file and return its filename.