2016-12-21 10 views
1

リモートリポジトリから最新のチェンジセットを取得し、同時にローカルリポジトリを特定のtagに更新したいと思います。 hg fetchまたはhg pull -uと似ていますが、タグが更新されています。 2行のコードでは、これは次のとおりです。Mercurial:特定のタグを取得して更新する方法

hg pull 
hg update mytag 

hg pull --helpは、次のことを明らかにし、残念ながらそれらのどれも、タグのために働いていません:

options: 

-u --update    update to new branch head if changesets were pulled 
-f --force     run even when remote repository is unrelated 
-r --rev REV [+]   a remote changeset intended to be added 
-B --bookmark BOOKMARK [+] bookmark to pull 
-b --branch BRANCH [+]  a specific branch you would like to pull 
-e --ssh CMD    specify ssh command to use 
    --remotecmd CMD   specify hg command to run on the remote side 
    --insecure    do not verify server certificate (ignoring web.cacerts config) 

私が試したもの:

hg pull -r mytag   only pulls the latest changesets, but no update 
hg pull -u     pulls and updates to tip, but no tag allowed 
hg pull -b mytag   abort: unknown branch 
hg pull -B mytag   abort: remote bookmark mytag not found 

それを1行で行うことは可能ですか?

+0

ちょうど好奇心が強い、なぜユースケースのように1行に入れたいのですか? –

答えて

1

コマンドラインで作業している場合は、これが役に立ちます。

まず関数を作成します。

function pullandup(){ hg pull; hg up $1; } 

$1は、最初のコマンドライン引数に置き換えられます。したがって、この関数はコマンドライン引数よりも最初にhg pullを実行し、指定されたリビジョン/ブックマーク/タグに作業ディレクトリをupdates実行します。

このエイリアスを作成して、関数を呼び出すことができます。

alias pull_up='function pullandup(){ hg pull; hg up $1; };pullandup' 

pull_up mytag 

を実行すると、最初にすべての最新のチェンジを引っ張ってくると、作業ディレクトリはmytagに更新します。

他の端末で作業しているときに違いがあるかもしれません。これはBASH向けです。

2

vanilla Mercurialを使用すると、特定のタグ、リビジョンなどに&を更新するコマンドはありません。

hg pull 
hg update mytag 

または

hg pull 
hg update -r REVNUMBER 

うまく仕事をするだろう、私は一つだけの余分なコマンドをやってから私を節約エイリアスと関数でそれを複雑にしません。

関連する問題