# HG changeset patch # User Sune Foldager # Date 1409652696 -7200 # Node ID e2806b8613cae110276280c0151a6775949fd7d6 # Parent 94f77624dbb58d57feab825ea3e9fab4626d9540 changegroup: rename bundle-related functions and classes Functions like getbundle and classes like unbundle10 really manipulate changegroups and not bundles. A HG10 bundle is the same as a changegroup plus a small header, but this is no longer the case for a HG2X bundle, so it's better to separate the names a bit. diff -r 94f77624dbb5 -r e2806b8613ca mercurial/bundle2.py --- a/mercurial/bundle2.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/bundle2.py Tue Sep 02 12:11:36 2014 +0200 @@ -820,7 +820,7 @@ # 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 -r 94f77624dbb5 -r e2806b8613ca mercurial/changegroup.py --- a/mercurial/changegroup.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/changegroup.py Tue Sep 02 12:11:36 2014 +0200 @@ -12,7 +12,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r 94f77624dbb5 -r e2806b8613ca mercurial/commands.py --- a/mercurial/commands.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/commands.py Tue Sep 02 12:11:36 2014 +0200 @@ -1159,8 +1159,8 @@ "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 @@ 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 -r 94f77624dbb5 -r e2806b8613ca mercurial/exchange.py --- a/mercurial/exchange.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/exchange.py Tue Sep 02 12:11:36 2014 +0200 @@ -31,7 +31,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 -r 94f77624dbb5 -r e2806b8613ca mercurial/sshserver.py --- a/mercurial/sshserver.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/sshserver.py Tue Sep 02 12:11:36 2014 +0200 @@ -142,7 +142,7 @@ 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 -r 94f77624dbb5 -r e2806b8613ca mercurial/wireproto.py --- a/mercurial/wireproto.py Tue Aug 19 01:13:10 2014 +0200 +++ b/mercurial/wireproto.py Tue Sep 02 12:11:36 2014 +0200 @@ -328,7 +328,7 @@ 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 @@ 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 @@ 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 -r 94f77624dbb5 -r e2806b8613ca tests/test-bundle2.t --- a/tests/test-bundle2.t Tue Aug 19 01:13:10 2014 +0200 +++ b/tests/test-bundle2.t Tue Sep 02 12:11:36 2014 +0200 @@ -106,7 +106,7 @@ > 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']: