comparison mercurial/url.py @ 11876:1fe94103c6ee

Merge with stable
author Martin Geisler <mg@lazybytes.net>
date Sat, 14 Aug 2010 03:30:35 +0200
parents d4bfa07f269f 6c51a5056020
children e3526634d5a3
comparison
equal deleted inserted replaced
11875:88f5b5c058b5 11876:1fe94103c6ee
568 arg = inst.args[0] 568 arg = inst.args[0]
569 if arg.startswith("AbstractDigestAuthHandler doesn't know "): 569 if arg.startswith("AbstractDigestAuthHandler doesn't know "):
570 return 570 return
571 raise 571 raise
572 572
573 class httpbasicauthhandler(urllib2.HTTPBasicAuthHandler):
574 def __init__(self, *args, **kwargs):
575 urllib2.HTTPBasicAuthHandler.__init__(self, *args, **kwargs)
576 self.retried_req = None
577
578 def reset_retry_count(self):
579 # Python 2.6.5 will call this on 401 or 407 errors and thus loop
580 # forever. We disable reset_retry_count completely and reset in
581 # http_error_auth_reqed instead.
582 pass
583
584 def http_error_auth_reqed(self, auth_header, host, req, headers):
585 # Reset the retry counter once for each request.
586 if req is not self.retried_req:
587 self.retried_req = req
588 self.retried = 0
589 return urllib2.HTTPBasicAuthHandler.http_error_auth_reqed(
590 self, auth_header, host, req, headers)
591
573 def getauthinfo(path): 592 def getauthinfo(path):
574 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path) 593 scheme, netloc, urlpath, query, frag = urlparse.urlsplit(path)
575 if not urlpath: 594 if not urlpath:
576 urlpath = '/' 595 urlpath = '/'
577 if scheme != 'file': 596 if scheme != 'file':
613 passmgr.add_password(*authinfo) 632 passmgr.add_password(*authinfo)
614 user, passwd = authinfo[2:4] 633 user, passwd = authinfo[2:4]
615 ui.debug('http auth: user %s, password %s\n' % 634 ui.debug('http auth: user %s, password %s\n' %
616 (user, passwd and '*' * len(passwd) or 'not set')) 635 (user, passwd and '*' * len(passwd) or 'not set'))
617 636
618 handlers.extend((urllib2.HTTPBasicAuthHandler(passmgr), 637 handlers.extend((httpbasicauthhandler(passmgr),
619 httpdigestauthhandler(passmgr))) 638 httpdigestauthhandler(passmgr)))
620 handlers.extend([h(ui, passmgr) for h in handlerfuncs]) 639 handlers.extend([h(ui, passmgr) for h in handlerfuncs])
621 opener = urllib2.build_opener(*handlers) 640 opener = urllib2.build_opener(*handlers)
622 641
623 # 1.0 here is the _protocol_ version 642 # 1.0 here is the _protocol_ version