mercurial/httpconnection.py
changeset 31300 0c8a042b193d
parent 31299 90e69badb125
child 31488 766364caae14
equal deleted inserted replaced
31299:90e69badb125 31300:0c8a042b193d
    65         self.close()
    65         self.close()
    66 
    66 
    67 # moved here from url.py to avoid a cycle
    67 # moved here from url.py to avoid a cycle
    68 def readauthforuri(ui, uri, user):
    68 def readauthforuri(ui, uri, user):
    69     # Read configuration
    69     # Read configuration
    70     config = {}
    70     groups = {}
    71     for key, val in ui.configitems('auth'):
    71     for key, val in ui.configitems('auth'):
    72         if '.' not in key:
    72         if '.' not in key:
    73             ui.warn(_("ignoring invalid [auth] key '%s'\n") % key)
    73             ui.warn(_("ignoring invalid [auth] key '%s'\n") % key)
    74             continue
    74             continue
    75         group, setting = key.rsplit('.', 1)
    75         group, setting = key.rsplit('.', 1)
    76         gdict = config.setdefault(group, {})
    76         gdict = groups.setdefault(group, {})
    77         if setting in ('username', 'cert', 'key'):
    77         if setting in ('username', 'cert', 'key'):
    78             val = util.expandpath(val)
    78             val = util.expandpath(val)
    79         gdict[setting] = val
    79         gdict[setting] = val
    80 
    80 
    81     # Find the best match
    81     # Find the best match
    82     scheme, hostpath = uri.split('://', 1)
    82     scheme, hostpath = uri.split('://', 1)
    83     bestuser = None
    83     bestuser = None
    84     bestlen = 0
    84     bestlen = 0
    85     bestauth = None
    85     bestauth = None
    86     for group, auth in config.iteritems():
    86     for group, auth in groups.iteritems():
    87         if user and user != auth.get('username', user):
    87         if user and user != auth.get('username', user):
    88             # If a username was set in the URI, the entry username
    88             # If a username was set in the URI, the entry username
    89             # must either match it or be unset
    89             # must either match it or be unset
    90             continue
    90             continue
    91         prefix = auth.get('prefix')
    91         prefix = auth.get('prefix')