diff --git a/mercurial/bundle2.py b/mercurial/bundle2.py --- a/mercurial/bundle2.py +++ b/mercurial/bundle2.py @@ -820,7 +820,7 @@ def handlechangegroup(op, inpart): # we need to make sure we trigger the creation of a transaction object used # for the whole processing scope. op.gettransaction() - cg = changegroup.unbundle10(inpart, 'UN') + cg = changegroup.cg1unpacker(inpart, 'UN') ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2') op.records.add('changegroup', {'return': ret}) if op.reply is not None: diff --git a/mercurial/changegroup.py b/mercurial/changegroup.py --- a/mercurial/changegroup.py +++ b/mercurial/changegroup.py @@ -12,7 +12,7 @@ import mdiff, util, dagutil import struct, os, bz2, zlib, tempfile import discovery, error, phases, branchmap -_BUNDLE10_DELTA_HEADER = "20s20s20s20s" +_CHANGEGROUPV1_DELTA_HEADER = "20s20s20s20s" def readexactly(stream, n): '''read n bytes from stream.read and abort if less was available''' @@ -123,8 +123,8 @@ def decompressor(fh, alg): raise util.Abort("unknown bundle compression '%s'" % alg) return util.chunkbuffer(generator(fh)) -class unbundle10(object): - deltaheader = _BUNDLE10_DELTA_HEADER +class cg1unpacker(object): + deltaheader = _CHANGEGROUPV1_DELTA_HEADER deltaheadersize = struct.calcsize(deltaheader) def __init__(self, fh, alg): self._stream = decompressor(fh, alg) @@ -227,8 +227,8 @@ class headerlessfixup(object): return d return readexactly(self._fh, n) -class bundle10(object): - deltaheader = _BUNDLE10_DELTA_HEADER +class cg1packer(object): + deltaheader = _CHANGEGROUPV1_DELTA_HEADER def __init__(self, repo, bundlecaps=None): """Given a source repo, construct a bundler. @@ -456,7 +456,7 @@ def getsubset(repo, outgoing, bundler, s repo.hook('preoutgoing', throw=True, source=source) _changegroupinfo(repo, csets, source) gengroup = bundler.generate(commonrevs, csets, fastpathlinkrev, source) - return unbundle10(util.chunkbuffer(gengroup), 'UN') + return cg1unpacker(util.chunkbuffer(gengroup), 'UN') def changegroupsubset(repo, roots, heads, source): """Compute a changegroup consisting of all the nodes that are @@ -480,17 +480,17 @@ def changegroupsubset(repo, roots, heads for n in roots: discbases.extend([p for p in cl.parents(n) if p != nullid]) outgoing = discovery.outgoing(cl, discbases, heads) - bundler = bundle10(repo) + bundler = cg1packer(repo) return getsubset(repo, outgoing, bundler, source) -def getlocalbundle(repo, source, outgoing, bundlecaps=None): +def getlocalchangegroup(repo, source, outgoing, bundlecaps=None): """Like getbundle, but taking a discovery.outgoing as an argument. This is only implemented for local repos and reuses potentially precomputed sets in outgoing.""" if not outgoing.missing: return None - bundler = bundle10(repo, bundlecaps) + bundler = cg1packer(repo, bundlecaps) return getsubset(repo, outgoing, bundler, source) def _computeoutgoing(repo, heads, common): @@ -512,7 +512,7 @@ def _computeoutgoing(repo, heads, common heads = cl.heads() return discovery.outgoing(cl, common, heads) -def getbundle(repo, source, heads=None, common=None, bundlecaps=None): +def getchangegroup(repo, source, heads=None, common=None, bundlecaps=None): """Like changegroupsubset, but returns the set difference between the ancestors of heads and the ancestors common. @@ -522,7 +522,7 @@ def getbundle(repo, source, heads=None, current discovery protocol works. """ outgoing = _computeoutgoing(repo, heads, common) - return getlocalbundle(repo, source, outgoing, bundlecaps=bundlecaps) + return getlocalchangegroup(repo, source, outgoing, bundlecaps=bundlecaps) def changegroup(repo, basenodes, source): # to avoid a race we use changegroupsubset() (issue1320) diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -1159,8 +1159,8 @@ def bundle(ui, repo, fname, dest=None, * "a destination")) common = [repo.lookup(rev) for rev in base] heads = revs and map(repo.lookup, revs) or revs - cg = changegroup.getbundle(repo, 'bundle', heads=heads, common=common, - bundlecaps=bundlecaps) + cg = changegroup.getchangegroup(repo, 'bundle', heads=heads, + common=common, bundlecaps=bundlecaps) outgoing = None else: dest = ui.expandpath(dest or 'default-push', dest or 'default') @@ -1172,7 +1172,8 @@ def bundle(ui, repo, fname, dest=None, * onlyheads=heads, force=opts.get('force'), portable=True) - cg = changegroup.getlocalbundle(repo, 'bundle', outgoing, bundlecaps) + cg = changegroup.getlocalchangegroup(repo, 'bundle', outgoing, + bundlecaps) if not cg: scmutil.nochangesfound(ui, repo, outgoing and outgoing.excluded) return 1 diff --git a/mercurial/exchange.py b/mercurial/exchange.py --- a/mercurial/exchange.py +++ b/mercurial/exchange.py @@ -31,7 +31,7 @@ def readbundle(ui, fh, fname, vfs=None): if version == '10': if alg is None: alg = changegroup.readexactly(fh, 2) - return changegroup.unbundle10(fh, alg) + return changegroup.cg1unpacker(fh, alg) elif version == '2X': return bundle2.unbundle20(ui, fh, header=magic + version) else: @@ -401,7 +401,7 @@ def _pushb2ctx(pushop, bundler): pushop.outgoing) if not pushop.force: bundler.newpart('B2X:CHECK:HEADS', data=iter(pushop.remoteheads)) - cg = changegroup.getlocalbundle(pushop.repo, 'push', pushop.outgoing) + cg = changegroup.getlocalchangegroup(pushop.repo, 'push', pushop.outgoing) cgpart = bundler.newpart('B2X:CHANGEGROUP', data=cg.getchunks()) def handlereply(op): """extract addchangroup returns from server reply""" @@ -536,14 +536,14 @@ def _pushchangeset(pushop): or pushop.repo.changelog.filteredrevs): # push everything, # use the fast path, no race possible on push - bundler = changegroup.bundle10(pushop.repo, bundlecaps) + bundler = changegroup.cg1packer(pushop.repo, bundlecaps) cg = changegroup.getsubset(pushop.repo, outgoing, bundler, 'push', fastpath=True) else: - cg = changegroup.getlocalbundle(pushop.repo, 'push', outgoing, + cg = changegroup.getlocalchangegroup(pushop.repo, 'push', outgoing, bundlecaps) # apply changegroup to remote @@ -969,7 +969,7 @@ def getbundle(repo, source, heads=None, passed. For now, the bundle can contain only changegroup, but this will changes when more part type will be available for bundle2. - This is different from changegroup.getbundle that only returns an HG10 + This is different from changegroup.getchangegroup that only returns an HG10 changegroup bundle. They may eventually get reunited in the future when we have a clearer idea of the API we what to query different data. @@ -979,8 +979,8 @@ def getbundle(repo, source, heads=None, cg = None if kwargs.get('cg', True): # build changegroup bundle here. - cg = changegroup.getbundle(repo, source, heads=heads, - common=common, bundlecaps=bundlecaps) + cg = changegroup.getchangegroup(repo, source, heads=heads, + common=common, bundlecaps=bundlecaps) elif 'HG2X' not in bundlecaps: raise ValueError(_('request for bundle10 must include changegroup')) if bundlecaps is None or 'HG2X' not in bundlecaps: diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py --- a/mercurial/sshserver.py +++ b/mercurial/sshserver.py @@ -142,7 +142,7 @@ class sshserver(wireproto.abstractserver return self.sendresponse("") - cg = changegroup.unbundle10(self.fin, "UN") + cg = changegroup.cg1unpacker(self.fin, "UN") r = changegroup.addchangegroup(self.repo, cg, 'serve', self._client()) self.lock.release() return str(r) diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py --- a/mercurial/wireproto.py +++ b/mercurial/wireproto.py @@ -328,7 +328,7 @@ class wirepeer(peer.peerrepository): def changegroup(self, nodes, kind): n = encodelist(nodes) f = self._callcompressable("changegroup", roots=n) - return changegroupmod.unbundle10(f, 'UN') + return changegroupmod.cg1unpacker(f, 'UN') def changegroupsubset(self, bases, heads, kind): self.requirecap('changegroupsubset', _('look up remote changes')) @@ -336,7 +336,7 @@ class wirepeer(peer.peerrepository): heads = encodelist(heads) f = self._callcompressable("changegroupsubset", bases=bases, heads=heads) - return changegroupmod.unbundle10(f, 'UN') + return changegroupmod.cg1unpacker(f, 'UN') def getbundle(self, source, **kwargs): self.requirecap('getbundle', _('look up remote changes')) @@ -362,7 +362,7 @@ class wirepeer(peer.peerrepository): if bundlecaps is not None and 'HG2X' in bundlecaps: return bundle2.unbundle20(self.ui, f) else: - return changegroupmod.unbundle10(f, 'UN') + return changegroupmod.cg1unpacker(f, 'UN') def unbundle(self, cg, heads, source): '''Send cg (a readable file-like object representing the diff --git a/tests/test-bundle2.t b/tests/test-bundle2.t --- a/tests/test-bundle2.t +++ b/tests/test-bundle2.t @@ -106,7 +106,7 @@ Create an extension to test bundle2 API > headmissing = [c.node() for c in repo.set('heads(%ld)', revs)] > headcommon = [c.node() for c in repo.set('parents(%ld) - %ld', revs, revs)] > outgoing = discovery.outgoing(repo.changelog, headcommon, headmissing) - > cg = changegroup.getlocalbundle(repo, 'test:bundle2', outgoing, None) + > cg = changegroup.getlocalchangegroup(repo, 'test:bundle2', outgoing, None) > bundler.newpart('b2x:changegroup', data=cg.getchunks()) > > if opts['parts']: