# HG changeset patch # User Benoit Boissinot # Date 1161954147 -7200 # Node ID 88b4755fa48f7e6778ead0ca8452e2fe60fa3dc4 # Parent 8c617d48564a595efd15f486597210d25e0b3e32 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 diff --git a/mercurial/httprepo.py b/mercurial/httprepo.py --- a/mercurial/httprepo.py +++ b/mercurial/httprepo.py @@ -218,8 +218,8 @@ class httprepository(remoterepository): 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 @@ class httprepository(remoterepository): 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: