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