2010-04-20 98 views
26

我知道Mercurial可以跟蹤文件的重命名,但我怎樣才能得到它顯示當我做hg status時,我改名而不是添加/刪除?例如,而不是:在hg狀態下顯示重命名?

A bin/extract-csv-column.pl 
A bin/find-mirna-binding.pl 
A bin/xls2csv-separate-sheets.pl 
A lib/Text/CSV/Euclid.pm 
R src/extract-csv-column.pl 
R src/find-mirna-binding.pl 
R src/modules/Text/CSV/Euclid.pm 
R src/xls2csv-separate-sheets.pl 

我想一些跡象表明,四個文件已被移動。

我想我在某處讀到輸出是這樣的,以保持與某些東西或其他東西的向後兼容性,但我並不擔心這一點。

+0

你的意思是「hg status」?我不認爲hg log會以您列出的格式生成輸出。 – 2010-04-21 01:01:53

+0

其實,我使用下面的命令讓hg log顯示額外的東西(和顏色):http://bitbucket.org/sjl/mercurial-cli-templates/src/所以讓我們把問題改爲'hg status'。 – 2010-04-21 01:16:54

回答

32

有幾種方法可以做到這一點。

你提交之前,你可以使用hg diff --git顯示什麼改名爲:

$ hg diff --git 
diff --git a/theTest.txt b/aTest.txt 
rename from theTest.txt 
rename to aTest.txt 

請注意,如果這僅適用於您使用hg mvhg rename,或mvhg addremove --similarity 100

你提交之後,你仍然可以使用hg diff,但你必須指定使用-r變化:

$ hg diff -r 0 -r 1 --git 
diff --git a/test.txt b/theTest.txt 
rename from test.txt 
rename to theTest.txt 

對於這兩種hg statushg log,使用-C命令行標誌,以查看源文件被複制。

$ hg status -C 
A aTest.txt 
    theTest.txt 
R theTest.txt 

略低於aTest.txt的行表示這是從(theTest.txt)複製的來源。

$ hg log -v -C 
changeset: 1:4d7b42489d9f 
tag:   tip 
user:  jhurne 
date:  Tue Apr 20 20:57:07 2010 -0400 
files:  test.txt theTest.txt 
copies:  theTest.txt (test.txt) 
description: 
Renamed test.txt 

可以看到,而 「theTest.txt」 從test.txt的複製受到影響的文件(test.txt的和theTest.txt)。

14

您可以通過hg summary找出已重命名的文件數量。如果你想看到被重命名的實際文件,我已經找到了最快捷的方式就是做:

hg st -a -C 

這將輸出類似這樣:

A <path\to\renamed\file> 
    <path\copied\from> 
A <path\to\added\file> 
A <path\to\renamed\file> 
    <path\copied\from> 

由於汞的地位考慮的重命名要成爲副本和刪除,重命名的文件將列出從文件複製的文件。添加但未重命名的文件不會列出從文件複製的文件。