[PATCH 4 of 4] Add reporeqpull() hook that allows extension to request certain data
David Soria Parra
sn_ at gmx.net
Wed Aug 27 05:03:22 CDT 2008
# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1219830241 -7200
# Node ID 7959c01ab29e6ad1507ee151cc681366fd891e62
# Parent d31f144fd74c93637970e212d605c5455b8dc4f8
Add reporeqpull() hook that allows extension to request certain data
The return value of the reporeqpull() call of an extension is passed to
the repopush() method on the remote side, therefore allowing extensions to
e.g. just request some data.
diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -38,7 +38,7 @@
yield resp
def extras(repo, req):
- resp = cPickle.dumps(repo.extras()) + "\n"
+ resp = cPickle.dumps(repo.extras(req.form['args'][0])) + "\n"
req.respond(HTTP_OK, HGTYPE, length=len(resp))
yield resp
diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
--- a/mercurial/httprepo.py
+++ b/mercurial/httprepo.py
@@ -385,9 +385,9 @@
except urllib2.HTTPError:
self.ui.note(_("remote repository doesn't support transfer of user defined data\n"))
- def extras(self):
+ def extras(self, args):
try:
- return cPickle.loads(self.do_read("extras").strip())
+ return cPickle.loads(self.do_read("extras", args=args).strip())
except urllib2.HTTPError:
self.ui.note(_("remote repository doesn't support transfer of user defined data\n"))
return {}
diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1403,7 +1403,7 @@
def pull(self, remote, heads=None, force=False):
lock = self.lock()
try:
- self.addextras(remote.extras())
+ self.addextras(remote.extras(self.reqextras()))
fetch = self.findincoming(remote, heads=heads, force=force)
if fetch == [nullid]:
self.ui.status(_("requesting all changes\n"))
@@ -1427,11 +1427,18 @@
if hasattr(module, 'repopull'):
module.repopull(ui=self.ui, repo=self, extras=extras)
- def extras(self):
+ def extras(self, args):
resp = {}
for name, module in extensions.extensions():
if hasattr(module, 'repopush'):
- resp.update(module.repopush(self))
+ resp.update(module.repopush(self, args))
+ return resp
+
+ def reqextras(self):
+ resp = {}
+ for name, module in extensions.extensions():
+ if hasattr(module, 'reporeqpull'):
+ resp.update(module.reporeqpull(self))
return resp
def push(self, remote, force=False, revs=None):
@@ -1443,7 +1450,7 @@
# unbundle assumes local user cannot lock remote repo (new ssh
# servers, http servers).
- remote.addextras(self.extras())
+ remote.addextras(self.extras(None))
if remote.capable('unbundle'):
return self.push_unbundle(remote, force, revs)
return self.push_addchangegroup(remote, force, revs)
diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py
--- a/mercurial/sshrepo.py
+++ b/mercurial/sshrepo.py
@@ -250,9 +250,9 @@
except EOFError:
self.ui.note(_("remote repository doesn't support transfer of user defined data\n"))
- def extras(self):
+ def extras(self, args):
try:
- return cPickle.loads(self.call("extras"))
+ return cPickle.loads(self.call("extras", args=cPickle.dumps(args)))
except EOFError:
self.ui.note(_("remote repository doesn't support transfer of extra information\n"))
return {}
diff --git a/mercurial/sshserver.py b/mercurial/sshserver.py
--- a/mercurial/sshserver.py
+++ b/mercurial/sshserver.py
@@ -213,7 +213,9 @@
self.fout.flush()
def do_extras(self):
- self.respond(cPickle.dumps(self.repo.extras()))
+ arg, args = self.getarg()
+ assert arg == 'args'
+ self.respond(cPickle.dumps(self.repo.extras(cPickle.loads(args))))
def do_addextras(self):
arg, extras = self.getarg()
More information about the Mercurial-devel
mailing list