2017-09-04 58 views
0

我試圖找出如果下面的Mercurial命令是等價的(附加+id -i輸出,如果目錄已經修改過的文件):hg id -ihg log -l1 --template "{node|short}"。他們還是不是?水銀命令等同

其目的是爲了加速某些自動化,而不需要執行id -i並在log模板中使用{node|short}。他們似乎相當,但我寧願如果別人看看,以及我繼續前。

回答

3

它們在某些條件下是等效的。 log -l 1爲您提供第一次修訂,當所有修訂從tip(「最新」)到0hg id告訴你你目前已經簽出了什麼。所以,如果你還沒有簽出尖端(說你已經簽出一個分支組織的特定版本),你會得到完全不同的輸出:

[email protected]:~/projects/mercurial-crew$ hg log -l1 --template "{node|short}\n" 
7eda5bb9ec8f 
[email protected]:~/projects/mercurial-crew$ hg id -i 
824f7b3545c1 

但是,如果你已經簽出tip(和你有沒有修改的文件),那麼他們是相同的(除了日誌不提供沒有\n換行符):

[email protected]:~/projects/mercurial-crew$ hg checkout tip 
4 files updated, 0 files merged, 0 files removed, 0 files unresolved 
[email protected]:~/projects/mercurial-crew$ hg id -i 
7eda5bb9ec8f 
[email protected]:~/projects/mercurial-crew$ hg log -l1 --template "{node|short}\n" 
7eda5bb9ec8f 
1

他們是不一樣的,因爲hg id默認檢查工作樹和:

$ hg merge side 
1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
(branch merge, don't forget to commit) 
$ hg id -i 
eb51a3480d0c+62e318575165+ 

如果您處於合併過程中,工作樹有兩個父母,並且hg id會同時打印這兩個父母。

同時,hg log默認爲注視當前(糟糕,由於Ry4an Brase尖端提交(而不是工作樹); {node | short}打印其ID:

$ hg log -l1 --template '{node|short}' 
eb51a3480d0c 

在另一方面,如果在合併的中間是,工作樹只有一個父。您也可以指定修訂.,它是當前提交的...所以在那種情況下是,它們實際上是相同的。