When I try to clone a https-authenticated Mercurial repository (e.g. from kiln), it asks me for my user name
C:\temp\test>hg clone https://<my-login-name>.kilnhg.com/Code/Repositories/Group/test
http authorization required
realm: kiln
user:
We want to invoke the hg clone command from our GUI application with any URL provided by the user and ask the user on demand for the user name and password, if they are required.
How can I configure Mercurial to invoke an arbitrary script which returns the user name/password, similar to scripts whose paths are defined in the environment variables GIT_ASKPASS or SSH_ASKPASS for Git?
You can configure your credentials in your user-wide
hgrc(mercurial.iniin the user profile directory, on Windows):Afterwards, the requests for this server will silently use the credentials provided in the
hgrcfile.See the docs on
hgrcfor more information.Update: After studying the TortoiseHg sources a little (the code in question being the
SyncWidget.inclickedandSyncWidget.pullclickedmethods in sync.py), I’ve found out that TortoiseHg, which does precisely what you’re trying to achieve, apparently first tries the URL for the auth request, and, if it’s been given, asks the user for the login and password, to rebuild a full URL (with credentials) and supply it tohg pull.I guess you can do the same.