2

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.

Community
  • 1
  • 1
greenoldman
  • 16,895
  • 26
  • 119
  • 185

2 Answers2

2

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.

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jyotsna Saroha
  • 678
  • 6
  • 13
  • Not exactly, after `svn copy` and `svn switch` trunk and branch are the same, but my working copy (i.e. local disk) has newer files. And I cannot commit -- `svn: Aborting commit: '/media/wdisk/Projekty/MyProject/MyProject.UnitTests' remains in conflict`. – greenoldman Mar 24 '14 at 08:47
  • To commit your changes to branch you need to resolve the conflicts which are getting highlighted only then your local changes (which you want to test) will move to branch . There could be two case 1. You created the branch first from the trunk and then done changes to the file and then commit it (in that case there will be no conflicts ) 2. Your case where you first made local modification and then created the branch after which using svn switch (which is smiliar to performing svn update on working copy with local modification ) you are suppose to get the conflicts . – Jyotsna Saroha Mar 24 '14 at 09:02
  • My case is exactly as you quoted "Have you ever found...", and I did exactly those steps. How do I tell my local files have higher priority and should go to repository (repo is already switched to branch)? – greenoldman Mar 24 '14 at 09:06
  • 1
    You can use svn resolve command with mine-full option which will give priority to your changes and will move them to branch .$ svn resolve --accept mine-full foo.c . http://svnbook.red-bean.com/en/1.6/svn.ref.svn.c.resolve.html – Jyotsna Saroha Mar 24 '14 at 09:12
  • 1
    Hi can you please try using command **svn resolve --accept mine-full** instead of **svn resolve --accept working** as it needs manually handling the conflicts resolution. – Jyotsna Saroha Mar 24 '14 at 09:33
  • `svn resolve --accept mine-full .` did nothing (appending `/` at the end does not help either). The conflicting directories are still in conflict. – greenoldman Mar 24 '14 at 09:49
  • Hello Since you mentioned conflicting directories (tree conflicts) following link looks having the similar issue where **svn resolve --accept working -R ** is used . http://stackoverflow.com/questions/12559929/resolving-tree-conflict.Please delete conflicts markers if any. – Jyotsna Saroha Mar 24 '14 at 09:57
  • Thank you, but no matter what the method, this leaves me with "Did not expect XXX to be a working copy root". From what I found it seems more like SVN bug. – greenoldman Mar 24 '14 at 10:00
  • Hi is there any .svn dir beside working copy . Similar issue http://stackoverflow.com/questions/8068923/svn-did-not-expect-to-be-working-copy-root . Fix on http://mail-archives.apache.org/mod_mbox/subversion-dev/201002.mbox/%3C4B73FDEB.8060603@elego.de%3E – Jyotsna Saroha Mar 24 '14 at 10:05
0

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"

bahrep
  • 29,961
  • 12
  • 103
  • 150
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110
  • I did exactly what you described, without merge, because I didn't commit any experimental changes into trunk. I cannot commit though `svn: Aborting commit: '/media/wdisk/Projekty/MyProject/MyProject.UnitTests' remains in conflict`. – greenoldman Mar 24 '14 at 08:46
  • @greenoldman - you **can't have any conflicts in your WC** if you use my Way2 **exactly as written**: conflicts are result of no-brain update attempt. And at last, you can **MUST** remove scrap and mark correct files as resolved before commit - it's common rule in SVN "don't commit WC with conflicts" – Lazy Badger Mar 24 '14 at 09:31
  • Way2 = "after local uncommited to trunk..."? I did this. I had conflicts. Since I have backup files, I repeated those steps and still -- conflict. – greenoldman Mar 24 '14 at 09:47