Powershell Mercurial:Windows脚本自动添加子存储库

Powershell Mercurial:Windows脚本自动添加子存储库,powershell,mercurial,batch-file,subrepos,mercurial-subrepos,Powershell,Mercurial,Batch File,Subrepos,Mercurial Subrepos,已在发布了一个脚本,可以使用以下命令自动添加子存储库: $ cd $TOP_OF_HG_PROJECT $ addsubrepo.sh $URL_TO_HG_PROJECT relative_path/you/want_to/put_the_subrepo 如何将其翻译成Windows批处理或powershell脚本?这里是一个快速而肮脏的翻译。我没有测试过,因为我周围没有水银。最初的脚本似乎很容易翻译成Powershell # Project and relative paths as sc

已在发布了一个脚本,可以使用以下命令自动添加子存储库:

$ cd $TOP_OF_HG_PROJECT
$ addsubrepo.sh $URL_TO_HG_PROJECT relative_path/you/want_to/put_the_subrepo

如何将其翻译成Windows批处理或powershell脚本?

这里是一个快速而肮脏的翻译。我没有测试过,因为我周围没有水银。最初的脚本似乎很容易翻译成Powershell

# Project and relative paths as script parameters
param([string]$project, [string]$relPath)

# Let's see if there is an item .hg. If not, report error and quit
if((test-path ".hg") -eq $false ) {
   "You MUST run this at the top of your directory structure and use relative paths"
    return
}

# Call Mercury
& hg clone $project $relPath

# Add data to .hgsub using composite formatting string
add-content -path ".hgsub" -value $("{0} = {1}" -f $relPath, $project)

# Check that .hgsub exists and issue Mercury commands if it does
if(test-path ".hgsub") {
    hg add .hgsub
    hg commit
} else {
    "failure, see error messages above"
}

谢谢你的代码!不过我有个错误。我需要将
if(测试路径“.hg”-eq$false)
替换为
if((测试路径“.hg”)-eq$false)