[PATCH 10 of 15] Supports pull from httprepo. Pull works as below
Pradeepkumar Gayam
in3xes at gmail.com
Mon Jul 12 05:49:52 CDT 2010
# HG changeset patch
# User Pradeepkumar Gayam <in3xes at gmail.com>
# Date 1278880556 -19800
# Branch stable
# Node ID 80e7ed5acc92171cc21c8d0bbced5c486ff5b0b0
# Parent 3c91a6fb7298312cea1f0cc0190393a6ad20a3cd
Supports pull from httprepo. Pull works as below
+--------------------------------------+
| | ld Client | New Client |
+------------+------------+------------+
| Old Server | Linear | Linear [2] |
+------------+------------+------------+
| New Server | Linear [1] | Parent |
+--------------------------------------+
[1] Server sends linear delta irrespective of the repo.
[2] Client adds linear deltas to the repository irrespective of client repo.
diff -r 3c91a6fb7298 -r 80e7ed5acc92 mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py Mon Jul 12 01:40:03 2010 +0530
+++ b/mercurial/hgweb/protocol.py Mon Jul 12 02:05:56 2010 +0530
@@ -21,7 +21,7 @@
]
HGTYPE = 'application/mercurial-0.1'
-basecaps = 'lookup changegroupsubset branchmap pushkey'.split()
+basecaps = 'lookup changegroupsubset branchmap pushkey parentdelta'.split()
def lookup(repo, req):
try:
@@ -75,8 +75,9 @@
if 'roots' in req.form:
nodes = map(bin, req.form['roots'][0].split(" "))
+ pdelta = 'parentdelta' in req.form
z = zlib.compressobj()
- f = repo.changegroup(nodes, 'serve')
+ f = repo.changegroup(nodes, 'serve', pdelta)
while 1:
chunk = f.read(4096)
if not chunk:
@@ -95,8 +96,9 @@
if 'heads' in req.form:
heads = [bin(x) for x in req.form['heads'][0].split(' ')]
+ pdelta = 'parentdelta' in req.form
z = zlib.compressobj()
- f = repo.changegroupsubset(bases, heads, 'serve')
+ f = repo.changegroupsubset(bases, heads, 'serve', pdelta=pdelta)
while 1:
chunk = f.read(4096)
if not chunk:
diff -r 3c91a6fb7298 -r 80e7ed5acc92 mercurial/httprepo.py
--- a/mercurial/httprepo.py Mon Jul 12 01:40:03 2010 +0530
+++ b/mercurial/httprepo.py Mon Jul 12 02:05:56 2010 +0530
@@ -195,16 +195,23 @@
raise error.ResponseError(_("unexpected response:"), d)
return r
- def changegroup(self, nodes, kind):
+ def changegroup(self, nodes, kind, pdelta=False):
n = " ".join(map(hex, nodes))
- f = self.do_cmd("changegroup", roots=n)
+ if pdelta:
+ f = self.do_cmd("changegroup", roots=n, parentdelta="parentdelta")
+ else:
+ f = self.do_cmd("changegroup", roots=n)
return util.chunkbuffer(zgenerator(f))
- def changegroupsubset(self, bases, heads, source):
+ def changegroupsubset(self, bases, heads, source, pdelta=False):
self.requirecap('changegroupsubset', _('look up remote changes'))
baselst = " ".join([hex(n) for n in bases])
headlst = " ".join([hex(n) for n in heads])
- f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst)
+ if pdelta:
+ f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst,
+ parentdelta="parentdelta")
+ else:
+ f = self.do_cmd("changegroupsubset", bases=baselst, heads=headlst)
return util.chunkbuffer(zgenerator(f))
def unbundle(self, cg, heads, source):
diff -r 3c91a6fb7298 -r 80e7ed5acc92 mercurial/localrepo.py
--- a/mercurial/localrepo.py Mon Jul 12 01:40:03 2010 +0530
+++ b/mercurial/localrepo.py Mon Jul 12 02:05:56 2010 +0530
@@ -1185,6 +1185,7 @@
tmp = discovery.findcommonincoming(self, remote, heads=heads,
force=force)
common, fetch, rheads = tmp
+ pdelta = remote.capable('parentdelta')
if not fetch:
self.ui.status(_("no changes found\n"))
return 0
@@ -1196,14 +1197,15 @@
heads = rheads
if heads is None:
- cg = remote.changegroup(fetch, 'pull')
+ cg = remote.changegroup(fetch, 'pull', pdelta)
else:
if not remote.capable('changegroupsubset'):
raise util.Abort(_("Partial pull cannot be done because "
"other repository doesn't support "
"changegroupsubset."))
cg = remote.changegroupsubset(fetch, heads, 'pull')
- return self.addchangegroup(cg, 'pull', remote.url(), lock=lock)
+ return self.addchangegroup(cg, 'pull', remote.url(), lock=lock,
+ pdelta=pdelta)
finally:
lock.release()
More information about the Mercurial-devel
mailing list