Mercurial > hg
changeset 29807:d4e026341e16
getchangegroup: take an 'outgoing' object as argument (API)
There is various version of this function that differ mostly by the way they
define the bundled set. The flexibility is now available in the outgoing object
itself so we move the complexity into the caller themself. This will allow use
to remove a good share of the similar function to obtains a changegroup in the
'changegroup.py' module.
An important side effect is that we stop calling 'computeoutgoing' in
'getchangegroup'. This is fine as code that needs such argument processing
is actually going through the 'exchange' module which already all this function
itself.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 09 Aug 2016 17:00:38 +0200 |
parents | 82e8c86cdd6d |
children | 8d226db31f20 |
files | mercurial/changegroup.py mercurial/commands.py mercurial/exchange.py tests/test-bundle2-multiple-changegroups.t tests/test-bundle2-remote-changegroup.t |
diffstat | 5 files changed, 19 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/changegroup.py Tue Aug 09 22:31:38 2016 +0200 +++ b/mercurial/changegroup.py Tue Aug 09 17:00:38 2016 +0200 @@ -987,7 +987,7 @@ heads = cl.heads() return discovery.outgoing(repo, common, heads) -def getchangegroup(repo, source, heads=None, common=None, bundlecaps=None, +def getchangegroup(repo, source, outgoing, bundlecaps=None, version='01'): """Like changegroupsubset, but returns the set difference between the ancestors of heads and the ancestors common. @@ -997,7 +997,6 @@ The nodes in common might not all be known locally due to the way the current discovery protocol works. """ - outgoing = computeoutgoing(repo, heads, common) return getlocalchangegroup(repo, source, outgoing, bundlecaps=bundlecaps, version=version)
--- a/mercurial/commands.py Tue Aug 09 22:31:38 2016 +0200 +++ b/mercurial/commands.py Tue Aug 09 17:00:38 2016 +0200 @@ -1412,9 +1412,10 @@ "a destination")) common = [repo.lookup(rev) for rev in base] heads = revs and map(repo.lookup, revs) or revs - cg = changegroup.getchangegroup(repo, 'bundle', heads=heads, - common=common, bundlecaps=bundlecaps, - version=cgversion) + outgoing = discovery.outgoing(repo, common, heads) + cg = changegroup.getchangegroup(repo, 'bundle', outgoing, + bundlecaps=bundlecaps, + version=cgversion) outgoing = None else: dest = ui.expandpath(dest or 'default-push', dest or 'default')
--- a/mercurial/exchange.py Tue Aug 09 22:31:38 2016 +0200 +++ b/mercurial/exchange.py Tue Aug 09 17:00:38 2016 +0200 @@ -1536,8 +1536,9 @@ if kwargs: raise ValueError(_('unsupported getbundle arguments: %s') % ', '.join(sorted(kwargs.keys()))) - return changegroup.getchangegroup(repo, source, heads=heads, - common=common, bundlecaps=bundlecaps) + outgoing = changegroup.computeoutgoing(repo, heads, common) + return changegroup.getchangegroup(repo, source, outgoing, + bundlecaps=bundlecaps) # bundle20 case b2caps = {}
--- a/tests/test-bundle2-multiple-changegroups.t Tue Aug 09 22:31:38 2016 +0200 +++ b/tests/test-bundle2-multiple-changegroups.t Tue Aug 09 17:00:38 2016 +0200 @@ -3,7 +3,7 @@ $ cat > bundle2.py <<EOF > """ > """ - > from mercurial import changegroup, exchange + > from mercurial import changegroup, discovery, exchange > > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, > b2caps=None, heads=None, common=None, @@ -12,13 +12,14 @@ > # changegroup part we are being requested. Use the parent of each head > # in 'heads' as intermediate heads for the first changegroup. > intermediates = [repo[r].p1().node() for r in heads] - > cg = changegroup.getchangegroup(repo, source, heads=intermediates, - > common=common, bundlecaps=bundlecaps) + > outgoing = discovery.outgoing(repo, common, intermediates) + > cg = changegroup.getchangegroup(repo, source, outgoing, + > bundlecaps=bundlecaps) > bundler.newpart('output', data='changegroup1') > bundler.newpart('changegroup', data=cg.getchunks()) - > cg = changegroup.getchangegroup(repo, source, heads=heads, - > common=common + intermediates, - > bundlecaps=bundlecaps) + > outgoing = discovery.outgoing(repo, common + intermediates, heads) + > cg = changegroup.getchangegroup(repo, source, outgoing, + > bundlecaps=bundlecaps) > bundler.newpart('output', data='changegroup2') > bundler.newpart('changegroup', data=cg.getchunks()) >
--- a/tests/test-bundle2-remote-changegroup.t Tue Aug 09 22:31:38 2016 +0200 +++ b/tests/test-bundle2-remote-changegroup.t Tue Aug 09 17:00:38 2016 +0200 @@ -8,7 +8,7 @@ > Current bundle2 implementation doesn't provide a way to generate those > parts, so they must be created by extensions. > """ - > from mercurial import bundle2, changegroup, exchange, util + > from mercurial import bundle2, changegroup, discovery, exchange, util > > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, > b2caps=None, heads=None, common=None, @@ -22,7 +22,7 @@ > part to add: > - changegroup common_revset heads_revset > Creates a changegroup part based, using common_revset and - > heads_revset for changegroup.getchangegroup. + > heads_revset for outgoing > - remote-changegroup url file > Creates a remote-changegroup part for a bundle at the given > url. Size and digest, as required by the client, are computed @@ -63,8 +63,8 @@ > _common, heads = args.split() > common.extend(repo.lookup(r) for r in repo.revs(_common)) > heads = [repo.lookup(r) for r in repo.revs(heads)] - > cg = changegroup.getchangegroup(repo, 'changegroup', - > heads=heads, common=common) + > outgoing = discovery.outgoing(repo, common, heads) + > cg = changegroup.getchangegroup(repo, 'changegroup', outgoing) > newpart('changegroup', cg.getchunks()) > else: > raise Exception('unknown verb')