[PATCH] changegroup: rename bundle-related functions and classes
Sune Foldager
sune.foldager at me.com
Sun Aug 31 10:13:58 UTC 2014
# HG changeset patch
# User Sune Foldager <cryo at cyanite.org>
# Date 1409477406 -7200
# Sun Aug 31 11:30:06 2014 +0200
# Node ID 2f836ecf121b2a300bda20121156f6a3de102d58
# Parent 188b8aa2120b03eead618ba150319074f4e3b42b
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 188b8aa2120b -r 2f836ecf121b mercurial/bundle2.py
--- a/mercurial/bundle2.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/bundle2.py Sun Aug 31 11:30:06 2014 +0200
@@ -796,7 +796,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.changegroupv1unpacker(inpart, 'UN')
ret = changegroup.addchangegroup(op.repo, cg, 'bundle2', 'bundle2')
op.records.add('changegroup', {'return': ret})
if op.reply is not None:
diff -r 188b8aa2120b -r 2f836ecf121b mercurial/changegroup.py
--- a/mercurial/changegroup.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/changegroup.py Sun Aug 31 11:30:06 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 changegroupv1unpacker(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 changegroupv1packer(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 changegroupv1unpacker(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 = changegroupv1packer(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 = changegroupv1packer(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 188b8aa2120b -r 2f836ecf121b mercurial/commands.py
--- a/mercurial/commands.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/commands.py Sun Aug 31 11:30:06 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 188b8aa2120b -r 2f836ecf121b mercurial/exchange.py
--- a/mercurial/exchange.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/exchange.py Sun Aug 31 11:30:06 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.changegroupv1unpacker(fh, alg)
elif version == '2X':
return bundle2.unbundle20(ui, fh, header=magic + version)
else:
@@ -383,7 +383,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"""
@@ -507,14 +507,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.changegroupv1packer(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
@@ -934,7 +934,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.
@@ -944,8 +944,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 188b8aa2120b -r 2f836ecf121b mercurial/sshserver.py
--- a/mercurial/sshserver.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/sshserver.py Sun Aug 31 11:30:06 2014 +0200
@@ -142,7 +142,7 @@
return
self.sendresponse("")
- cg = changegroup.unbundle10(self.fin, "UN")
+ cg = changegroup.changegroupv1unpacker(self.fin, "UN")
r = changegroup.addchangegroup(self.repo, cg, 'serve', self._client())
self.lock.release()
return str(r)
diff -r 188b8aa2120b -r 2f836ecf121b mercurial/wireproto.py
--- a/mercurial/wireproto.py Sat Aug 30 18:44:59 2014 +0200
+++ b/mercurial/wireproto.py Sun Aug 31 11:30:06 2014 +0200
@@ -327,7 +327,7 @@
def changegroup(self, nodes, kind):
n = encodelist(nodes)
f = self._callcompressable("changegroup", roots=n)
- return changegroupmod.unbundle10(f, 'UN')
+ return changegroupmod.changegroupv1unpacker(f, 'UN')
def changegroupsubset(self, bases, heads, kind):
self.requirecap('changegroupsubset', _('look up remote changes'))
@@ -335,7 +335,7 @@
heads = encodelist(heads)
f = self._callcompressable("changegroupsubset",
bases=bases, heads=heads)
- return changegroupmod.unbundle10(f, 'UN')
+ return changegroupmod.changegroupv1unpacker(f, 'UN')
def getbundle(self, source, **kwargs):
self.requirecap('getbundle', _('look up remote changes'))
@@ -361,7 +361,7 @@
if bundlecaps is not None and 'HG2X' in bundlecaps:
return bundle2.unbundle20(self.ui, f)
else:
- return changegroupmod.unbundle10(f, 'UN')
+ return changegroupmod.changegroupv1unpacker(f, 'UN')
def unbundle(self, cg, heads, source):
'''Send cg (a readable file-like object representing the
diff -r 188b8aa2120b -r 2f836ecf121b tests/test-bundle2.t
--- a/tests/test-bundle2.t Sat Aug 30 18:44:59 2014 +0200
+++ b/tests/test-bundle2.t Sun Aug 31 11:30:06 2014 +0200
@@ -99,7 +99,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']:
More information about the Mercurial-devel
mailing list