Commits

Brodie Rao committed d5ed341

Adding post-pushkey patch

Comments (0)

Files changed (2)

+# HG changeset patch
+# Parent 158ca54a79cce2439c9f66a95d174d993f9ebc4b
+wireproto: fix pushkey not being sent via POST over HTTP
+
+diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py
+--- a/mercurial/httprepo.py
++++ b/mercurial/httprepo.py
+@@ -157,8 +157,11 @@ class httprepository(wireproto.wirerepos
+                     type = x
+                     break
+ 
+-        tempname = changegroup.writebundle(cg, None, type)
+-        fp = url.httpsendfile(tempname, "rb")
++        if cg is not None:
++            tempname = changegroup.writebundle(cg, None, type)
++            fp = url.httpsendfile(tempname, "rb")
++        else:
++            fp = ''
+         headers = {'Content-Type': 'application/mercurial-0.1'}
+ 
+         try:
+@@ -170,8 +173,9 @@ class httprepository(wireproto.wirerepos
+                     raise util.Abort(_('push failed: %s') % err.args[1])
+                 raise util.Abort(err.args[1])
+         finally:
+-            fp.close()
+-            os.unlink(tempname)
++            if cg is not None:
++                fp.close()
++                os.unlink(tempname)
+ 
+     def _abort(self, exception):
+         raise exception
+diff --git a/mercurial/sshrepo.py b/mercurial/sshrepo.py
+--- a/mercurial/sshrepo.py
++++ b/mercurial/sshrepo.py
+@@ -129,8 +129,8 @@ class sshrepository(wireproto.wirereposi
+ 
+     def _callpush(self, cmd, fp, **args):
+         r = self._call(cmd, **args)
+-        if r:
+-            return '', r
++        if r or fp is None:
++            return r.split('\n')
+         while 1:
+             d = fp.read(4096)
+             if not d:
+@@ -139,7 +139,7 @@ class sshrepository(wireproto.wirereposi
+         self._send("", flush=True)
+         r = self._recv()
+         if r:
+-            return '', r
++            return r.split('\n')
+         return self._recv(), ''
+ 
+     def _decompress(self, stream):
+diff --git a/mercurial/wireproto.py b/mercurial/wireproto.py
+--- a/mercurial/wireproto.py
++++ b/mercurial/wireproto.py
+@@ -82,9 +82,9 @@ class wirerepository(repo.repository):
+     def pushkey(self, namespace, key, old, new):
+         if not self.capable('pushkey'):
+             return False
+-        d = self._call("pushkey",
+-                      namespace=namespace, key=key, old=old, new=new)
+-        return bool(int(d))
++        d = self._callpush("pushkey", None, # force a POST
++                           namespace=namespace, key=key, old=old, new=new)
++        return bool(int(d[0]))
+ 
+     def listkeys(self, namespace):
+         if not self.capable('pushkey'):
+post-pushkey
 hgplain-i18n
 mq-opt-fuckery #+mq-opt-fuckery
 localdate-config #+localdate-config