Show More
@@ -1240,7 +1240,7 def getrepocaps(repo, allowpushback=Fals | |||||
1240 | Exists to allow extensions (like evolution) to mutate the capabilities. |
|
1240 | Exists to allow extensions (like evolution) to mutate the capabilities. | |
1241 | """ |
|
1241 | """ | |
1242 | caps = capabilities.copy() |
|
1242 | caps = capabilities.copy() | |
1243 |
caps['changegroup'] = tuple(sorted(changegroup. |
|
1243 | caps['changegroup'] = tuple(sorted(changegroup.supportedversions(repo))) | |
1244 | if obsolete.isenabled(repo, obsolete.exchangeopt): |
|
1244 | if obsolete.isenabled(repo, obsolete.exchangeopt): | |
1245 | supportedformat = tuple('V%i' % v for v in obsolete.formats) |
|
1245 | supportedformat = tuple('V%i' % v for v in obsolete.formats) | |
1246 | caps['obsmarkers'] = supportedformat |
|
1246 | caps['obsmarkers'] = supportedformat | |
@@ -1277,8 +1277,7 def handlechangegroup(op, inpart): | |||||
1277 | op.gettransaction() |
|
1277 | op.gettransaction() | |
1278 | unpackerversion = inpart.params.get('version', '01') |
|
1278 | unpackerversion = inpart.params.get('version', '01') | |
1279 | # We should raise an appropriate exception here |
|
1279 | # We should raise an appropriate exception here | |
1280 |
|
|
1280 | cg = changegroup.getunbundler(unpackerversion, inpart, None) | |
1281 | cg = unpacker(inpart, None) |
|
|||
1282 | # the source and url passed here are overwritten by the one contained in |
|
1281 | # the source and url passed here are overwritten by the one contained in | |
1283 | # the transaction.hookargs argument. So 'bundle2' is a placeholder |
|
1282 | # the transaction.hookargs argument. So 'bundle2' is a placeholder | |
1284 | nbchangesets = None |
|
1283 | nbchangesets = None |
@@ -285,7 +285,7 class bundlerepository(localrepo.localre | |||||
285 | "multiple changegroups") |
|
285 | "multiple changegroups") | |
286 | cgstream = part |
|
286 | cgstream = part | |
287 | version = part.params.get('version', '01') |
|
287 | version = part.params.get('version', '01') | |
288 |
if version not in changegroup. |
|
288 | if version not in changegroup.supportedversions(self): | |
289 | msg = _('Unsupported changegroup version: %s') |
|
289 | msg = _('Unsupported changegroup version: %s') | |
290 | raise error.Abort(msg % version) |
|
290 | raise error.Abort(msg % version) | |
291 | if self.bundle.compressed(): |
|
291 | if self.bundle.compressed(): | |
@@ -296,7 +296,7 class bundlerepository(localrepo.localre | |||||
296 | raise error.Abort('No changegroups found') |
|
296 | raise error.Abort('No changegroups found') | |
297 | cgstream.seek(0) |
|
297 | cgstream.seek(0) | |
298 |
|
298 | |||
299 |
self.bundle = changegroup. |
|
299 | self.bundle = changegroup.getunbundler(version, cgstream, 'UN') | |
300 |
|
300 | |||
301 | elif self.bundle.compressed(): |
|
301 | elif self.bundle.compressed(): | |
302 | f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN') |
|
302 | f = _writetempbundle(self.bundle.read, '.hg10un', header='HG10UN') |
@@ -914,13 +914,23 class cg3packer(cg2packer): | |||||
914 | return struct.pack( |
|
914 | return struct.pack( | |
915 | self.deltaheader, node, p1n, p2n, basenode, linknode, flags) |
|
915 | self.deltaheader, node, p1n, p2n, basenode, linknode, flags) | |
916 |
|
916 | |||
917 | packermap = {'01': (cg1packer, cg1unpacker), |
|
917 | _packermap = {'01': (cg1packer, cg1unpacker), | |
918 | # cg2 adds support for exchanging generaldelta |
|
918 | # cg2 adds support for exchanging generaldelta | |
919 | '02': (cg2packer, cg2unpacker), |
|
919 | '02': (cg2packer, cg2unpacker), | |
920 | # cg3 adds support for exchanging treemanifests |
|
920 | # cg3 adds support for exchanging treemanifests | |
921 | '03': (cg3packer, cg3unpacker), |
|
921 | '03': (cg3packer, cg3unpacker), | |
922 | } |
|
922 | } | |
923 |
|
923 | |||
|
924 | def supportedversions(repo): | |||
|
925 | return _packermap.keys() | |||
|
926 | ||||
|
927 | def getbundler(version, repo, bundlecaps=None): | |||
|
928 | assert version in supportedversions(repo) | |||
|
929 | return _packermap[version][0](repo, bundlecaps) | |||
|
930 | ||||
|
931 | def getunbundler(version, fh, alg): | |||
|
932 | return _packermap[version][1](fh, alg) | |||
|
933 | ||||
924 | def _changegroupinfo(repo, nodes, source): |
|
934 | def _changegroupinfo(repo, nodes, source): | |
925 | if repo.ui.verbose or source == 'bundle': |
|
935 | if repo.ui.verbose or source == 'bundle': | |
926 | repo.ui.status(_("%d changesets found\n") % len(nodes)) |
|
936 | repo.ui.status(_("%d changesets found\n") % len(nodes)) | |
@@ -947,7 +957,7 def getsubsetraw(repo, outgoing, bundler | |||||
947 |
|
957 | |||
948 | def getsubset(repo, outgoing, bundler, source, fastpath=False): |
|
958 | def getsubset(repo, outgoing, bundler, source, fastpath=False): | |
949 | gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath) |
|
959 | gengroup = getsubsetraw(repo, outgoing, bundler, source, fastpath) | |
950 |
return |
|
960 | return getunbundler(bundler.version, util.chunkbuffer(gengroup), None) | |
951 |
|
961 | |||
952 | def changegroupsubset(repo, roots, heads, source, version='01'): |
|
962 | def changegroupsubset(repo, roots, heads, source, version='01'): | |
953 | """Compute a changegroup consisting of all the nodes that are |
|
963 | """Compute a changegroup consisting of all the nodes that are | |
@@ -973,7 +983,7 def changegroupsubset(repo, roots, heads | |||||
973 | included = set(csets) |
|
983 | included = set(csets) | |
974 | discbases = [n for n in discbases if n not in included] |
|
984 | discbases = [n for n in discbases if n not in included] | |
975 | outgoing = discovery.outgoing(cl, discbases, heads) |
|
985 | outgoing = discovery.outgoing(cl, discbases, heads) | |
976 |
bundler = |
|
986 | bundler = getbundler(version, repo) | |
977 | return getsubset(repo, outgoing, bundler, source) |
|
987 | return getsubset(repo, outgoing, bundler, source) | |
978 |
|
988 | |||
979 | def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None, |
|
989 | def getlocalchangegroupraw(repo, source, outgoing, bundlecaps=None, | |
@@ -984,7 +994,7 def getlocalchangegroupraw(repo, source, | |||||
984 | precomputed sets in outgoing. Returns a raw changegroup generator.""" |
|
994 | precomputed sets in outgoing. Returns a raw changegroup generator.""" | |
985 | if not outgoing.missing: |
|
995 | if not outgoing.missing: | |
986 | return None |
|
996 | return None | |
987 |
bundler = |
|
997 | bundler = getbundler(version, repo, bundlecaps) | |
988 | return getsubsetraw(repo, outgoing, bundler, source) |
|
998 | return getsubsetraw(repo, outgoing, bundler, source) | |
989 |
|
999 | |||
990 | def getlocalchangegroup(repo, source, outgoing, bundlecaps=None, |
|
1000 | def getlocalchangegroup(repo, source, outgoing, bundlecaps=None, | |
@@ -995,7 +1005,7 def getlocalchangegroup(repo, source, ou | |||||
995 | precomputed sets in outgoing.""" |
|
1005 | precomputed sets in outgoing.""" | |
996 | if not outgoing.missing: |
|
1006 | if not outgoing.missing: | |
997 | return None |
|
1007 | return None | |
998 |
bundler = |
|
1008 | bundler = getbundler(version, repo, bundlecaps) | |
999 | return getsubset(repo, outgoing, bundler, source) |
|
1009 | return getsubset(repo, outgoing, bundler, source) | |
1000 |
|
1010 | |||
1001 | def computeoutgoing(repo, heads, common): |
|
1011 | def computeoutgoing(repo, heads, common): |
@@ -2078,7 +2078,7 def _debugbundle2(ui, gen, **opts): | |||||
2078 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) |
|
2078 | ui.write('%s -- %r\n' % (part.type, repr(part.params))) | |
2079 | if part.type == 'changegroup': |
|
2079 | if part.type == 'changegroup': | |
2080 | version = part.params.get('version', '01') |
|
2080 | version = part.params.get('version', '01') | |
2081 |
cg = changegroup. |
|
2081 | cg = changegroup.getunbundler(version, part, 'UN') | |
2082 | chunkdata = cg.changelogheader() |
|
2082 | chunkdata = cg.changelogheader() | |
2083 | chain = None |
|
2083 | chain = None | |
2084 | while True: |
|
2084 | while True: |
@@ -653,7 +653,8 def _pushb2ctx(pushop, bundler): | |||||
653 | cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push', |
|
653 | cg = changegroup.getlocalchangegroupraw(pushop.repo, 'push', | |
654 | pushop.outgoing) |
|
654 | pushop.outgoing) | |
655 | else: |
|
655 | else: | |
656 |
cgversions = [v for v in cgversions |
|
656 | cgversions = [v for v in cgversions | |
|
657 | if v in changegroup.supportedversions(pushop.repo)] | |||
657 | if not cgversions: |
|
658 | if not cgversions: | |
658 | raise ValueError(_('no common changegroup version')) |
|
659 | raise ValueError(_('no common changegroup version')) | |
659 | version = max(cgversions) |
|
660 | version = max(cgversions) | |
@@ -1505,7 +1506,8 def _getbundlechangegrouppart(bundler, r | |||||
1505 | cgversions = b2caps.get('changegroup') |
|
1506 | cgversions = b2caps.get('changegroup') | |
1506 | getcgkwargs = {} |
|
1507 | getcgkwargs = {} | |
1507 | if cgversions: # 3.1 and 3.2 ship with an empty value |
|
1508 | if cgversions: # 3.1 and 3.2 ship with an empty value | |
1508 |
cgversions = [v for v in cgversions |
|
1509 | cgversions = [v for v in cgversions | |
|
1510 | if v in changegroup.supportedversions(repo)] | |||
1509 | if not cgversions: |
|
1511 | if not cgversions: | |
1510 | raise ValueError(_('no common changegroup version')) |
|
1512 | raise ValueError(_('no common changegroup version')) | |
1511 | version = getcgkwargs['version'] = max(cgversions) |
|
1513 | version = getcgkwargs['version'] = max(cgversions) |
General Comments 0
You need to be logged in to leave comments.
Login now