How to merge a foreign branch?

Asked by André Bachmann

Here are two repositories, A and B. A has several branches like trunk, feat1 and feat2. One day it was decided that a new software project B should be created. Repository B was born. Then we copied the files from the last revision of A/feat1 (rev 87) to B/trunk (committed as rev 1).
There were some commits on A/trunk, A/feat1, A/feat2 and B/trunk during the last months. Now we want to re-integrate B/trunk as A/feat1. Rev 2 of B/trunk should be rev 88 of A/feat1, rev 3 of B/trunk should be rev 89 of A/feat1 and so on.

But how can we do this? Merging from a foreign branch ("bzr merge B/trunk -r 1..2" when run from A/feat1's working tree) don't seem to be the right way for this, because this fails horribly with a great collection of different conflicts.

Question information

Language:
English Edit question
Status:
Solved
For:
Bazaar Edit question
Assignee:
No assignee Edit question
Solved by:
André Bachmann
Solved:
Last query:
Last reply:
Revision history for this message
Jelmer Vernooij (jelmer) said :
#1

On Mon, Mar 26, 2012 at 02:10:55PM -0000, André Bachmann wrote:
> Here are two repositories, A and B. A has several branches like trunk, feat1 and feat2. One day it was decided that a new software project B should be created. Repository B was born. Then we copied the files from the last revision of A/feat1 (rev 87) to B/trunk (committed as rev 1).
> There were some commits on A/trunk, A/feat1, A/feat2 and B/trunk during the last months. Now we want to re-integrate B/trunk as A/feat1. Rev 2 of B/trunk should be rev 88 of A/feat1, rev 3 of B/trunk should be rev 89 of A/feat1 and so on.
>
> But how can we do this? Merging from a foreign branch ("bzr merge B/trunk -r 1..2" when run from A/feat1's working tree) don't seem to be the right way for this, because this fails horribly with a great collection of different conflicts.
Merge won't help you much in this case, because the two branches
don't have related history or file identities.

The simplest thing to do is probably to use "bzr diff" to retrieve the
changes from B/trunk and then apply that to A/feat1 using patch.

(Note that the term "foreign" is usually used to refer to branches in Subversion, Git or
Mercurial, rather than unrelated branches)

Cheers,

Jelmer

Revision history for this message
André Bachmann (andrebachmann-dd) said :
#2

Thank you for the answer. We will use this in the future.

Are there any plans about implementing a feature in bzr to handle such a task with unrelated branches more efficient? I can imagine a command like "bzr import-branch --base-rev 87 --extern-rev 1 B/trunk" when called from A/feat1 which should do this kind of task.

Revision history for this message
Jelmer Vernooij (jelmer) said :
#3

On Tue, Mar 27, 2012 at 11:55:53AM -0000, André Bachmann wrote:
> Question #191752 on Bazaar changed:
> https://answers.launchpad.net/bzr/+question/191752
>
> Status: Answered => Solved
>
> André Bachmann confirmed that the question is solved:
> Thank you for the answer. We will use this in the future.
>
> Are there any plans about implementing a feature in bzr to handle such a
> task with unrelated branches more efficient? I can imagine a command
> like "bzr import-branch --base-rev 87 --extern-rev 1 B/trunk" when
> called from A/feat1 which should do this kind of task.
Yes, we have some ideas about this. It's a fairly hard problem to
solve properly though. For your use there are some easier hacks we
could do.

Cheers,

Jelmer