# HG changeset patch # User Marcin Kasperski # Date 2015-11-21 08:28:01 # Node ID ae4c2c2b6a10af6cf7736c8233e7e94bf2c59780 # Parent 47735e331ed26e1eb63fc838488580d335e49888 In case username (and maybe password) is present in url, they are removed from it before prefix matching. This resolves unclear situation with respect to .prefix-es. Currently (as far as mercurial_keyring is considered), prefixes (in .hgrc) should always be defined without username (albeit I am considering handling both) diff --git a/mercurial_keyring.py b/mercurial_keyring.py --- a/mercurial_keyring.py +++ b/mercurial_keyring.py @@ -320,7 +320,7 @@ class HTTPPasswordHandler(object): base_url, url_user, url_passwd = self.unpack_url(authuri) ui.debug(_('keyring: base url: %s, url user: %s, url pwd: %s\n') % (base_url, url_user or '', url_passwd and '******' or '')) - + # Extract username (or password) stored directly in url if url_user and url_passwd: return url_user, url_passwd, self.SRC_URL, base_url @@ -492,14 +492,15 @@ class HTTPPasswordHandler(object): @staticmethod def unpack_url(authuri): """ - Does two things: + Takes original url for which authentication is attempted and: - 1. Strips query params from url. Used to convert urls like - https://repo.machine.com/repos/apps/module?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between - to - https://repo.machine.com/repos/apps/module + - Strips query params from url. Used to convert urls like + https://repo.machine.com/repos/apps/module?pairs=0000000000000000000000000000000000000000-0000000000000000000000000000000000000000&cmd=between + to + https://repo.machine.com/repos/apps/module - 2. Extracts username and password, if present. + - Extracts username and password, if present, and removes them from url + (so prefix matching works properly) Returns url, user, password """ @@ -510,8 +511,12 @@ class HTTPPasswordHandler(object): # Strip arguments to get actual remote repository url. # base_url = "%s://%s%s" % (parsed_url.scheme, parsed_url.netloc, # parsed_url.path) + user = parsed_url.user + passwd = parsed_url.passwd + parsed_url.user = None + parsed_url.passwd = None - return str(parsed_url), parsed_url.user, parsed_url.passwd + return str(parsed_url), user, passwd ############################################################