Merging Branches

This forum is now locked, since Gold Support is no longer offered.

Moderator: SourceGear

Locked
Thalko
Posts: 21
Joined: Thu Feb 17, 2005 2:34 pm

Merging Branches

Post by Thalko » Tue Nov 01, 2005 4:46 pm

I have a Main branch (Main) that I broke off of to create a new branch (Release 1) to do some work in. After completing the work in Release 1 I removed access and created a new branch from Release 1 called Release 2. when work is completed in Release 2 i want to bring all the changes from Release 1 and Release 2 up to the Main branch.

My question is to bring up these changes to the Main branch do i have to merge Release 1 up then merge Release 2 up to the Main branch or is there a way to merge up the changes from Release 2 and it will include the changes made in Release 1 since the changes are already in Release 2 since it was derived from Release 1?

When i attempt to merge Release 2 up to the Main branch i only see the changesets from Release 2. Must i merge all the Release branches up in the order they were created to get all the changes made in the Release branches?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Wed Nov 02, 2005 9:55 am

If you branch, then branch the branch, merging back into the original trunk is a two-step process. The way to do this would be to first merge Release 2 into its trunk, which is Release 1. Then merge the merged Release 1 into the Main branch.
Linda Bauer
SourceGear
Technical Support Manager

Thalko
Posts: 21
Joined: Thu Feb 17, 2005 2:34 pm

Post by Thalko » Wed Nov 02, 2005 1:45 pm

So, if i understand you correctly, if i created Release 3 which was branched from Release 2 and wanted to merge all the changes made from Release 3, Release 2 and Release 1 into the Main branch (assuming i have not merged Release 1 or Release 2 into Main) then i would have to do the following:

1.) Merge Release 3 into Release 2
2.) merge Release 2 into Release 1
3.) finally Merge Release 1 into Main

If this is the case then i would just end up having 3 Release branches with the same code. The proj. mgr wants to keep the Release branches as they are for historical purposes. Is there anyway to move all the changes up to the Main branch without forcing the release branches to have the latest code?

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Wed Nov 02, 2005 2:20 pm

A couple of ideas:

Create a branch from Main for each release, rather than branching the branch.

Or --

Branch, create Release 1, label, continue work for Release 2, label.
You will always be able to retrieve/view Release 1 and 2 via Get Label.

Chapters 7 and 8 of Eric Sink's Source Control HowTo has some useful information about branching and merging branches:
http://www.ericsink.com/scm/source_control.html
Linda Bauer
SourceGear
Technical Support Manager

mlippert
Posts: 252
Joined: Wed Oct 06, 2004 10:49 am
Location: Cambridge, MA

Post by mlippert » Thu Nov 03, 2005 5:15 pm

As I understand your structure, you have a Trunk, and have branched for Release 1. You later branched Release 1 creating essentially a Release 1.1 which you are calling Release 2.

In your situation, all changes made in the Release 1 branch exist in the Release 2 branch.

Now you want to merge all of the changes made in both branches back into your Trunk.

I think the best way to do that is to merge the Release 1 branch to the Trunk selecting all changesets, and then merge the Release 2 branch to the Trunk again selecting all changesets (except the initial branch changeset).

In a prior message conversation with Eric, I learned that the Merge branches uses the initial changeset selected as the base in doing a "3-way" merge. I suggested the 2 step merge above because of this.

If a file is unmergable (binary for example) the merge will still automatically update it (by overwriting it) if the target file is identical to the "base" file.

In addition the base file really will be the base file for a 3-way text file merge.

You could attempt to just merge the Release 2 branch to the Trunk without 1st merging the Release 1 branch and the end result would be the same. However the process is likely to be much more difficult with more merge conflicts and un-mergable files that you will have to resolve manually.

Eric please correct me if I've said anything that isn't true.

I hope this helps,
Mike

lbauer
Posts: 9736
Joined: Tue Dec 16, 2003 1:25 pm
Location: SourceGear

Post by lbauer » Thu Nov 03, 2005 5:23 pm

You could attempt to just merge the Release 2 branch to the Trunk without 1st merging the Release 1 branch and the end result would be the same.
When I tried just merging Release 2 into Trunk, the Release 1 changes were not incorporated in Trunk, even though Release 2 had all the content from Release 1.
Linda Bauer
SourceGear
Technical Support Manager

mlippert
Posts: 252
Joined: Wed Oct 06, 2004 10:49 am
Location: Cambridge, MA

Post by mlippert » Thu Nov 03, 2005 5:39 pm

Interesting, thanks Linda.

Now that you say that, I guess I can understand it. Only the actual changes made to the source file in the selected changesets are "merged" into the target file.

The expectation that the differences between the "base" file and the target file are all due to changes made to the target file since it was branched is false.

Thats the reason the changes between when the file was branched to Release 1 and when it was branched to Release 2 are not done during the merge.

I'll have to remember that.

Mike

In some future version of Vault I hope it will keep track of branches and merges so that it would always KNOW the real base file and not need to be told.

ericsink
Posts: 346
Joined: Mon Dec 15, 2003 1:52 pm
Location: SourceGear
Contact:

Post by ericsink » Thu Nov 03, 2005 6:03 pm

mlippert wrote:In some future version of Vault I hope it will keep track of branches and merges so that it would always KNOW the real base file and not need to be told.
This capability is planned to be in Vault 4.0.
Eric Sink
Software Craftsman
SourceGear

ericsink
Posts: 346
Joined: Mon Dec 15, 2003 1:52 pm
Location: SourceGear
Contact:

Post by ericsink » Thu Nov 03, 2005 6:04 pm

mlippert wrote:Eric please correct me if I've said anything that isn't true.
Your post looks correct. Thanks.
Eric Sink
Software Craftsman
SourceGear

mlippert
Posts: 252
Joined: Wed Oct 06, 2004 10:49 am
Location: Cambridge, MA

Post by mlippert » Thu Nov 03, 2005 6:05 pm

Awesome! Thanks Eric.

I'm assuming since you didn't say otherwise, that my message above to Thalko (after the correction by Linda) is OK.

Mike

(edit: I see you did say it was OK, looks like our posts crossed in the ether! :D )

Locked