2016-11-10 115 views
1

我在幾個月前從默認創建分支br1。從那以後,我一直在致力於br1的改變。時不時地,拉動從默認的變化如下:在兩個分支之間創建更改提交

hg up br1 
hg merge default 
// create a commit, push 

我想創造的我做出BR1在過去幾個月的所有更改的提交信息。分支br1和default在我的工作空間中是乾淨的,也就是說沒有未提交的更改,沒有未推入的提交。此時,br1在1周內與默認值不同步。我做了以下步驟:

hg up default 
hg merge br1 
// At this point, "hg stat" shows files that I did not modify in br1. :(
// So, if I created a commit message at this point, it would be no good. 
// I am not sure why these addition file modifications showed up. 

我覺得這個問題可能是因爲br1與默認的一週不同步。我執行了以下一系列的步驟在乾淨的工作區:

hg up br1 
hg merge default 
// created a commit -**ch1**, but did **NOT push** 
hg up default 
hg merge br1 
// At this point, "hg stat" shows the same additional files as my pervious 
// attempt. :(

問: - 是否「汞合併」無視提交未推? - 我需要推ch1爲這些額外的文件不顯示?這是「hg merge br1」何時顯示額外文件的原因嗎? - 有沒有一種方法可以告訴hg在從br1進行合併時考慮到ch1。

謝謝, 艾哈邁德。

回答

1

好了,因爲你沒有提供一個工作的例子,我要建立一個從頭開始,所以請原諒我在結束下方

解釋了一堆命令行,因爲纔有意義,如果你效仿的榜樣步驟

準備階段

# create a new dir an initialize the repository 
mkdir hgtrial 
cd hgtrial 
hg init 

# create an empty file and make first commit on default branch 
echo . > dummy.txt 
hg add dummy.txt 
hg commit -m "1st commit" 

# add info and make a second commmit also on default branch 
echo abc >> dummy.txt 
hg commit -m "2nd commit" 

# create a new branch and make an empty commit on it 
hg branch br1 
hg commit -m "my new branch" 

# work on br1 
echo def >> dummy.txt 
hg commit -m "def on br1" 

# work on default (make br1 out of sync) 
hg up default 
echo ghi >> dummy.txt 
hg commit -m "ghi on default" 
echo jkl >> dummy.txt 
hg commit -m "jkl on default" 

# sync br1 by pulling default 
hg up br1 
hg merge default 
# solve merge conflicts (abc def ghi jkl) 
hg commit -m "br1 <- default" 

# continue working on br1 (without touching dummy.txt) 
echo 123 > another.txt 
hg add another.txt 
hg commit -m "another file" 
echo 456 >> another.txt 
hg commit -m "456" 

# work on default (make br1 out of sync) 
hg up default 
echo yes-yes > one-more.txt 
hg add one-more.txt 
hg commit -m "yes-yes, on default" 
echo no-no >> one-more.txt 
hg commit -m "no-no, on default" 

現在的問題(通知我們站在default BR anch)

# now the problem (scenario 1) 
hg merge br1 
hg stat 
# dummy.txt is modified, trying to bring "def" from br1 into default 
# abort 

# checkout clean br1 (drop merge in progress) 
hg up -C br1 
hg merge default 
hg commit -m "br1 <- default" 

# the problem again (scenario 2) 
hg up default 
hg merge br1 
hg stat 
# dummy.txt is modified, trying to bring "def" from br1 into default 
# SAME THING! 

爲什麼? 因爲在某些時候"def"變化在br1製成,default從來不知道這件事,所以即使你沒有在很長一段時間摸dummy.txt,你已經同步defaultbr1,但沒有倒過來,因此default有很多趕上

編輯:在TortoiseHg 這個場景的截圖添加TortoiseHg merge in progress

+0

非常感謝你的解釋,工作示例。問題是,對於場景1,我猜測hg stat會像「dummy.txt被修改,試圖從br1帶來」def「,並且存在新文件another.txt。這正是我想要的。這兩項是br1所做更改的完整列表。 –

+0

什麼是一個好的推薦工作流程,以獲得只有bri到bri的變化列表,這將是「def」到dummy.txt,並創建新文件another.txt。有推薦的工作流程嗎? –

+0

爲更好的可視化和理解發生了什麼我會推薦你​​TortoiseHg(GUI),同時你可以參考http:// stackoverflow。com/questions/25238277/mercurial-show-diff-against-2-parents-or-base-merge- – arhak

相關問題