[PATCH 1 of 9] bundle-ng: move bundler creation up in the stack
Sune Foldager
cryo at cyanite.org
Thu Feb 14 17:07:19 CST 2013
# HG changeset patch
# User Benoit Boissinot <benoit.boissinot at ens-lyon.org>
# Date 1360432342 -3600
# Node ID d78029a5c1f72e2eb75321409ad969462b7d372f
# Parent 46edbc49a9f213dd9c78e4dbaa8809661058bb07
bundle-ng: move bundler creation up in the stack
Create a simple start() method to pass the lookup function until bundler
becomes smarter and gets a repo object.
diff -r 46edbc49a9f2 -r d78029a5c1f7 contrib/shrink-revlog.py
--- a/contrib/shrink-revlog.py Sat Feb 09 16:02:01 2013 +0000
+++ b/contrib/shrink-revlog.py Sat Feb 09 18:52:22 2013 +0100
@@ -117,7 +117,8 @@
unlookup = lambda x: int(x, 10)
try:
- bundler = changegroup.bundle10(lookup)
+ bundler = changegroup.bundle10()
+ bundler.start(lookup)
group = util.chunkbuffer(r1.group(order, bundler))
group = changegroup.unbundle10(group, "UN")
r2.addgroup(group, unlookup, tr)
diff -r 46edbc49a9f2 -r d78029a5c1f7 mercurial/changegroup.py
--- a/mercurial/changegroup.py Sat Feb 09 16:02:01 2013 +0000
+++ b/mercurial/changegroup.py Sat Feb 09 18:52:22 2013 +0100
@@ -225,7 +225,9 @@
class bundle10(object):
deltaheader = _BUNDLE10_DELTA_HEADER
- def __init__(self, lookup):
+ def __init__(self):
+ pass
+ def start(self, lookup):
self._lookup = lookup
def close(self):
return closechunk()
diff -r 46edbc49a9f2 -r d78029a5c1f7 mercurial/localrepo.py
--- a/mercurial/localrepo.py Sat Feb 09 16:02:01 2013 +0000
+++ b/mercurial/localrepo.py Sat Feb 09 18:52:22 2013 +0100
@@ -1823,7 +1823,9 @@
if revs is None and not outgoing.excluded:
# push everything,
# use the fast path, no race possible on push
- cg = self._changegroup(outgoing.missing, 'push')
+ bundler = changegroup.bundle10()
+ cg = self._changegroup(outgoing.missing, bundler,
+ 'push')
else:
cg = self.getlocalbundle('push', outgoing)
@@ -1978,7 +1980,8 @@
csets, bases, heads = cl.nodesbetween(bases, heads)
# We assume that all ancestors of bases are known
common = cl.ancestors([cl.rev(n) for n in bases])
- return self._changegroupsubset(common, csets, heads, source)
+ bundler = changegroup.bundle10()
+ return self._changegroupsubset(common, csets, heads, bundler, source)
def getlocalbundle(self, source, outgoing):
"""Like getbundle, but taking a discovery.outgoing as an argument.
@@ -1987,9 +1990,11 @@
precomputed sets in outgoing."""
if not outgoing.missing:
return None
+ bundler = changegroup.bundle10()
return self._changegroupsubset(outgoing.common,
outgoing.missing,
outgoing.missingheads,
+ bundler,
source)
def getbundle(self, source, heads=None, common=None):
@@ -2013,7 +2018,7 @@
discovery.outgoing(cl, common, heads))
@unfilteredmethod
- def _changegroupsubset(self, commonrevs, csets, heads, source):
+ def _changegroupsubset(self, commonrevs, csets, heads, bundler, source):
cl = self.changelog
mf = self.manifest
@@ -2026,7 +2031,7 @@
# can we go through the fast path ?
heads.sort()
if heads == sorted(self.heads()):
- return self._changegroup(csets, source)
+ return self._changegroup(csets, bundler, source)
# slow path
self.hook('preoutgoing', throw=True, source=source)
@@ -2068,7 +2073,7 @@
unit=_files, total=count[1])
return fstate[1][x]
- bundler = changegroup.bundle10(lookup)
+ bundler.start(lookup)
reorder = self.ui.config('bundle', 'reorder', 'auto')
if reorder == 'auto':
reorder = None
@@ -2125,7 +2130,7 @@
return self.changegroupsubset(basenodes, self.heads(), source)
@unfilteredmethod
- def _changegroup(self, nodes, source):
+ def _changegroup(self, nodes, bundler, source):
"""Compute the changegroup of all nodes that we have that a recipient
doesn't. Return a chunkbuffer object whose read() method will return
successive changegroup chunks.
@@ -2176,7 +2181,7 @@
total=count[1], unit=_files)
return cl.node(revlog.linkrev(revlog.rev(x)))
- bundler = changegroup.bundle10(lookup)
+ bundler.start(lookup)
reorder = self.ui.config('bundle', 'reorder', 'auto')
if reorder == 'auto':
reorder = None
More information about the Mercurial-devel
mailing list