windows hg pull 是否只对当前工作目录进行操作?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1782095/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Does hg pull only operate on the current working directory?
提问by fbuchinger
I have multiple mercurial repositories and used hg clone
to create backups of them on our file server. Now I want to write a batch file that updates them once a day by running hg pull -u
on each subdirectory.
我有多个 mercurial 存储库,用于hg clone
在我们的文件服务器上创建它们的备份。现在我想编写一个批处理文件,通过hg pull -u
在每个子目录上运行来每天更新一次。
I want to keep this backup script as generic as possible, so it should update all backup repositories stored in my H:\BACKUPS\REPOS folder. This is my hgbackup.bat that is stored in the same folder:
我想让这个备份脚本尽可能通用,所以它应该更新存储在我的 H:\BACKUPS\REPOS 文件夹中的所有备份存储库。这是我的 hgbackup.bat 存储在同一文件夹中:
for /f "delims=" %%i in ('dir /ad/b') do hg pull -u
for /f "delims=" %%i in ('dir /ad/b') do hg pull -u
The problem: hg pull only seems to operate on the current working directory, there seems to be no switch to specify the target repository for the pull. As I hate Windows Batch Scripting, I want to keep my .bat as simple as possible and avoid cd'ing to the different directories.
问题:hg pull 似乎只在当前工作目录上操作,似乎没有开关指定 pull 的目标存储库。由于我讨厌 Windows Batch Scripting,我想让我的 .bat 尽可能简单并避免 cd 到不同的目录。
Any ideas how I can run hg pull -u
on a different directory?
有什么想法可以hg pull -u
在不同的目录上运行吗?
回答by Benjamin Wohlwend
Use the -R
-switch:
使用 --R
开关:
hg pull -u -R /path/to/repository
See hg -v help pull
for all command line options of hg pull
(the -v
switch tells help to include global options).
有关hg -v help pull
所有命令行选项的信息,请参阅hg pull
(该-v
开关告诉 help 包括全局选项)。
回答by MattGWagner
Found this question quite a bit later due to a script I was working on for my own computer, and rather than a batch script, I did it in PowerShell (since you mentioned it's on a server, I assumed PS was available). This handles both Subversion and Mercurial repositories:
由于我正在为自己的计算机处理脚本,而不是批处理脚本,我在 PowerShell 中完成了这个问题(因为您提到它在服务器上,所以我假设 PS 可用),所以后来发现这个问题。这处理 Subversion 和 Mercurial 存储库:
$path = "c:\users\mattgwagner\Documents\Code"
foreach($fi in get-childitem $path)
{
if(test-path $path$fi\.svn)
{
"Updating " + $fi + " via Subversion..."
svn update $path$fi
}
elseif(test-path $path$fi\.hg)
{
"Updating " + $fi + " via Mercurial..."
hg pull -u -R $path$fi
}
}