greenoldman
greenoldman

Reputation: 21082

What happened after svn switch and how to commit local changes?

I made some changes in my code and after that I decided the code is not good for trunk, but I should rather experiment a bit (with code) and later if I succeed I should go with trunk.

So I needed to create a branch -- I created new directory in branches, I copied svn copy the trunk to the newly created branch, and then I went to my source code directory and executed svn switch.

And at this point I don't understand what happened. svn traversed entire directory in similar fashion when I apply svn status, putting for most file A letter but for directories C, in summary I could read:

Updated to revision 1458.
Summary of conflicts:
Tree conflicts: 6

But when I checked some files I saw the files are (luckily) not updated really from svn repository (once again, after last commit I made changes to code and then decided to branch).

When I issue svn status now I can see for many entries info like for this directory:

A  +  C testsuite
      >   local edit, incoming delete upon switch

The steps I made I read on SO, and there was not mentioned such problems. So how can I commit my changes to branch now (of course I don't want to delete my changes).

Update: I found partial answer on SO, you can execute:

svn resolve --accept working ./*

to claim the local version files as OK. See: https://stackoverflow.com/a/2207119/210342

But it is not over, now I has this error:

svn: Did not expect '/media/wdisk/Projekty/MyProject
/MyProject.UnitTests/MetaData' to be a working copy root

Update 2: I didn't solve this as I would like. Instead I copied entire directory (local one), removed all .snv directories, I checked out the files from the branch, copied all local files over, and then I committed. This was seen by SVN as regular change, so it didn't trigger conflicts.

Upvotes: 2

Views: 5500

Answers (2)

Jyotsna Saroha
Jyotsna Saroha

Reputation: 678

Since your working copying is containing local modifications which you want to commit after testing them in a separate branch (feature branch - branching startegy :) ), on running the svn switch command you are getting a response similar to what you get when you run svn update, as svn switch also compares the working copy it is giving you response like some changes are in C (conflict state) and some are newly added (A).

The same scenarios are described in:

http://svnbook.red-bean.com/en/1.6/svn.branchmerge.switchwc.html

Have you ever found yourself making some complex edits (in your /trunk working copy) and suddenly realized, Hey, these changes ought to be in their own branch? A great technique to do this can be summarized in two steps:

$ svn copy http://svn.example.com/repos/calc/trunk \
http://svn.example.com/repos/calc/branches/newbranch \
-m "Create branch 'newbranch'."

Committed revision 353.

$ svn switch ^/calc/branches/newbranch

At revision 353.

The svn switch command, like svn update, preserves your local edits. At this point, your working copy is now a reflection of the newly created branch, and your next svn commit invocation will send your changes there.

Upvotes: 2

Lazy Badger
Lazy Badger

Reputation: 97365

You performed (and, BTW, describe pre-conditions) branching badly.

READ SVN BOOK!!!

"Made some changes in my code" isn't clear description of the state for repository and WC at this moment

If "after commit to trunk I decided the code is not good for trunk" you have (proper way):

  • Make server-side copy of trunk's HEAD to branch

svn copy URL/OF/TRUNK URL/OF/NEW/BRANCH -m "Branching latest state"

  • Remove commit(s) with "some changes" from trunk, i.e perform reverse merge of revision(s)

svn merge -c -REVNO . && svn commit -m "Undoing latest change"

  • Switch to branch

svn switch URL/OF/NEW/BRANCH

If "after local uncommited to trunk changes I decided the code is not good for trunk" you have (proper way):

  • Switch to branch

svn switch URL/OF/NEW/BRANCH

  • Commit changes

svn co -m "Starting point of featire"

Upvotes: 0

Related Questions