
Distributed version control is great for merging. Things like bazaar, git, mercurial, etc. all have sophisticated tools and good support for merging branches of the same code that have diverged even if files have been moved or renamed. But what about merging branches with no common ancestor? I needed to do just that today. I had two bazaar repositories that were separate parts of the same project. One repository was the client and one held the server. I decided that it was pretty inconvenient and a bad idea to have them in separate repositories. I wanted to merge the repositories so I wouldn't lose the history for either project.
Turns out this is pretty easy... In bazaar you can simply do the following:
- Change directory to the destination working copy.
- Execute the following command
bzr merge /path/to/source-working-copy -r0..-1
- Note the -r0..-1 part of the command. This tells bazaar to merge a range of revisions from the first revision to the most current.
- Now review and commit the changes. Notice that bazaar gives you an indication that all history is preserved by displaying a list of checkin comments. Nice.