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