comparison tests/test-bundle2-remote-changegroup.t @ 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 622782ea9cf3
children f28f2ac65c66
comparison
equal deleted inserted replaced
29806:82e8c86cdd6d 29807:d4e026341e16
6 > """A small extension to test bundle2 remote-changegroup parts. 6 > """A small extension to test bundle2 remote-changegroup parts.
7 > 7 >
8 > Current bundle2 implementation doesn't provide a way to generate those 8 > Current bundle2 implementation doesn't provide a way to generate those
9 > parts, so they must be created by extensions. 9 > parts, so they must be created by extensions.
10 > """ 10 > """
11 > from mercurial import bundle2, changegroup, exchange, util 11 > from mercurial import bundle2, changegroup, discovery, exchange, util
12 > 12 >
13 > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None, 13 > def _getbundlechangegrouppart(bundler, repo, source, bundlecaps=None,
14 > b2caps=None, heads=None, common=None, 14 > b2caps=None, heads=None, common=None,
15 > **kwargs): 15 > **kwargs):
16 > """this function replaces the changegroup part handler for getbundle. 16 > """this function replaces the changegroup part handler for getbundle.
20 > 20 >
21 > Each line of that bundle2maker file contain a description of the 21 > Each line of that bundle2maker file contain a description of the
22 > part to add: 22 > part to add:
23 > - changegroup common_revset heads_revset 23 > - changegroup common_revset heads_revset
24 > Creates a changegroup part based, using common_revset and 24 > Creates a changegroup part based, using common_revset and
25 > heads_revset for changegroup.getchangegroup. 25 > heads_revset for outgoing
26 > - remote-changegroup url file 26 > - remote-changegroup url file
27 > Creates a remote-changegroup part for a bundle at the given 27 > Creates a remote-changegroup part for a bundle at the given
28 > url. Size and digest, as required by the client, are computed 28 > url. Size and digest, as required by the client, are computed
29 > from the given file. 29 > from the given file.
30 > - raw-remote-changegroup <python expression> 30 > - raw-remote-changegroup <python expression>
61 > part.addparam(k, str(v)) 61 > part.addparam(k, str(v))
62 > elif verb == 'changegroup': 62 > elif verb == 'changegroup':
63 > _common, heads = args.split() 63 > _common, heads = args.split()
64 > common.extend(repo.lookup(r) for r in repo.revs(_common)) 64 > common.extend(repo.lookup(r) for r in repo.revs(_common))
65 > heads = [repo.lookup(r) for r in repo.revs(heads)] 65 > heads = [repo.lookup(r) for r in repo.revs(heads)]
66 > cg = changegroup.getchangegroup(repo, 'changegroup', 66 > outgoing = discovery.outgoing(repo, common, heads)
67 > heads=heads, common=common) 67 > cg = changegroup.getchangegroup(repo, 'changegroup', outgoing)
68 > newpart('changegroup', cg.getchunks()) 68 > newpart('changegroup', cg.getchunks())
69 > else: 69 > else:
70 > raise Exception('unknown verb') 70 > raise Exception('unknown verb')
71 > 71 >
72 > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart 72 > exchange.getbundle2partsmapping['changegroup'] = _getbundlechangegrouppart