Jason S
Jason S

Reputation: 189686

right way to merge one file from two unrelated branches of SVN

I have two closely related C projects that are checked into SVN (but are not branches of a common ancestor). Let's call them Foo and Bar. They each contain a file "user_param.h"

I would like to merge file "user_param.h" from the Foo project into the "user_param.h" of the Bar project. I want to do the text merging manually, but I would like to record merge information so that I have some traceability to this other branch.

I know how to do normal merges from trunk to branch or back, but not sure how to do this.

What's the right way to do this kind of merge?

Upvotes: 3

Views: 1538

Answers (1)

janos
janos

Reputation: 124646

If the two branches don't have a common ancestor, Subversion will refuse the merge, you will get something like this:

$ svn merge ^/path/to/other/user_param.h
svn: E195016: 'file:///.../path/to/other/user_param.h@19' must be ancestrally related to 'file:///.../path/to/this/user_param.h@18'

So, it's not really possible. I think you have no choice but to copy the file by hand.

If you want some sort of traceability, maybe you can record a Subversion property, for example:

svn pset fake:mergeinfo /path/to/other/user_param.h:18-19 user_param.h

This mimics the svn:mergeinfo property set by Subversion when the merging works, between related branches. This property is just to have some sort of traceability as you asked, other than that it will have no function and it will not affect Subversion operations in any way.

As @BenReser pointed out in comments:

You can use --ignore-ancestry to merge unrelated files but you won't get merge tracking

Upvotes: 3

Related Questions