diff --git a/HISTORY.txt b/HISTORY.txt --- a/HISTORY.txt +++ b/HISTORY.txt @@ -1,5 +1,8 @@ +1.1.1 +~~~~~~~~~~~~~~~~~~ -~~~~~~~~~~~~~~~~~~ +#49 Fixed the bug due to url-stored usernames did not work (introduced +in 1.0.0 and not completely fixed in 1.0.1). #50 Bad doc url in error message diff --git a/mercurial_keyring.py b/mercurial_keyring.py --- a/mercurial_keyring.py +++ b/mercurial_keyring.py @@ -310,32 +310,36 @@ class HTTPPasswordHandler(object): if urllib_user and urllib_pwd: return urllib_user, urllib_pwd, self.SRC_URLCACHE, base_url + actual_user = url_user or urllib_user + # Consult configuration to normalize url to prefix, and find username # (and maybe password) auth_user, auth_pwd, keyring_url = self.get_url_config( - ui, parsed_url, url_user) - if auth_user and url_user and (url_user != auth_user): - raise util.Abort(_('keyring: username for %s specified both in repository path (%s) and in .hg/hgrc/[auth] (%s). Please, leave only one of those' % (base_url, url_user, auth_user))) + ui, parsed_url, actual_user) + if auth_user and actual_user and (actual_user != auth_user): + raise util.Abort(_('keyring: username for %s specified both in repository path (%s) and in .hg/hgrc/[auth] (%s). Please, leave only one of those' % (base_url, actual_user, auth_user))) if auth_user and auth_pwd: return auth_user, auth_pwd, self.SRC_CFGAUTH, keyring_url + actual_user = actual_user or auth_user + if skip_caches: - return auth_user, None, None, keyring_url + return actual_user, None, None, keyring_url # Check memory cache (reuse ) # Checking the memory cache (there may be many http calls per command) - cached_pwd = self.pwd_cache.check(realm, keyring_url, auth_user) + cached_pwd = self.pwd_cache.check(realm, keyring_url, actual_user) if cached_pwd: - return auth_user, cached_pwd, self.SRC_MEMCACHE, keyring_url + return actual_user, cached_pwd, self.SRC_MEMCACHE, keyring_url # Load from keyring. - if auth_user: - ui.debug(_("keyring: looking for password (user %s, url %s)\n") % (auth_user, keyring_url)) - keyring_pwd = password_store.get_http_password(keyring_url, auth_user) + if actual_user: + ui.debug(_("keyring: looking for password (user %s, url %s)\n") % (actual_user, keyring_url)) + keyring_pwd = password_store.get_http_password(keyring_url, actual_user) if keyring_pwd: - return auth_user, keyring_pwd, self.SRC_KEYRING, keyring_url + return actual_user, keyring_pwd, self.SRC_KEYRING, keyring_url - return auth_user, None, None, keyring_url + return actual_user, None, None, keyring_url @staticmethod def prompt_interactively(ui, user, realm, url):