phpmercurial

Mercurial (HG) pull parameters: username and password


I have to write a script that automates pulling from a mercurial repo. Is there anyway I can perform an hg pull -u that includes passing the requested username and password in the same command? I know there's an interactive method which is the default behaviour, and I don't want to save the username and password in hgrc or elsewhere because it will be used by multiple users, so is there a way to pass the username and password via the command line? I tried using proc_open in PHP but that wasn't working as well as echoing out to STDIN.


Solution

  • I found two solutions:

    1. Explicitly provide the URL, including full credentials:

    hg pull -u https://user:pass@host/path

    2. Provide the credentials with --config, using * as a prefix (from Victor's answer):

    hg pull -u --config auth.x.prefix=* --config auth.x.username=user --config auth.x.password=pass