httprepo: record the url after a request, makes pull + redirect works
authorBenoit Boissinot <benoit.boissinot@ens-lyon.org>
Fri, 27 Oct 2006 15:02:27 +0200
changeset 3562 88b4755fa48f
parent 3561 8c617d48564a
child 3563 db946221a58a
httprepo: record the url after a request, makes pull + redirect works POST+redirect doesn't work in python, as a workaround we record the url from the previous GETs so that when we do a POST it uses the redirected url fix issue327
mercurial/httprepo.py
--- a/mercurial/httprepo.py	Fri Oct 27 10:24:19 2006 +0200
+++ b/mercurial/httprepo.py	Fri Oct 27 15:02:27 2006 +0200
@@ -218,8 +218,8 @@
         self.ui.debug(_("sending %s command\n") % cmd)
         q = {"cmd": cmd}
         q.update(args)
-        qs = urllib.urlencode(q)
-        cu = "%s?%s" % (self._url, qs)
+        qs = '?%s' % urllib.urlencode(q)
+        cu = "%s%s" % (self._url, qs)
         try:
             resp = urllib2.urlopen(urllib2.Request(cu, data, headers))
         except urllib2.HTTPError, inst:
@@ -233,6 +233,8 @@
         except IndexError:
             # this only happens with Python 2.3, later versions raise URLError
             raise util.Abort(_('http error, possibly caused by proxy setting'))
+        # record the url we got redirected to
+        self._url = resp.geturl().rstrip(qs)
         try:
             proto = resp.getheader('content-type')
         except AttributeError: