svnversion-controltortoisesvntortoisemerge

TortoiseSVN: Using Switch to Merge


I'm working with another team in the same central repository.

They have a branch (let's call it theirBranch) which I'm not allowed to edit (can view, checkout, just not change).

I have my own branch (myBranch) which started out as a copy of theirBranch. After checking it out and work on it, "working copy", I commit it back to myBranch when I've made significant changes to it.

The Goal: Merge any changes from theirBranch to myBranch.

1st Attempt - was to do a "merge of two different trees".

"This method covers the case when you want to merge the differences of two different branches into your working copy."

The Result - Any difference in the code was marked as a conflict even when the code was only changed by me since the initial creation of myBranch. Also, some added complexity, I had some tree conflicts because I deleted some files from myBranch that still exist in theirBranch. This tree conflict makes since to me.

Question 1: Do all tree conflicts need to be merged/resolved manually?

2nd Attempt - Use "switch" to merge theirBranch with myBranch. Switch back to my branch and commit.

As I understand it when working in the same repository on (2) different branches you can switch your repository branch that your working copy is linked to. When this is done any differences between your working copy and the new branch will be "merged" using "update".

From TortoiseSVN man:

Switch -

Just as “Update-to-revision” changes the time window of a working copy to look at a different point in history, so “Switch” changes the space window of a working copy so that it points to a different part of the repository. It is particularly useful when working on trunk and branches where only a few files differ. You can switch your working copy between the two and only the changed files will be transferred.

Update -

This Subversion command pulls down the latest changes from the repository into your working copy, merging any changes made by others with local changes in the working copy.

The Result - Any files that were different were replaced in my working copy by the "theirBranch" version of the file.

Question 2 - Why did the files get replaced instead of merged?

Question 3 - Why did theirBranch files that only existed in theirBranch get placed in myBranch and there wasn't a tree conflict?

Please feel free to answer any question you know the answer to or any advice on accomplishing my goal. Thank you.


Solution

  • First here is an analysis of what you tried:
    1) Merge of two different trees
    As indicated in https://tortoisesvn.net/docs/release/TortoiseSVN_en/tsvn-dug-merge.html, it may work for your case if:
    - you have working copy linked with myBranch
    - and you select merge FROM myBranch TO theirBranch in TortoiseSVN window (and not the opposite, as I suppose you did: it explains the conflicts you observed).
    However this kind of merge is useful when there is no merge-tracking feature that can be used, which is probably not your case.
    2) Switch command
    This is not a merge, but a resynchronization of your local working copy with another branch (in your case). So if you do not have any local changes compared to myBranch before the switch, you will not have any changes compared to theirBranch after the switch. It means your local files will be replaced, as you observed. This answers to your questions 2 and 3.
    Switch command is not a merge, and it could be quite dangerous to use it in your case (you could finally forget with which branch your local working copy is linked).

    Secondly, I recommend to use the "Merge a range of revisions" which seems well suited for your case. However it is still possible that you encounter tree conflicts: you will have to solve them manually, as all other conflicts. This answers to your question 1.