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