Jan Hudec
Jan Hudec

Reputation: 76276

Do a merge in subversion but don't record mergeinfo

I need to apply only some changes from one branch to another. Because they are not well split to commits, I need to merge the branch and manually revert the ones that are not appropriate. But when I do that, I need to not record the mergeinfo, because they are no longer true when I only commit part of the merge. How can I revert metadata change and leave the text changes?

Given that there are many spurious mergeinfos in the tree (there should only be one, in the root directory, but due to various quirks, mistakes and bugs there are many more) not only on directories, but even on files that have also text changes, I can't simply do a non-recursive revert on directories only.

I suppose I can always write something like

svn propset svn:mergeinfo "$(svn propget svn:mergeinfo "$file") "$file"

Wrapped in a for loop across status it's going to be rather complicated, so I am looking for something simpler.


Basically the situation is like this. I have branches general and temporary. And some changes were done on temporary that should have been on general, but are mixed with others that shouldn't. So I need to run a merge from temporary to general, pick only the changes I want and commit. But since temporary tracks general, I must not commit the merge info, because if I did, the reversion would be an intended change and would merge to temporary.

Upvotes: 0

Views: 954

Answers (1)

Ben Reser
Ben Reser

Reputation: 5765

Just run svn revert on the directory or directories that have svn:mergeinfo property changes. Don't use the -R flag so it won't recurse and won't remove your other changes.

In your case you're applying a bunch of partial changes. Which means mergeinfo will likely end up on a lot of individual files. One workaround this case is to use svn diff to select the changes you want, store it in a file and then use that file to run svn patch. If you don't know which changes you want that'll create some burden and if you're merging tree changes (not just file or property changes) then diff and patch isn't good enough.

If you're only applying partial changes why not just let Subversion deal with the mergeinfo for you? Your goal of removing the mergeinfo would appear to be to allow the other parts of the revision to be merged in properly later. Merge should be able to deal with that and if it isn't that's a bug and should be reported.

Short of those two options you're probably just going to have to edit manually. Maybe you should present your case and ask for revert to accept an option to only apply to properties to the [email protected] list.

Upvotes: 1

Related Questions