Lobo
Lobo

Reputation: 566

SVN switch overwrites Working Copy

I've just started using SVN and just encountered a strange problem with SVN switch that I haven't been able to find a answer to. Long story short: I had a working copy of the latest version of my application that I had stored in /my repo/tags/versionnumber. Did some bugfixes and planned to do a checkin to Trunk to deploy it to my stage-environment.

However, upon doing a svn switch it did not only change the repo path to /my repo/trunk/ but proceded to do a checkout (or something) and overwriting my local changes. Both the trunk and the tag also has the same revision number, which shouldn't be possible according to what I've read.

The following is an example output (translated from swedish so if anything sound strange you know why):

>svn info
>
>URL: svn+ssh://user@server/my repo/tags/versionnumber
......
>Revision: 8
.....
>Latest change in revision: 6

> svn switch svn+ssh://user@server/my repo/trunk/
> password ********
>
>D    log
>D    logparse.php
>U    document_root/js/standard.js
......
>Updated to revision 8
>
>svn info
>URL: svn+ssh://user@server/my repo/trunk
......
>Revision: 8
.....
>Latest change in revision: 8

The same will happen when I switch back. It will then add the files that it previously deleted (if they exist in trunk) and "update" the files that exists in both.

Upvotes: 0

Views: 1242

Answers (1)

Luke Mills
Luke Mills

Reputation: 1616

That's the intended behaviour of svn switch. What it does is switch your working copy to the HEAD revision of the branch that you're switching to (essentially a checkout of the branch over your current working copy).

If you have local changes that don't conflict with anything on the branch you're changing to, then they'll be left alone. If there are conflicts then svn will tell you.

When you make a commit and the revision number is incremented, that revision number is the new revision number for the entire repository, not just the branch you're working on. That's why the trunk and the tag have the same revision number. This is also the intended behaviour for svn.

Have a look at this book for more details: http://svnbook.red-bean.com/ (Free online versions available).

Upvotes: 1

Related Questions