Merge single branched file

If you are having a problem using Vault, post a message here.

Moderator: SourceGear

Post Reply
Posts: 17
Joined: Fri Jun 27, 2008 1:07 pm

Merge single branched file

Post by edonaldson » Wed Oct 29, 2008 12:55 pm

Perhaps I am missing something very obvious, but I've spent hours trying to figure this out, and I hope I'm not as dense as it seems.

Is there way to merge a single file from a branch back into the trunk, incorporating only those change history items that are relevant for that file?

here's our scenario:

core/file1 is branched to client/file1
Modifications are made on client/file1 for client specific requirements
Modifications are made on core/file1 for other improvements
core/file2 is branched to client/file2
Modifications are made on client/file2
Modifications are made on client/file1 for client specific requirements

At some point, we want to integrate the changes made to client/file1 into core/file1, because we think the changes could benefit others.

However, I cannot find any way to merge just the changes and history for client/file1 into core/file1. Sure, I can use the Merge Branch on client as orig and core as target, and select only that file, but the history of the changes is a complete disaster. When I select the range of changes to apply, some of the changes are made to file2, which I obviously don't need to include the history of those changes, and moreover, they make the change history very confusing, since they are unrelated.

I really only want the history for file1 to be included, not the history for all changes to the folder.

So, am I missing something?

Or, should I be doing something other than a branch/merge?

Posts: 1821
Joined: Thu Dec 18, 2003 11:39 am
Location: Sourcegear

Re: Merge single branched file

Post by jeremy_sg » Wed Oct 29, 2008 1:08 pm

No, Merge Branches will not work for you in this case, since it currently only supports merging all of the changes in a range. We are currently investigating ways or changing Merge

I can offer two workarounds,

1. Use Merge Branches as normal at the folder level, but only check in the one file that you wish to merge, undoing all merges that were done to other files.

2. Use the Show Differences dialog to diff between trunk and the branch, manually moving changes between the two versions.
Subscribe to the Fortress/Vault blog

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear

Re: Merge single branched file

Post by jeffhostetler » Wed Oct 29, 2008 6:04 pm

Let me make a suggestion here. It's a little crude, but it should get the job done.
I'll assume that you want to merge the most recent version of 'file1' from the branch
with the most recent version in the trunk.

1. Checkout core/file1 or make it writable.
2. Open the history on core/file1.
3. Select the most recent version and the version at the branch point.
4. Right click and select "Diff...".

This will open DiffMerge with those 2 versions. The ancestor on the left
and the most recent version on the right.

5. Open the DiffMerge About Box and click on "Support".

This will show you the command line arguments that were used to start
DiffMerge. Argv[5] should contain the pathname of the temp-file used
for the ancestor. Copy this pathname to the clipboard and close the
Support and About Box dialogs.

6. Open a new Merge Window.
6a. Paste the ancestor pathname into the center field.
6b. Type/Browse the pathname for 'core/file1' for the top field.
6c. Type/Browse the pathname for 'client/file1' for the bottom field.

This will give you the usual 3-way merge window with the core version
on the left, the common ancestor in the center, and the client branch
version in the right panel.

You can then do an interactive merge as usual.

7. THIS IS IMPORTANT. When you are finished with the merge, use 'Save As'
to save the merge-result to core/file1. (A regular 'Save' will try to write to the
temporary file.)

This will merge the contents of the 2 different development paths into a single
file, but it won't help you compose the checkin comment as a true Merge Branches
will -- you'll have to take care of that the hard way.

As I said, it's not pretty, but if it gets the job done....

Hope this helps and let me know if you have questions/problems.

Posts: 534
Joined: Tue Jun 05, 2007 11:37 am
Location: SourceGear

Re: Merge single branched file

Post by jeffhostetler » Thu Oct 30, 2008 5:54 am

BTW, if you incrementally 'Save As' into core/file1, DiffMerge might
reload the left panel. If you find this annoying or disconcerting, you
can use the temporary file given in argv[6] in the left panel instead.

Also, once you get the 3-way merge window open, you can close the original
2-way diff window. The temporary files should persist until DiffMerge exits.


Post Reply