本文介绍了水银:Windows脚本自动添加subrepository的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

已经张贴在一个脚本here,可以使用下面的命令来自动添加subrepository:

RyanWilcox had posted a script at here, that can use the following command to add subrepository automatically:

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

如何把它翻译成Windows批处理或PowerShell脚本?

How to translate it into Windows batch or powershell script?

推荐答案

下面是一个快速和肮脏的翻译。没有测试,因为我没有得到周围汞。最初的剧本似乎是很容易转化为PowerShell的。

Here is a quick and dirty translation. Haven't tested as I got no Mercury around. The initial script seems to be easy enough to translate into 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"
}

这篇关于水银:Windows脚本自动添加subrepository的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-16 12:19