Integrating from multiple unrelated branches
Wesley J. Landaker
wjl at icecavern.net
Wed Feb 25 00:15:16 GMT 2009
Hey folks,
Here is a scenerio that keeps coming up when I use bzr, but I have not
yet been able to solve:
Imagine there is an upstream for a particular piece of code. They don't
have version control, they just make tarball releases. I manually track
the upstream version by importing the tarballs when they come out, e.g.
bzr init upstream-release
cd upstream-release
bzr import ../something-x.y.z.tar.gz
bzr commit -m "Imported x.y.z"
bzr tag something-x.y.z
... later ...
bzr import ../something-l.m.n.tar.gz
bzr commit -m "Imported l.m.n"
bzr tag something-l.m.n
... etc ...
Now, there are also some other repositories that I want to track that
deal with this same software. For example, some other Linux
distribution may have a real repository, which contains both packaging,
and bug fixes that may or may not have been sent upstream. I can track
this via the usual mechanisms, but for simplicity, pretend it's a
bazaar branch:
bzr branch http://3rdparty/something 3rdparty
... later ...
cd 3rdparty
bzr pull
There might be more than one of these, repositories. Some might be
Subversion, some might be git, but whatever, I can always somehow turn
them into local Bazaar branches.
Finally, because I'm packing the software for Debian, I have of course
also have my OWN Bazaar branches with features, patches, etc.
Now, I want to be able to continuously merge from all of these sources.
Unfortunately, I've never found a way to do this with Bazaar.
This is what I IMAGINE would happen:
# base the debian package off of the upstream-release
bzr branch upstream-release pkg-debian
cd pkg-debian
bzr merge ../pkg-fedora
... resolve conflicts, edit out irrelevent changes, etc ...
bzr commit -m "Merged bugfixes from Fedora"
... later ...
bzr merge ../upstream-release
bzr commit -m "Merged upstream"
... later ...
bzr merge ../pkg-fedora
bzr commit -m "Merged new bugfixes from Fedora"
... etc ...
Instead, it usually it goes like something this after the very first
merge, even if diff -r of the two directories is IDENTICAL.
LOTS OF CONFLICTS
src => src.moved
lib => lib.moved
scripts => scripts.moved
Makefile => Makefile.moved
... etc ...
Now, I can resolve these by manually moving the directories around,
manually diffing files between, say, src and src.moved, and eventually
get it all resolved. Okay, great, so "bzr commit". But now, later
merges only recognize changes from one side -- i.e. whichever side I
happened to pick when I resolved the directory conflicts. So now either
merging upstream-release fails, or merging pkg-fedora fails, or merging
some-other-3rdparty fails, etc.
In general, it seems like if you have two or more branches that are
IDENTICAL on their tip, but aren't historically related, you can't
effectively merge them so that later merges from either one will result
in your files actually getting updated.
This is easy to reproduce, if you do something like:
bzr init A
bzr init B
cd A
mkdir subdir
echo "Hello" > subdir/file
bzr add
bzr commit -m "Added a file"
cd ../B
mkdir subdir
echo "Hello" > subdir/file
bzr add
bzr commit -m "Added a file"
cd ..
bzr branch A C
cd C
bzr merge -r0..1 ../B
... resolve subdir conflicts ...
bzr commit -m "Merged B"
Now if you add or remove files in the subdir or modify "subdir/file" in
A or B and merge them both into C, you will EITHER get the changes from
A or from B (depending how you resolved things), and the changes from
the other repository result in horrible, horrible conflicts.
I'm guessing the root cause is to be that a merge can't record that a
file (or directory) has multiple file-id's from multiple chains of
history.
I really hope this isn't a fundamental flaw, because this isn't a
problem with, say subversion: if I put everything in as svn branches
and merge things that way, it works fine. Same with, say, CVS! But of
course, I don't want to use those, I want to use a DVCS. Well, as far
as I can tell with my testing, this isn't a problem with git or hg,
only with Bazzar. But I *want* to use Bazaar!
Am I missing something? Is there really no way to merge multiple,
IDENTICAL, but unrelated branches, and after resolving conflicts have
them merge happily after that?
--
Wesley J. Landaker <wjl at icecavern.net> <xmpp:wjl at icecavern.net>
OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2
More information about the bazaar
mailing list