Show More
@@ -9,7 +9,7 b'' | |||
|
9 | 9 | from node import nullid |
|
10 | 10 | from i18n import _ |
|
11 | 11 | import changegroup, statichttprepo, error, url, util, wireproto |
|
12 |
import os, urllib, urllib2, |
|
|
12 | import os, urllib, urllib2, zlib, httplib | |
|
13 | 13 | import errno, socket |
|
14 | 14 | |
|
15 | 15 | def zgenerator(f): |
@@ -28,13 +28,13 b' class httprepository(wireproto.wirerepos' | |||
|
28 | 28 | self.path = path |
|
29 | 29 | self.caps = None |
|
30 | 30 | self.handler = None |
|
31 | scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) | |
|
32 | if query or frag: | |
|
31 | u = url.url(path) | |
|
32 | if u.query or u.fragment: | |
|
33 | 33 | raise util.Abort(_('unsupported URL component: "%s"') % |
|
34 | (query or frag)) | |
|
34 | (u.query or u.fragment)) | |
|
35 | 35 | |
|
36 | 36 | # urllib cannot handle URLs with embedded user or passwd |
|
37 |
self._url, authinfo = u |
|
|
37 | self._url, authinfo = u.authinfo() | |
|
38 | 38 | |
|
39 | 39 | self.ui = ui |
|
40 | 40 | self.ui.debug('using %s\n' % self._url) |
@@ -6,8 +6,7 b'' | |||
|
6 | 6 | # GNU General Public License version 2 or any later version. |
|
7 | 7 | |
|
8 | 8 | from i18n import _ |
|
9 | import util, error, wireproto | |
|
10 | import re | |
|
9 | import util, error, wireproto, url | |
|
11 | 10 | |
|
12 | 11 | class remotelock(object): |
|
13 | 12 | def __init__(self, repo): |
@@ -24,16 +23,16 b' class sshrepository(wireproto.wirereposi' | |||
|
24 | 23 | self._url = path |
|
25 | 24 | self.ui = ui |
|
26 | 25 | |
|
27 | m = re.match(r'^ssh://(([^@]+)@)?([^:/]+)(:(\d+))?(/(.*))?$', path) | |
|
28 | if not m: | |
|
26 | u = url.url(path, parse_query=False, parse_fragment=False) | |
|
27 | if u.scheme != 'ssh' or not u.host or u.path is None: | |
|
29 | 28 | self._abort(error.RepoError(_("couldn't parse location %s") % path)) |
|
30 | 29 | |
|
31 |
self.user = |
|
|
32 | if self.user and ':' in self.user: | |
|
30 | self.user = u.user | |
|
31 | if u.passwd is not None: | |
|
33 | 32 | self._abort(error.RepoError(_("password in URL not supported"))) |
|
34 |
self.host = |
|
|
35 |
self.port = |
|
|
36 |
self.path = |
|
|
33 | self.host = u.host | |
|
34 | self.port = u.port | |
|
35 | self.path = u.path or "." | |
|
37 | 36 | |
|
38 | 37 | sshcmd = self.ui.config("ui", "ssh", "ssh") |
|
39 | 38 | remotecmd = self.ui.config("ui", "remotecmd", "hg") |
@@ -85,7 +85,8 b' class statichttprepository(localrepo.loc' | |||
|
85 | 85 | self.ui = ui |
|
86 | 86 | |
|
87 | 87 | self.root = path |
|
88 |
|
|
|
88 | u = url.url(path.rstrip('/') + "/.hg") | |
|
89 | self.path, authinfo = u.authinfo() | |
|
89 | 90 | |
|
90 | 91 | opener = build_opener(ui, authinfo) |
|
91 | 92 | self.opener = opener(self.path) |
@@ -906,31 +906,6 b' class httpbasicauthhandler(urllib2.HTTPB' | |||
|
906 | 906 | return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed( |
|
907 | 907 | self, auth_header, host, req, headers) |
|
908 | 908 | |
|
909 | def getauthinfo(path): | |
|
910 | scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) | |
|
911 | if not urlpath: | |
|
912 | urlpath = '/' | |
|
913 | if scheme != 'file': | |
|
914 | # XXX: why are we quoting the path again with some smart | |
|
915 | # heuristic here? Anyway, it cannot be done with file:// | |
|
916 | # urls since path encoding is os/fs dependent (see | |
|
917 | # urllib.pathname2url() for details). | |
|
918 | urlpath = quotepath(urlpath) | |
|
919 | host, port, user, passwd = netlocsplit(netloc) | |
|
920 | ||
|
921 | # urllib cannot handle URLs with embedded user or passwd | |
|
922 | url = urlparse.urlunsplit((scheme, netlocunsplit(host, port), | |
|
923 | urlpath, query, frag)) | |
|
924 | if user: | |
|
925 | netloc = host | |
|
926 | if port: | |
|
927 | netloc += ':' + port | |
|
928 | # Python < 2.4.3 uses only the netloc to search for a password | |
|
929 | authinfo = (None, (url, netloc), user, passwd or '') | |
|
930 | else: | |
|
931 | authinfo = None | |
|
932 | return url, authinfo | |
|
933 | ||
|
934 | 909 | handlerfuncs = [] |
|
935 | 910 | |
|
936 | 911 | def opener(ui, authinfo=None): |
General Comments 0
You need to be logged in to leave comments.
Login now