2013-03-06 48 views
4

subrepositories我有subrepositories許多項目:如何合併一個特性分支爲默認與水銀

/project    <- Main repository 
/project/src   <- Source code subrepository (subrepository to /project) 
/project/src/module <- Module subrepository (subrepository to /project/src repository) 

我現在已經有幾個版本特性分支(特徵1)工作,我現在想要合併回默認分支。自從特性1分支被創建以來,默認分支沒有任何變化。

我已經嘗試將分支合併到默認值,但最終發生在子庫中的一些奇怪的事情。

我已經按照這個other post的說明,並得到下面的結果:

$ hg checkout default 
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
$ hg merge feature1 
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved 
    (branch merge, don't forget to commit) 
$ hg status -S 
    M .hgsubstate 
$ hg commit -S -m "branch merge test" 
    nothing changed 
$ hg branches 
    default      19:c2398dc23428 
    feature1      17:98dc0efbad90 (inactive) 

什麼奇怪的是,儘管很多文件都在模塊 subrepository改變,合併只說1文件已更新。我假設這恰好是.hgsubstate

當我明確地更新subrepository,然後我得到如下:

$ cd src/module 
$ hg update 
    39 files updated, 0 files merged, 23 files removed, 0 files unresolved 
$ cd ../.. 
$ hg commit -S -m "feature1 merge" 
    committing subrepository src 
$ hg status -S 
    M .hgsubstate 

這樣做汞柱更新把所有的修改到工作目錄後,我看到了模塊中的變化我需要提交的subrepository。但是,.hgsubstate始終保持修改狀態。我試過hg刪除。我試過hg忘記。但是不管我做什麼,當我做hg狀態時它仍然被標記。

所以我的問題是:

  1. 當時我走上合併在正確的分支(考慮subrepositories存在)的過程?
  2. 是否需要在子庫中執行hg更新以使主存儲庫能夠識別更改?
  3. 爲什麼.hgsubstate行爲不端?

回答

2

你不說你正在使用哪個版本的hg - subrepo支持已經隨時間改變了一定的數量。我剛剛在hg v2.8中使用了3個subrepo級別的測試,並且適用於我。

當你在頂層有一個髒的.hgsubstate時,當你提交一個subrepo時,這是正常的。 [如果只有一個subrepo被獨立提交,那麼只有.hgsubstate在頂層是髒的。]如果你然後進入頂層並在該層提交,那麼.hgsubstate將被提交,並且一切正常。請記住,頂層回購以類似於文件的方式跟蹤subrepos - 它會在每個頂層提交時提交來自subrepo的特定更改集。

FWIW。推薦的做法是單獨進行subrepos,即避免subrepos骯髒時在頂層進行。原因是subrepos通常需要不同的提交信息 - 畢竟它們是有原因的subrepos;但是如果你願意的話,你可以在頂層進行提交。在你的情況下,3個級別的序列將是:

cd src/module 
hg commit -m "src/module commit reason" 
cd .. 
hg commit -m "src commit reason" 
cd .. 
hg commit -m "top level reason" 

這是意圖subrepos會改變,例如,第三方庫。如果你的subrepos頻繁更換,你和你的團隊必須保持警惕,以避免錯誤,特別是當與其他人合併時。 [但是考慮到問題的日期,你現在可能已經自己解決了這個問題。]