2

I have three independent Bazaar repositories. They are all related to a single project but have no overlapping files.

I want to combine them into a single repository, under different sub-folders, and preserve their history.

Is this possible? Note that I don't want to maintain the independent nature of the repositories. It will be a one time operation.

There is a solution for doing this in GIT: How do you merge two Git repositories? But I couldnt find something similar for Bazaar.

What I have tried: I tried merging the repositories, but files that have common paths in the two repositories cause conflicts. I would like them to be merged under different sub-directories but couldn't figure out how. I mostly use Bazaar in a non-collaborative way; I am not familiar with the merge command.

Update: I found a bzr plugin which aims to do exactly what I want, but is buggy.

Community
  • 1
  • 1
HRJ
  • 17,079
  • 11
  • 56
  • 80
  • Have you tried the `bzr join` command? – dOxxx Mar 24 '12 at 13:37
  • Yes, I did try. And hit this bug/feature: https://bugs.launchpad.net/bzr/+bug/370710 – HRJ Mar 24 '12 at 14:57
  • Have you tried upgrading before running "bzr join" ? – jelmer Mar 24 '12 at 21:20
  • Yes @jelmer, I did try upgrading. I even tried downgrading to an older format. I have even tried assigning unique root ids to the different repositories using a python script. I have tried cascading the joins as well. That is `A` join with `B`, then join that merger with `C`, etc. It was a whole day of experimentation, but no dice. – HRJ Mar 25 '12 at 06:57

2 Answers2

4

You can do it with merge -r0..-1 command. But if you want to put files into different subfolders, it's better to do that before merge.

Let's say you have one main component, and 2 subcomponents: foo and bar. You want your new combined project to have the following structure:

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

We will merge foo and bar into main. But first let's move files into subdirectories:

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

And similar for bar:

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

Now we're ready to merge everything into 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"

After that your main will have both foo and bar merged.

bialix
  • 20,053
  • 8
  • 46
  • 63
  • Thanks @bialix but this runs into the same problem: it creates conflicts between project files which are supposed to be different. In my case it is happening only with the last merge, so I may bite the bullet and forego the commit history for that last repository. – HRJ Mar 24 '12 at 10:46
  • @HRJ: you can use bzr-fastimport plugin to convert your third repo into 1.14 format (non rich-root) and then merge it again. – bialix Mar 24 '12 at 17:03
0

Appears there's a plugin for this, at least for bazaar (as opposed to breezy), as of writing (July 2021) - https://launchpad.net/bzr-merge-into

stellarpower
  • 332
  • 3
  • 13