Search code examples
svnconflicttree-conflict

SVN switching to a branch that is older than the working copy


I made changes to my working copy of the trunk. Then, I wanted to switch to a different branch so that I could commit to it. I did, and now my project is a mess. The branch I switched to was behind the trunk and was missing files to which I made modifications. Frustrated, I switched back to the trunk.

Now I have tree conflicts in several places that say "local edit, incoming delete upon switch." I can't commit these because of the conflict. The only option I can see is to revert my local changes, or basically re-checkout the entire project and lose all my changes.

Another problem - I reverted (and deleted) one of the folders that had such a tree conflict. So now, I can see that folder exists on the repository, but it's gone from my local project and updating does NOT bring it into my working copy. What's happening here? 1. It exists on the repo, 2. it does NOT exist in my working copy because I just deleted it, and 3. updating does NOT bring it into my working copy. Why is this?

Why is this so hard? I have local changes, and I want to commit them. I don't see why it matters that I switched to another branch and back again. If the file doesn't exist on the branch I switch to, why can't I just commit my file to the branch so that it does?

Here's what eclipse is giving me for one of the tree conflicts, which was a local change to a file that didn't exist on the branch I switched to. I'm assuming it wanted to delete the file when I switched because it wasn't in the branch. So how do I fix this now? Really what I want to do is add it to the branch and commit my changes, but I can't because there's a conflict now!

Resolve Tree Conflict on my_jsp.jsp
Conflict Description:
local edit, incoming delete upon switch
Source left: (file) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@349
Source right: (none) https://......./WebContent/WEB-INF/jsp/my_jsp.jsp@353

The only options it gives me is to revert, remove or compare, all of which are unacceptable. I have lots of local changes!


Solution

  • For your first problem:

    One thing you could do is make a patch of your current changes, then revert back to the trunk and apply your patch. If you're running linux the commands would look something like

    svn diff > ~/patch.diff
    svn switch svn://path/to/trunk
    patch -p0 < ~/patch.diff
    

    That should get you back to more or less where you were (hopefully). If you're not running linux, there should be similar commands in Eclipse or SVNTortoise. When you want to go to the new branch, make a diff again just to be safe. You might have to make the changes manually if it's really far behind, or make sure you merge the branch with trunk first (if that's an option).

    For your second problem:

    I think I've seen something similar but I don't recall what the issue was. Have you tried svn up <file_name> to just update the missing file?