2012-03-24 180 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

相关问题