开发者

Mercurial: Tag the current revision with a name that is defined in a text file

开发者 https://www.devze.com 2023-04-05 15:43 出处:网络
Normally in Mercurial if I want to tag the current revision i do this: hg tag version12 This will tag my current revision to \"version12\"

Normally in Mercurial if I want to tag the current revision i do this:

hg tag version12

This will tag my current revision to "version12"

Now suppose that t开发者_如何学JAVAhe text "version12" is located in a file called buildNumbers.txt How can I issue a DOS command to tag it with the text contained within the buildNumbers.txt file?

What I already tried was piping the text file in.

hg tag < buildNumbers.txt

But that results in HG just giving me the help screen again. That tells me it doesen't understand this command.

So does anyone know how to extract the version number from the text file and provide it as a parameter ?


Given buildNumbers.txt containing just one line with one tag (no whitepsace):

for /f %v in (buildNumbers.txt) do hg tag %v

If the structure of buildNumbers.txt is more compilcated (you didn't specify it), see the "options" to the for command.


Would this be what you need?

D:\code>md htagtest

D:\code>echo bla>tagfile

D:\code>hg init

D:\code>touch a b c

D:\code>hg add a b c

D:\code>hg commit -m first

D:\code>cat tagfile | xargs hg tag

D:\code>hg log
changeset:   1:2dce938a816a
tag:         tip
user:        Tempos
date:        Sat Sep 17 00:34:36 2011 +0300
summary:     Added tag bla for changeset 349e58fd49a1

changeset:   0:349e58fd49a1
tag:         bla
user:        Tempos
date:        Sat Sep 17 00:34:27 2011 +0300
summary:     first


D:\code>


You could use a PowerShell script if your buildNumbers.txt is a oneliner!

UrdaNumber.txt Contents:

1.0

UrdaHgTag.ps1:

$ver = cat .\UrdaNumber.Txt
hg tag $($ver)

This will tag the current revision to 1.0 if executed inside the repository.


Another powershell version, that does it in one line with pipes:

cat buildnumber.txt | %{hg tag $_}

note this uses a loop, so if you have more than one line in your file you will have to use Select-Object as well, unless you want multiple tags

cat buildnumber.txt | Select-Object -first 1 | %{hg tag $_}
0

精彩评论

暂无评论...
验证码 换一张
取 消