Mercurial > hg > mercurial-crew-with-dirclash
comparison mercurial/httprepo.py @ 2447:cd00531ecc16
httprepo: make "http://user:pass@host/" urls work
author | Vadim Gelfer <vadim.gelfer@gmail.com> |
---|---|
date | Fri, 16 Jun 2006 10:19:45 -0700 |
parents | 1b2bbb2b4911 |
children | c91118f425d0 |
comparison
equal
deleted
inserted
replaced
2446:1b2bbb2b4911 | 2447:cd00531ecc16 |
---|---|
10 from i18n import gettext as _ | 10 from i18n import gettext as _ |
11 from demandload import * | 11 from demandload import * |
12 demandload(globals(), "hg os urllib urllib2 urlparse zlib util httplib") | 12 demandload(globals(), "hg os urllib urllib2 urlparse zlib util httplib") |
13 demandload(globals(), "keepalive") | 13 demandload(globals(), "keepalive") |
14 | 14 |
15 class passwordmgr(urllib2.HTTPPasswordMgr): | 15 class passwordmgr(urllib2.HTTPPasswordMgrWithDefaultRealm): |
16 def __init__(self, ui): | 16 def __init__(self, ui): |
17 urllib2.HTTPPasswordMgr.__init__(self) | 17 urllib2.HTTPPasswordMgrWithDefaultRealm.__init__(self) |
18 self.ui = ui | 18 self.ui = ui |
19 | 19 |
20 def find_user_password(self, realm, authuri): | 20 def find_user_password(self, realm, authuri): |
21 authinfo = urllib2.HTTPPasswordMgr.find_user_password( | 21 authinfo = urllib2.HTTPPasswordMgrWithDefaultRealm.find_user_password( |
22 self, realm, authuri) | 22 self, realm, authuri) |
23 if authinfo != (None, None): | 23 if authinfo != (None, None): |
24 return authinfo | 24 return authinfo |
25 | 25 |
26 if not self.ui.interactive: | 26 if not self.ui.interactive: |
131 except OSError: | 131 except OSError: |
132 pass | 132 pass |
133 | 133 |
134 passmgr = passwordmgr(ui) | 134 passmgr = passwordmgr(ui) |
135 if user: | 135 if user: |
136 ui.debug(_('will use user %s for http auth\n') % user) | 136 ui.debug(_('will use user %s, password %s for http auth\n') % |
137 (user, '*' * len(passwd))) | |
137 passmgr.add_password(None, host, user, passwd or '') | 138 passmgr.add_password(None, host, user, passwd or '') |
138 | 139 |
139 opener = urllib2.build_opener( | 140 opener = urllib2.build_opener( |
140 handler, | 141 handler, |
141 urllib2.HTTPBasicAuthHandler(passmgr), | 142 urllib2.HTTPBasicAuthHandler(passmgr), |