[PATCH 2 of 4] Add extras/addextras transfer support to HTTP repositories

David Soria Parra sn_ at gmx.net
Fri Aug 29 14:29:47 CDT 2008


Matt Nordhoff wrote:
> This might be a stupid question, but is that an ugly diff, or did the
> last two lines of the function at the top get removed?

you are right, it should be this (the last patchset still applies clean, 
just with a hunk offset in the last patch):

# HG changeset patch
# User David Soria Parra <sn_ at gmx.net>
# Date 1220038001 -7200
# Node ID 24560daa7855acbe937bdc82262378af17d2a421
# Parent  e3df3f1b318590888a879f4f0f3647e5ca881a3b
Add extras/addextras transfer support to HTTP repositories

diff -r e3df3f1b3185 -r 24560daa7855 mercurial/hgweb/protocol.py
--- a/mercurial/hgweb/protocol.py	Fri Aug 29 21:22:59 2008 +0200
+++ b/mercurial/hgweb/protocol.py	Fri Aug 29 21:26:41 2008 +0200
@@ -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,9 +17,21 @@
  __all__ = [
     'lookup', 'heads', 'branches', 'between', 'changegroup',
     'changegroupsubset', 'capabilities', 'unbundle', 'stream_out',
+   'extras', 'addextras'
  ]

  HGTYPE = 'application/mercurial-0.1'
+
+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

  def lookup(repo, req):
      try:
diff -r e3df3f1b3185 -r 24560daa7855 mercurial/httprepo.py
--- a/mercurial/httprepo.py	Fri Aug 29 21:22:59 2008 +0200
+++ b/mercurial/httprepo.py	Fri Aug 29 21:26:41 2008 +0200
@@ -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