Show More
@@ -494,9 +494,18 b' class headerlessfixup(object):' | |||
|
494 | 494 | class cg1packer(object): |
|
495 | 495 | deltaheader = _CHANGEGROUPV1_DELTA_HEADER |
|
496 | 496 | version = '01' |
|
497 | def __init__(self, repo): | |
|
497 | def __init__(self, repo, bundlecaps=None): | |
|
498 | 498 | """Given a source repo, construct a bundler. |
|
499 | ||
|
500 | bundlecaps is optional and can be used to specify the set of | |
|
501 | capabilities which can be used to build the bundle. While bundlecaps is | |
|
502 | unused in core Mercurial, extensions rely on this feature to communicate | |
|
503 | capabilities to customize the changegroup packer. | |
|
499 | 504 | """ |
|
505 | # Set of capabilities we can use to build the bundle. | |
|
506 | if bundlecaps is None: | |
|
507 | bundlecaps = set() | |
|
508 | self._bundlecaps = bundlecaps | |
|
500 | 509 | # experimental config: bundle.reorder |
|
501 | 510 | reorder = repo.ui.config('bundle', 'reorder', 'auto') |
|
502 | 511 | if reorder == 'auto': |
@@ -800,8 +809,8 b' class cg2packer(cg1packer):' | |||
|
800 | 809 | version = '02' |
|
801 | 810 | deltaheader = _CHANGEGROUPV2_DELTA_HEADER |
|
802 | 811 | |
|
803 | def __init__(self, repo): | |
|
804 | super(cg2packer, self).__init__(repo) | |
|
812 | def __init__(self, repo, bundlecaps=None): | |
|
813 | super(cg2packer, self).__init__(repo, bundlecaps) | |
|
805 | 814 | if self._reorder is None: |
|
806 | 815 | # Since generaldelta is directly supported by cg2, reordering |
|
807 | 816 | # generally doesn't help, so we disable it by default (treating |
@@ -895,9 +904,9 b' def safeversion(repo):' | |||
|
895 | 904 | assert versions |
|
896 | 905 | return min(versions) |
|
897 | 906 | |
|
898 | def getbundler(version, repo): | |
|
907 | def getbundler(version, repo, bundlecaps=None): | |
|
899 | 908 | assert version in supportedoutgoingversions(repo) |
|
900 | return _packermap[version][0](repo) | |
|
909 | return _packermap[version][0](repo, bundlecaps) | |
|
901 | 910 | |
|
902 | 911 | def getunbundler(version, fh, alg, extras=None): |
|
903 | 912 | return _packermap[version][1](fh, alg, extras=extras) |
@@ -948,24 +957,26 b' def changegroupsubset(repo, roots, heads' | |||
|
948 | 957 | bundler = getbundler(version, repo) |
|
949 | 958 | return getsubset(repo, outgoing, bundler, source) |
|
950 | 959 | |
|
951 |
def getlocalchangegroupraw(repo, source, outgoing, |
|
|
960 | def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None, | |
|
961 | version='01'): | |
|
952 | 962 | """Like getbundle, but taking a discovery.outgoing as an argument. |
|
953 | 963 | |
|
954 | 964 | This is only implemented for local repos and reuses potentially |
|
955 | 965 | precomputed sets in outgoing. Returns a raw changegroup generator.""" |
|
956 | 966 | if not outgoing.missing: |
|
957 | 967 | return None |
|
958 | bundler = getbundler(version, repo) | |
|
968 | bundler = getbundler(version, repo, bundlecaps) | |
|
959 | 969 | return getsubsetraw(repo, outgoing, bundler, source) |
|
960 | 970 | |
|
961 |
def getchangegroup(repo, source, outgoing, |
|
|
971 | def getchangegroup(repo, source, outgoing, bundlecaps=None, | |
|
972 | version='01'): | |
|
962 | 973 | """Like getbundle, but taking a discovery.outgoing as an argument. |
|
963 | 974 | |
|
964 | 975 | This is only implemented for local repos and reuses potentially |
|
965 | 976 | precomputed sets in outgoing.""" |
|
966 | 977 | if not outgoing.missing: |
|
967 | 978 | return None |
|
968 | bundler = getbundler(version, repo) | |
|
979 | bundler = getbundler(version, repo, bundlecaps) | |
|
969 | 980 | return getsubset(repo, outgoing, bundler, source) |
|
970 | 981 | |
|
971 | 982 | def getlocalchangegroup(repo, *args, **kwargs): |
@@ -936,19 +936,22 b' def _pushchangeset(pushop):' | |||
|
936 | 936 | pushop.repo.prepushoutgoinghooks(pushop) |
|
937 | 937 | outgoing = pushop.outgoing |
|
938 | 938 | unbundle = pushop.remote.capable('unbundle') |
|
939 | # TODO: get bundlecaps from remote | |
|
940 | bundlecaps = None | |
|
939 | 941 | # create a changegroup from local |
|
940 | 942 | if pushop.revs is None and not (outgoing.excluded |
|
941 | 943 | or pushop.repo.changelog.filteredrevs): |
|
942 | 944 | # push everything, |
|
943 | 945 | # use the fast path, no race possible on push |
|
944 | bundler = changegroup.cg1packer(pushop.repo) | |
|
946 | bundler = changegroup.cg1packer(pushop.repo, bundlecaps) | |
|
945 | 947 | cg = changegroup.getsubset(pushop.repo, |
|
946 | 948 | outgoing, |
|
947 | 949 | bundler, |
|
948 | 950 | 'push', |
|
949 | 951 | fastpath=True) |
|
950 | 952 | else: |
|
951 |
cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing |
|
|
953 | cg = changegroup.getchangegroup(pushop.repo, 'push', outgoing, | |
|
954 | bundlecaps=bundlecaps) | |
|
952 | 955 | |
|
953 | 956 | # apply changegroup to remote |
|
954 | 957 | if unbundle: |
@@ -1575,7 +1578,7 b' def getbundlechunks(repo, source, heads=' | |||
|
1575 | 1578 | raise ValueError(_('unsupported getbundle arguments: %s') |
|
1576 | 1579 | % ', '.join(sorted(kwargs.keys()))) |
|
1577 | 1580 | outgoing = _computeoutgoing(repo, heads, common) |
|
1578 | bundler = changegroup.getbundler('01', repo) | |
|
1581 | bundler = changegroup.getbundler('01', repo, bundlecaps) | |
|
1579 | 1582 | return changegroup.getsubsetraw(repo, outgoing, bundler, source) |
|
1580 | 1583 | |
|
1581 | 1584 | # bundle20 case |
@@ -1613,6 +1616,7 b' def _getbundlechangegrouppart(bundler, r' | |||
|
1613 | 1616 | version = max(cgversions) |
|
1614 | 1617 | outgoing = _computeoutgoing(repo, heads, common) |
|
1615 | 1618 | cg = changegroup.getlocalchangegroupraw(repo, source, outgoing, |
|
1619 | bundlecaps=bundlecaps, | |
|
1616 | 1620 | version=version) |
|
1617 | 1621 | |
|
1618 | 1622 | if cg: |
@@ -113,7 +113,7 b' Create an extension to test bundle2 API' | |||
|
113 | 113 | > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)] |
|
114 | 114 | > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)] |
|
115 | 115 | > outgoing = discovery.outgoing(repo, headcommon, headmissing) |
|
116 | > cg = changegroup.getchangegroup(repo, 'test:bundle2', outgoing) | |
|
116 | > cg = changegroup.getchangegroup(repo, 'test:bundle2', outgoing, None) | |
|
117 | 117 | > bundler.newpart('changegroup', data=cg.getchunks(), |
|
118 | 118 | > mandatory=False) |
|
119 | 119 | > |
@@ -13,11 +13,13 b' Create an extension to test bundle2 with' | |||
|
13 | 13 | > # in 'heads' as intermediate heads for the first changegroup. |
|
14 | 14 | > intermediates = [repo[r].p1().node() for r in heads] |
|
15 | 15 | > outgoing = discovery.outgoing(repo, common, intermediates) |
|
16 |
> cg = changegroup.getchangegroup(repo, source, outgoing |
|
|
16 | > cg = changegroup.getchangegroup(repo, source, outgoing, | |
|
17 | > bundlecaps=bundlecaps) | |
|
17 | 18 | > bundler.newpart('output', data='changegroup1') |
|
18 | 19 | > bundler.newpart('changegroup', data=cg.getchunks()) |
|
19 | 20 | > outgoing = discovery.outgoing(repo, common + intermediates, heads) |
|
20 |
> cg = changegroup.getchangegroup(repo, source, outgoing |
|
|
21 | > cg = changegroup.getchangegroup(repo, source, outgoing, | |
|
22 | > bundlecaps=bundlecaps) | |
|
21 | 23 | > bundler.newpart('output', data='changegroup2') |
|
22 | 24 | > bundler.newpart('changegroup', data=cg.getchunks()) |
|
23 | 25 | > |
General Comments 0
You need to be logged in to leave comments.
Login now