2017-08-09 95 views
1

我的問題是非常直截了當的 - 是否有一個mercurial命令,你可以檢查一個分支是否關閉或不使用它的分支名稱?如何使用分支名稱知道分支是否已關閉?

hg branch_name status 

- closed 

沿着這些線的東西。 。?

感謝

+0

你可能想看看這個:https://stackoverflow.com/a/40385648/5619416。據我所知,你不能檢查遠程存儲庫,所以你必須讓它們在本地克隆。 –

回答

2

考慮回購這段歷史:

> hg log -G 
_ changeset: 3:fde10e155a4c 
| branch:  two 
| tag:   tip 
| summary:  close branch two 
| 
o changeset: 2:dec57b99f3d8 
| branch:  two 
| parent:  0:4b5a1a000402 
| summary:  add c 
| 
| o changeset: 1:1b3feb10b30e 
|/ branch:  one 
| summary:  add b 
| 
@ changeset: 0:4b5a1a000402 
    summary:  Add a 

有3個分支:defaultonetwo。分行two已關閉。

我們可以用hg branches如下:

--closed選項打印也是封閉的分支:

> hg branches --closed 
one       1:1b3feb10b30e 
two       3:fde10e155a4c (closed) 
default      0:4b5a1a000402 (inactive) 

所以用一個簡單的殼管使用grep:

> hg branches --closed | grep closed | grep two 
two       3:fde10e155a4c (closed) 
> 

作爲計數器例如,使用分支one會給出空輸出,因爲它沒有關閉:

> hg branches --closed | grep closed | grep one 
> 
0
hg log -r "branch('branch_name') and head() and (closed())" -T "{branch}" 

我用過的是這樣的。 這基本上指出T作爲模板後的分支名稱。

用您的分支名稱替換branch_name