2012-03-24 179 views
2

我有三個獨立的Bazaar存儲庫。它們都與單個項目有關,但沒有重疊文件。如何將倉庫中的倉庫合併爲一個倉庫?

我想將它們合併到一個存儲庫中,位於不同的子文件夾下,並保留它們的歷史記錄。

這可能嗎?請注意,我不想保持存儲庫的獨立性。這將是一次性操作。

在GIT中有這樣做的解決方案:How do you merge two Git repositories?但我無法找到與Bazaar類似的解決方案。

我曾嘗試: 我試圖合併庫,但有兩個儲存共同路徑文件導致衝突。我希望他們在不同的子目錄下合併,但不知道如何。我主要以非協作方式使用Bazaar;我不熟悉merge命令。

更新:我發現a bzr plugin其目的是做我想要的東西,但它是越野車。

+0

你嘗試過'bzr join'命令嗎? – dOxxx 2012-03-24 13:37:34

+0

是的,我嘗試過。並擊中這個錯誤/功能:https://bugs.launchpad.net/bzr/+bug/370710 – HRJ 2012-03-24 14:57:56

+0

你在嘗試升級之前運行「bzr加入」? – jelmer 2012-03-24 21:20:41

回答

4

您可以使用merge -r0..-1命令執行此操作。但是如果你想把文件放到不同的子文件夾中,最好在合併之前這樣做。

假設您有一個main組件和2個子組件:foobar。您希望您的新的組合項目具有以下結構:

ProjectRoot/ 
    main.txt  <-- any files from main component 
    ...    should be at the root of the project 
    ... 
    bar/   <-- bar subdirectory with files from bar component 
    foo/   <-- foo subdirectory with files from foo component 

我們將合併foobarmain。但是,首先讓我們來移動文件到子目錄:

cd /path/to/foo 
bzr mkdir foo 
bzr mv file1 file2 foo 
bzr commit -m "files moved into foo/ subdirectory" 

而且類似的bar

cd /path/to/bar 
bzr mkdir bar 
bzr mv file3 file4 bar 
bzr commit -m "files moved into bar/ subdirectory" 

現在,我們已經準備好要合併到一切main

cd /path/to/main 
# ensure the working tree does not have uncommitted changes 
bzr status 
# now merge foo 
bzr merge -r0..-1 /path/to/foo 
# if there is no conflicts then you can commit this part 
bzr status 
bzr commit -m "merged foo component" 
# now merge bar 
bzr merge -r0..-1 /path/to/bar 
# if there is no conflicts then you can commit this part 
bzr status 
bzr commit -m "merged bar component" 

之後,你main會合並了foobar

+0

感謝@bialix,但這會遇到同樣的問題:它會在應該不同的項目文件之間產生衝突。在我的情況下,它只發生在最後一次合併中,所以我可能會咬緊牙關,放棄最後一個倉庫的提交歷史記錄。 – HRJ 2012-03-24 10:46:39

+0

@HRJ:您可以使用bzr-fastimport插件將您的第三個回購轉換爲1.14格式(非富根),然後再次合併它。 – bialix 2012-03-24 17:03:20

相關問題