# HG changeset patch # User Aurelien Campeas # Date 1567529806 -7200 # Tue Sep 03 18:56:46 2019 +0200 # Node ID 70ee390c996a95b2093449d70a295d9457db4b23 # Parent 8de310e8ec98c8f5cf422c09e1a9013cbc10b297 https+auth: use a ~/.git-credentials file if it exists to fetch credentials In some situations we code the plain auth-less uri in the hgrc paths section (for convenience) and want to use a centrally-stored credentials file. Though it is possible to use the hgrc [auth] section, it would be also nice to access .git-credentials (still usefull for git direct access), avoiding double maintenance of credentials. This probably does not cover all possible situations with git credentials handling (a vast topic) but it provides a working base. closes 305 diff --git a/hggit/git_handler.py b/hggit/git_handler.py --- a/hggit/git_handler.py +++ b/hggit/git_handler.py @@ -1742,6 +1742,15 @@ username = username.decode('latin-1') if password is not None: password = password.decode('latin-1') + if url.user is None: + username_password = client.get_credentials_from_store( + url.scheme, + url.host + ) + if username_password is not None: + username, password = username_password + username = username.decode('utf-8') + password = password.decode('utf-8') return ( client.HttpGitClient( str_uri,