Mercurial(HG)拉取参数:用户名和密码 [英] Mercurial (HG) pull parameters: username and password
问题描述
我必须编写一个脚本,以自动执行从水银回购中提取的操作.无论如何,我可以执行hg pull -u
,包括在同一命令中传递所请求的用户名和密码吗?我知道有一个交互式方法是默认行为,并且我不想将用户名和密码保存在hgrc或其他地方,因为它将被多个用户使用,因此有一种方法可以通过命令行?
我试过在PHP中使用proc_open
,但无法与STDIN呼应.
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.
推荐答案
我找到了两种解决方案:
I found two solutions:
1.明确提供URL,包括完整的凭据:
1. Explicitly provide the URL, including full credentials:
hg pull -u https://user:pass@host/path
2.用-作为配置文件的凭据,使用*作为前缀(摘自Victor的回答):
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
hg pull -u --config auth.x.prefix=* --config auth.x.username=user --config auth.x.password=pass
这篇关于Mercurial(HG)拉取参数:用户名和密码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!