[PATCH 2 of 4] Add extras/addextras transfer support to HTTP repositories
David Soria Parra
sn_ at gmx.net
Wed Aug 27 05:03:20 CDT 2008
# HG changeset patch
# User David Soria Parra <dsp at php.net>
# Date 1219830241 -7200
# Node ID 3253bef923ab49b535362d36b5f979b955481f4e
# Parent ecb23d75d99dbcbfd9495ba7aeccc6376b528f57
Add extras/addextras transfer support to HTTP repositories
diff --git a/mercurial/hgweb/protocol.py b/mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py
+++ b/mercurial/hgweb/protocol.py
@@ -5,8 +5,8 @@
# This software may be used and distributed according to the terms
# of the GNU General Public License, incorporated herein by reference.
-import cStringIO, zlib, tempfile, errno, os, sys
-from mercurial import util, streamclone
+import cStringIO, zlib, tempfile, errno, os, sys, cPickle
+from mercurial import util, streamclone, extensions
from mercurial.node import bin, hex
from mercurial import changegroup as changegroupmod
from common import HTTP_OK, HTTP_NOT_FOUND, HTTP_SERVER_ERROR
@@ -17,6 +17,7 @@
__all__ = [
'lookup', 'heads', 'branches', 'between', 'changegroup',
'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
+ 'extras', 'addextras'
]
HGTYPE = 'application/mercurial-0.1'
@@ -29,6 +30,15 @@
r = str(inst)
success = 0
resp = "%s %s\n" % (success, r)
+
+def addextras(repo, req):
+ repo.addextras(req.form['extras'][0])
+ resp = "1"
+ req.respond(HTTP_OK, HGTYPE, length=len(resp))
+ yield resp
+
+def extras(repo, req):
+ resp = cPickle.dumps(repo.extras()) + "\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
@@ -8,7 +8,7 @@
from node import bin, hex
from i18n import _
-import repo, os, urllib, urllib2, urlparse, zlib, util, httplib
+import repo, os, urllib, urllib2, urlparse, zlib, util, httplib, cPickle
import errno, keepalive, socket, changegroup
class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm):
@@ -379,6 +379,19 @@
except:
raise util.UnexpectedOutput(_("unexpected response:"), d)
+ def addextras(self, extras):
+ try:
+ self.do_read("addextras", extras=extras)
+ except urllib2.HTTPError:
+ self.ui.note(_("remote repository doesn't support transfer of user defined data\n"))
+
+ def extras(self):
+ try:
+ return cPickle.loads(self.do_read("extras").strip())
+ except urllib2.HTTPError:
+ self.ui.note(_("remote repository doesn't support transfer of user defined data\n"))
+ return {}
+
def between(self, pairs):
n = "\n".join(["-".join(map(hex, p)) for p in pairs])
d = self.do_read("between", pairs=n)
More information about the Mercurial-devel
mailing list