# HG changeset patch # User Pierre-Yves David <pierre-yves.da...@octobus.net> # Date 1493998132 -7200 # Fri May 05 17:28:52 2017 +0200 # Node ID 16b60a34def41f52e024d32d6e99e5d533cad02f # Parent 54c7d588194032831969d2f68eec650ac2d2ff40 # EXP-Topic bundle2.tagsfnodecache # Available At https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ # hg pull https://www.mercurial-scm.org/repo/users/marmoute/mercurial/ -r 16b60a34def4 bundle2: move tagsfnodecache generation in a generic function
This will help us reusing the logic for `hg bundle`. diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -1378,6 +1378,30 @@ def _addpartsfromopts(ui, repo, bundler, 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. diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -29,7 +29,6 @@ from . import ( scmutil, sslutil, streamclone, - tags, url as urlmod, util, ) @@ -1664,30 +1663,7 @@ def _getbundletagsfnodes(bundler, repo, return outgoing = _computeoutgoing(repo, heads, common) - - if not outgoing.missingheads: - return - - 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)) + bundle2.addparttagsfnodescache(repo, bundler, outgoing) def _getbookmarks(repo, **kwargs): """Returns bookmark to node mapping. _______________________________________________ Mercurial-devel mailing list Mercurial-devel@mercurial-scm.org https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel