2011-03-03 98 views
30

我想弄清楚如何合併分支從一個單獨的回購到當前。從不同的存儲庫合併Mercurial分支

我有以下幾點:

PJT1 - 包含分支默認和foodog

PJT2 - 包含分支默認

從PJT2

,我做了以下內容:

$ hg fetch -y ../PJT1 -r foodog -m "this is a test" 

現在,如果我查看PJT2,我會看到正確的文件和更改。但是,我如果我做hg branches,我得到如下:

[[email protected] pjt2]$ hg branches 
foodog       1:c1e14fde816b 
default      0:7b1adb938f71 (inactive) 

hg branch揭示了以下內容:

[[email protected] pjt2]$ hg branch 
foodog 

我如何將內容從PJT1的foodog支進PJT2的default分支?

回答

55

你需要合併,但要記住分支食物的變化總是在食物上 - 分支永遠不會離開,但它們可以隱藏。命令序列是儘可能接近你會得到你的要求:

cd PJT2 
hg update default # just in case you were somewhere else 
hg pull ../PJT1 -r foodog # that gets you foodog 
hg merge foodog # that merges the changes into default 
hg commit # commit the merge 
hg update foodog # go to the most recent change in foodog (note: it is not a 'head') 
hg commit --close-branch 

合併後hg branches仍將顯示foodog除非你做hg branches --active這隻能說明,對他們的頭分支。在commit --close-branch之後,除非你做hg branches --closed,否則你不會看到foodog

這是因爲Mercurial中的分支從不完全消失(設計特徵),它們通常僅用於終生使用,如release-1.0stable。對於諸如錯誤和功能等短暫的努力,請考慮使用書籤。以下是兩者的極佳對比:http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial

0

您也可以嘗試使用rebase擴展名。這將是這個樣子:

hg fetch -y ../PJT1 -r foodog -m "this is a test" 
hg rebase --source <sRev> --dest <dRev> 

底墊作用將detatch變更SREV和所有後代並應用組更改到變更集DREV。默認情況下,更改將應用​​於默認分支。所以,你的情況,SREV將是對分支foodogDREV第一變更將要應用於他們的默認變更。

最後,如果你想覆蓋這個並保留源分支名稱,你可以使用底座選項--keepbranches。你的問題表明這正是你不想做的事情,但應該指出。