當使用mercurial時,當處理大的變化時,我會做幾個提交(作爲安全點,或與同事分享我的進展)。 當我完成後,我想將我的更改推送到主存儲庫。然而,在我這樣做之前,我會想要做一個「hg pull -u & & hg merge」以獲得自我上次拉動以來發生的更改,並查看我的更改。如何顯示傳出差異而不合並?
因爲我有幾個變更集,所以在每一個上運行hg diff都不是一個好的解決方案。
我試着運行hg diff -c「outgoing()and not merge()」來僅顯示我輸出變更集的差異(沒有合併的變化集,因爲這往往只會增加我想要避免的噪音)。
但是,這對我來說還是不好,因爲mercurial似乎跳過了一些信息,我不明白是什麼原因。請參考以下場景:
全場景:
# clean working directory
rm -fr base clone
#prepare reference repo
mkdir base; cd base
hg init
touch 1.txt
echo " 1\n2" >>1.txt
hg add 1.txt
touch 2.txt
hg add 2.txt
hg commit -m"initial commit"
cd ..
hg clone base clone
cd base
#update ref repo.
echo "foo" >> 1.txt
hg commit -m"update file on remote repository"
#make changes locally
cd ../clone
echo "foo" >> 2.txt
hg commit -m "update initial file"
#now we are ready to push
hg pull -u && hg merge
hg commit -m"merge"
#actually...
sed -i -e 's/foo/bar/' 2.txt
hg commit -m"changed my mind"
hg out
changeset: 1:fce14ac089b2
date: Thu Nov 14 11:17:08 2013 +0100
summary: update initial file
changeset: 3:1967c50242c0
parent: 1:fce14ac089b2
parent: 2:2cdaf75afc6d
date: Thu Nov 14 11:17:10 2013 +0100
summary: merge
changeset: 4:120a0b8a0ede
tag: tip
date: Thu Nov 14 11:18:54 2013 +0100
summary: changed my mind
#try to display my changes
hg diff -c"outgoing() and not merge()"
--- a/2.txt Thu Nov 14 11:17:10 2013 +0100
+++ b/2.txt Thu Nov 14 11:18:54 2013 +0100
@@ -1,1 +1,1 @@
-foo
+bar
#only one change here!
#but
hg log -r"outgoing() and not merge()"
changeset: 1:fce14ac089b2
date: Thu Nov 14 11:17:08 2013 +0100
summary: update initial file
changeset: 4:120a0b8a0ede
tag: tip
date: Thu Nov 14 11:18:54 2013 +0100
summary: changed my mind
#is ok
所以,任何人都可以請給我爲什麼善變跳過變更集fce14ac089b2完全解釋一下嗎?我期望的是一個合併的輸出,即類似的:
--- a/2.txt
+++ b/2.txt
@@ -1,1 +1,1 @@
+bar
非常感謝提前。