At this moment, I am the only person working on a project in svn. To stay legit, I am suppose to make changes to a branch and then merge those changes into trunk: so my branch and trunk are basically identical. Currently I have two working copies, one for the branch and one for trunk. I make the changes to the branch working copy and commit those, then I perform an svn merge on the trunk working copy from the branch location and then commit those changes. Question: can I change my process so that I only have one working copy and switch between the branch and trunk as follows?: 1) switch to branch, make changes and commit. 2) switch to trunk, commit. 3) repeat.
Yes you can do this, using svn switch
.
If your working copy is currently from the branch, and you've committed your changes to the branch:
svn switch svn://server/path/to/repo/trunk
Then to go back to the branch:
svn switch svn://server/path/to/repo/branches/xxx
You can with one additional step.
1) switch to branch, make changes and commit. 2) switch to trunk, svn merge commited branch changes, commit. 3) repeat.
As the previous answers suggest, it is possible to stay with a single working copy by switching back and forth. There's nothing technically wrong with it, the operation is semantically identical. However, I would stay with the two working copies due to the following reasons:
- You would still have to svn merge the changes after the switch, because the switch reverts the (now committed) changes, as pointed out by the first answer.
- You can't avoid the merge by quickly copying your changes back after the switch, because the merge operation records meta data for the commit (svn:mergeinfo in svn >= 1.5, as linked in comment by Richard Fearn).
- With separate working copies, you have a 'clean' test environment for the branch, without your unversioned/uncommitted trunk changes.
- If you have uncommitted changes in your trunk working copy because you are working on the trunk when you need to fix the branch, there's a risk you accidentally commit something that was not supposed to be part of the fix. Twice - first in the branch commit, then in the trunk commit.
The only downside to having two working copies (at least that I can see) is that you may have to do an svn update before making the fix. You didn't mention your reason for wanting to change your process?