Mercurial > hg-stable
diff mercurial/changegroup.py @ 29593:953839de96ab
bundle2: store changeset count when creating file bundles
The bundle2 changegroup part has an advisory param saying how many
changesets are in the part. Before this patch, we were setting
this part when generating bundle2 parts via the wire protocol but
not when generating local bundle2 files.
A side effect of not setting the changeset count part is that progress
bars don't work when applying changesets. As the tests show, this
impacted clone bundles, shelve, backup bundles, `hg unbundle`, and
anything touching bundle2 files.
This patch adds a backdoor to allow us to pass state from
changegroup generation into the unbundler. We store the number
of changesets in the changegroup in this state and use it to
populate the aforementioned advisory part parameter when generating
the bundle2 bundle.
I concede that I'm not thrilled by how state is being passed in
changegroup.py (it feels a bit hacky). I would love to overhaul the
rather confusing set of functions in changegroup.py with something that
passes rich objects around instead of e.g. low-level generators.
However, given the code freeze for 3.9 is imminent, I'd rather not
undertake this endeavor right now. This feels like the easiest way
to get the parameter added to the changegroup part.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Sun, 17 Jul 2016 15:13:51 -0700 |
parents | 1b699c7eb2b7 |
children | 5684bc429e6a |
line wrap: on
line diff
--- a/mercurial/changegroup.py Sun Jul 17 15:10:30 2016 -0700 +++ b/mercurial/changegroup.py Sun Jul 17 15:13:51 2016 -0700 @@ -135,7 +135,7 @@ version = '01' _grouplistcount = 1 # One list of files after the manifests - def __init__(self, fh, alg): + def __init__(self, fh, alg, extras=None): if alg == 'UN': alg = None # get more modern without breaking too much if not alg in util.decompressors: @@ -145,6 +145,7 @@ alg = '_truncatedBZ' self._stream = util.decompressors[alg](fh) self._type = alg + self.extras = extras or {} self.callback = None # These methods (compressed, read, seek, tell) all appear to only @@ -900,8 +901,8 @@ assert version in supportedoutgoingversions(repo) return _packermap[version][0](repo, bundlecaps) -def getunbundler(version, fh, alg): - return _packermap[version][1](fh, alg) +def getunbundler(version, fh, alg, extras=None): + return _packermap[version][1](fh, alg, extras=extras) def _changegroupinfo(repo, nodes, source): if repo.ui.verbose or source == 'bundle': @@ -929,7 +930,8 @@ def getsubset(repo, outgoing, bundler, source, fastpath=False): gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath) - return getunbundler(bundler.version, util.chunkbuffer(gengroup), None) + return getunbundler(bundler.version, util.chunkbuffer(gengroup), None, + {'clcount': len(outgoing.missing)}) def changegroupsubset(repo, roots, heads, source, version='01'): """Compute a changegroup consisting of all the nodes that are