Show More
@@ -820,7 +820,7 def handlechangegroup(op, inpart): | |||
|
820 | 820 | # we need to make sure we trigger the creation of a transaction object used |
|
821 | 821 | # for the whole processing scope. |
|
822 | 822 | op.gettransaction() |
|
823 |
cg = changegroup. |
|
|
823 | cg = changegroup.cg1unpacker(inpart, 'UN') | |
|
824 | 824 | ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') |
|
825 | 825 | op.records.add('changegroup', {'return': ret}) |
|
826 | 826 | if op.reply is not None: |
@@ -12,7 +12,7 import mdiff, util, dagutil | |||
|
12 | 12 | import struct, os, bz2, zlib, tempfile |
|
13 | 13 | import discovery, error, phases, branchmap |
|
14 | 14 | |
|
15 |
_ |
|
|
15 | _CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s" | |
|
16 | 16 | |
|
17 | 17 | def readexactly(stream, n): |
|
18 | 18 | '''read n bytes from stream.read and abort if less was available''' |
@@ -123,8 +123,8 def decompressor(fh, alg): | |||
|
123 | 123 | raise util.Abort("unknown bundle compression '%s'" % alg) |
|
124 | 124 | return util.chunkbuffer(generator(fh)) |
|
125 | 125 | |
|
126 |
class |
|
|
127 |
deltaheader = _ |
|
|
126 | class cg1unpacker(object): | |
|
127 | deltaheader = _CHANGEGROUPV1_DELTA_HEADER | |
|
128 | 128 | deltaheadersize = struct.calcsize(deltaheader) |
|
129 | 129 | def __init__(self, fh, alg): |
|
130 | 130 | self._stream = decompressor(fh, alg) |
@@ -227,8 +227,8 class headerlessfixup(object): | |||
|
227 | 227 | return d |
|
228 | 228 | return readexactly(self._fh, n) |
|
229 | 229 | |
|
230 |
class |
|
|
231 |
deltaheader = _ |
|
|
230 | class cg1packer(object): | |
|
231 | deltaheader = _CHANGEGROUPV1_DELTA_HEADER | |
|
232 | 232 | def __init__(self, repo, bundlecaps=None): |
|
233 | 233 | """Given a source repo, construct a bundler. |
|
234 | 234 | |
@@ -456,7 +456,7 def getsubset(repo, outgoing, bundler, s | |||
|
456 | 456 | repo.hook('preoutgoing', throw=True, source=source) |
|
457 | 457 | _changegroupinfo(repo, csets, source) |
|
458 | 458 | gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) |
|
459 |
return |
|
|
459 | return cg1unpacker(util.chunkbuffer(gengroup), 'UN') | |
|
460 | 460 | |
|
461 | 461 | def changegroupsubset(repo, roots, heads, source): |
|
462 | 462 | """Compute a changegroup consisting of all the nodes that are |
@@ -480,17 +480,17 def changegroupsubset(repo, roots, heads | |||
|
480 | 480 | for n in roots: |
|
481 | 481 | discbases.extend([p for p in cl.parents(n) if p != nullid]) |
|
482 | 482 | outgoing = discovery.outgoing(cl, discbases, heads) |
|
483 |
bundler = |
|
|
483 | bundler = cg1packer(repo) | |
|
484 | 484 | return getsubset(repo, outgoing, bundler, source) |
|
485 | 485 | |
|
486 |
def getlocal |
|
|
486 | def getlocalchangegroup(repo, source, outgoing, bundlecaps=None): | |
|
487 | 487 | """Like getbundle, but taking a discovery.outgoing as an argument. |
|
488 | 488 | |
|
489 | 489 | This is only implemented for local repos and reuses potentially |
|
490 | 490 | precomputed sets in outgoing.""" |
|
491 | 491 | if not outgoing.missing: |
|
492 | 492 | return None |
|
493 |
bundler = |
|
|
493 | bundler = cg1packer(repo, bundlecaps) | |
|
494 | 494 | return getsubset(repo, outgoing, bundler, source) |
|
495 | 495 | |
|
496 | 496 | def _computeoutgoing(repo, heads, common): |
@@ -512,7 +512,7 def _computeoutgoing(repo, heads, common | |||
|
512 | 512 | heads = cl.heads() |
|
513 | 513 | return discovery.outgoing(cl, common, heads) |
|
514 | 514 | |
|
515 |
def get |
|
|
515 | def getchangegroup(repo, source, heads=None, common=None, bundlecaps=None): | |
|
516 | 516 | """Like changegroupsubset, but returns the set difference between the |
|
517 | 517 | ancestors of heads and the ancestors common. |
|
518 | 518 | |
@@ -522,7 +522,7 def getbundle(repo, source, heads=None, | |||
|
522 | 522 | current discovery protocol works. |
|
523 | 523 | """ |
|
524 | 524 | outgoing = _computeoutgoing(repo, heads, common) |
|
525 |
return getlocal |
|
|
525 | return getlocalchangegroup(repo, source, outgoing, bundlecaps=bundlecaps) | |
|
526 | 526 | |
|
527 | 527 | def changegroup(repo, basenodes, source): |
|
528 | 528 | # to avoid a race we use changegroupsubset() (issue1320) |
@@ -1159,8 +1159,8 def bundle(ui, repo, fname, dest=None, * | |||
|
1159 | 1159 | "a destination")) |
|
1160 | 1160 | common = [repo.lookup(rev) for rev in base] |
|
1161 | 1161 | heads = revs and map(repo.lookup, revs) or revs |
|
1162 |
cg = changegroup.get |
|
|
1163 | bundlecaps=bundlecaps) | |
|
1162 | cg = changegroup.getchangegroup(repo, 'bundle', heads=heads, | |
|
1163 | common=common, bundlecaps=bundlecaps) | |
|
1164 | 1164 | outgoing = None |
|
1165 | 1165 | else: |
|
1166 | 1166 | dest = ui.expandpath(dest or 'default-push', dest or 'default') |
@@ -1172,7 +1172,8 def bundle(ui, repo, fname, dest=None, * | |||
|
1172 | 1172 | onlyheads=heads, |
|
1173 | 1173 | force=opts.get('force'), |
|
1174 | 1174 | portable=True) |
|
1175 |
cg = changegroup.getlocal |
|
|
1175 | cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, | |
|
1176 | bundlecaps) | |
|
1176 | 1177 | if not cg: |
|
1177 | 1178 | scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) |
|
1178 | 1179 | return 1 |
@@ -31,7 +31,7 def readbundle(ui, fh, fname, vfs=None): | |||
|
31 | 31 | if version == '10': |
|
32 | 32 | if alg is None: |
|
33 | 33 | alg = changegroup.readexactly(fh, 2) |
|
34 |
return changegroup. |
|
|
34 | return changegroup.cg1unpacker(fh, alg) | |
|
35 | 35 | elif version == '2X': |
|
36 | 36 | return bundle2.unbundle20(ui, fh, header=magic + version) |
|
37 | 37 | else: |
@@ -401,7 +401,7 def _pushb2ctx(pushop, bundler): | |||
|
401 | 401 | pushop.outgoing) |
|
402 | 402 | if not pushop.force: |
|
403 | 403 | bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads)) |
|
404 |
cg = changegroup.getlocal |
|
|
404 | cg = changegroup.getlocalchangegroup(pushop.repo, 'push', pushop.outgoing) | |
|
405 | 405 | cgpart = bundler.newpart('B2X:CHANGEGROUP', data=cg.getchunks()) |
|
406 | 406 | def handlereply(op): |
|
407 | 407 | """extract addchangroup returns from server reply""" |
@@ -536,14 +536,14 def _pushchangeset(pushop): | |||
|
536 | 536 | or pushop.repo.changelog.filteredrevs): |
|
537 | 537 | # push everything, |
|
538 | 538 | # use the fast path, no race possible on push |
|
539 |
bundler = changegroup. |
|
|
539 | bundler = changegroup.cg1packer(pushop.repo, bundlecaps) | |
|
540 | 540 | cg = changegroup.getsubset(pushop.repo, |
|
541 | 541 | outgoing, |
|
542 | 542 | bundler, |
|
543 | 543 | 'push', |
|
544 | 544 | fastpath=True) |
|
545 | 545 | else: |
|
546 |
cg = changegroup.getlocal |
|
|
546 | cg = changegroup.getlocalchangegroup(pushop.repo, 'push', outgoing, | |
|
547 | 547 | bundlecaps) |
|
548 | 548 | |
|
549 | 549 | # apply changegroup to remote |
@@ -969,7 +969,7 def getbundle(repo, source, heads=None, | |||
|
969 | 969 | passed. For now, the bundle can contain only changegroup, but this will |
|
970 | 970 | changes when more part type will be available for bundle2. |
|
971 | 971 | |
|
972 |
This is different from changegroup.get |
|
|
972 | This is different from changegroup.getchangegroup that only returns an HG10 | |
|
973 | 973 | changegroup bundle. They may eventually get reunited in the future when we |
|
974 | 974 | have a clearer idea of the API we what to query different data. |
|
975 | 975 | |
@@ -979,7 +979,7 def getbundle(repo, source, heads=None, | |||
|
979 | 979 | cg = None |
|
980 | 980 | if kwargs.get('cg', True): |
|
981 | 981 | # build changegroup bundle here. |
|
982 |
cg = changegroup.get |
|
|
982 | cg = changegroup.getchangegroup(repo, source, heads=heads, | |
|
983 | 983 | common=common, bundlecaps=bundlecaps) |
|
984 | 984 | elif 'HG2X' not in bundlecaps: |
|
985 | 985 | raise ValueError(_('request for bundle10 must include changegroup')) |
@@ -142,7 +142,7 class sshserver(wireproto.abstractserver | |||
|
142 | 142 | return |
|
143 | 143 | |
|
144 | 144 | self.sendresponse("") |
|
145 |
cg = changegroup. |
|
|
145 | cg = changegroup.cg1unpacker(self.fin, "UN") | |
|
146 | 146 | r = changegroup.addchangegroup(self.repo, cg, 'serve', self._client()) |
|
147 | 147 | self.lock.release() |
|
148 | 148 | return str(r) |
@@ -328,7 +328,7 class wirepeer(peer.peerrepository): | |||
|
328 | 328 | def changegroup(self, nodes, kind): |
|
329 | 329 | n = encodelist(nodes) |
|
330 | 330 | f = self._callcompressable("changegroup", roots=n) |
|
331 |
return changegroupmod. |
|
|
331 | return changegroupmod.cg1unpacker(f, 'UN') | |
|
332 | 332 | |
|
333 | 333 | def changegroupsubset(self, bases, heads, kind): |
|
334 | 334 | self.requirecap('changegroupsubset', _('look up remote changes')) |
@@ -336,7 +336,7 class wirepeer(peer.peerrepository): | |||
|
336 | 336 | heads = encodelist(heads) |
|
337 | 337 | f = self._callcompressable("changegroupsubset", |
|
338 | 338 | bases=bases, heads=heads) |
|
339 |
return changegroupmod. |
|
|
339 | return changegroupmod.cg1unpacker(f, 'UN') | |
|
340 | 340 | |
|
341 | 341 | def getbundle(self, source, **kwargs): |
|
342 | 342 | self.requirecap('getbundle', _('look up remote changes')) |
@@ -362,7 +362,7 class wirepeer(peer.peerrepository): | |||
|
362 | 362 | if bundlecaps is not None and 'HG2X' in bundlecaps: |
|
363 | 363 | return bundle2.unbundle20(self.ui, f) |
|
364 | 364 | else: |
|
365 |
return changegroupmod. |
|
|
365 | return changegroupmod.cg1unpacker(f, 'UN') | |
|
366 | 366 | |
|
367 | 367 | def unbundle(self, cg, heads, source): |
|
368 | 368 | '''Send cg (a readable file-like object representing the |
@@ -106,7 +106,7 Create an extension to test bundle2 API | |||
|
106 | 106 | > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)] |
|
107 | 107 | > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)] |
|
108 | 108 | > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing) |
|
109 |
> cg = changegroup.getlocal |
|
|
109 | > cg = changegroup.getlocalchangegroup(repo, 'test:bundle2', outgoing, None) | |
|
110 | 110 | > bundler.newpart('b2x:changegroup', data=cg.getchunks()) |
|
111 | 111 | > |
|
112 | 112 | > if opts['parts']: |
General Comments 0
You need to be logged in to leave comments.
Login now