Search code examples
mercurial

How can I pass my remote username and password directly into hg outgoing?


I have a repository where I want to undo all local commits on my branch since the most recent commit pulled down. I do not want to save any work.

After doing some research I found the following on SuperUser:

hg --config "extensions.strip = " strip "roots(outgoing())"

Note that I have added --config "extensions.strip = " because I do not have the strip extension enabled.

After executing this command it then appears to already know my remote username (which is not in my mercurial.ini) and prompts for my remote password - this then appears to function exactly as I want it to.

My question is how does it know my username already if it is not stored in my mercurial.ini? And more importantly how can I pass both my username and password directly into my command so I could give a different username and have it also not prompt me for the password?

Thanks!


Solution

  • Can you check the repo's .hg/hgrc to confirm if it doesn't have any credential? If you have cloned using your username (eg: http://username:password@ip:port/reponame), it will stay in the repo's config.

    You can create a new named path in .hg/hgrc and pass it to "roots(outgoing(newpath))". That will do what you are expecting.