comparison mercurial/httprepo.py @ 13819:d16894e29f91

httprepo/sshrepo: use url.url Like the previous patch to getauthinfo(), this also makes username/password parsing more forgiving for SSH URLs. This also opens up the possibility of allowing non-numeric ports, since the URL parser has no problem handling them. Related issues: - issue851: @ in password in http url - issue2055: nonnumeric port bug with https protocol
author Brodie Rao <brodie@bitheap.org>
date Wed, 30 Mar 2011 20:01:35 -0700
parents 395a84f78736
children aaa9a5989405
comparison
equal deleted inserted replaced
13818:bf6156bab41b 13819:d16894e29f91
7 # GNU General Public License version 2 or any later version. 7 # GNU General Public License version 2 or any later version.
8 8
9 from node import nullid 9 from node import nullid
10 from i18n import _ 10 from i18n import _
11 import changegroup, statichttprepo, error, url, util, wireproto 11 import changegroup, statichttprepo, error, url, util, wireproto
12 import os, urllib, urllib2, urlparse, zlib, httplib 12 import os, urllib, urllib2, zlib, httplib
13 import errno, socket 13 import errno, socket
14 14
15 def zgenerator(f): 15 def zgenerator(f):
16 zd = zlib.decompressobj() 16 zd = zlib.decompressobj()
17 try: 17 try:
26 class httprepository(wireproto.wirerepository): 26 class httprepository(wireproto.wirerepository):
27 def __init__(self, ui, path): 27 def __init__(self, ui, path):
28 self.path = path 28 self.path = path
29 self.caps = None 29 self.caps = None
30 self.handler = None 30 self.handler = None
31 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 31 u = url.url(path)
32 if query or frag: 32 if u.query or u.fragment:
33 raise util.Abort(_('unsupported URL component: "%s"') % 33 raise util.Abort(_('unsupported URL component: "%s"') %
34 (query or frag)) 34 (u.query or u.fragment))
35 35
36 # urllib cannot handle URLs with embedded user or passwd 36 # urllib cannot handle URLs with embedded user or passwd
37 self._url, authinfo = url.getauthinfo(path) 37 self._url, authinfo = u.authinfo()
38 38
39 self.ui = ui 39 self.ui = ui
40 self.ui.debug('using %s\n' % self._url) 40 self.ui.debug('using %s\n' % self._url)
41 41
42 self.urlopener = url.opener(ui, authinfo) 42 self.urlopener = url.opener(ui, authinfo)