tags:

views:

481

answers:

5

I want to copy the trunk of one project to another, so I use the following command:

svn copy -m "test" (url of project from)/Trunk/ (url of project to)/Trunk/

The files ended up in (url of project to)/Trunk/Trunk/ instead of (url of project to)/Trunk/ where I want them to go.

Have I done something wrong? What should I do if I do if I want the files in (url of project to)/Trunk/? Doing the the following does not seem to make sense:

svn copy -m "test" (url of project from)/Trunk/ (url of project to)/

+1  A: 

You should do svn copy -m "test" (url of project from)/Trunk/ (url of project to)/ to copy the trunk to project to, since you are copying the whole folder.

I'm not sure if wildcards are allowed in svn copy, to do something like /trunk/*, you should check the docs.

pgb
Thank you. Just confirmed that svn does not do wildcards. What a pain!
Andy
A: 

If something in your destination already exists you need to delete it before copying there something else. It is also possible that svn copy isn't the right thing to do in your case but it's hard to guess.

Gleb
Thank you. This is one of the reasons why I find svn so difficult to use at the moment.
Andy
A: 

I had this problem a bunch when I started with SVN.

IMHO, you are probably getting confused in your URLs and your working directory. If you branch with

svn copy -m "I want a branch man" http://theproject/proj/trunk http://theproject/proj/branches/today

then trunk will end up in today, which is what you want. Then when you switch you would use

svn switch http://theproject/proj/branches/today .

But the way you specified it, the whole thing would be different

svn copy -m "I need another trunk yo" http://theproject/proj/trunk http://theproject/anotherproj/trunk

then you would need to switch to the right dir

svn switch http://theproject/anotherproj/trunk .

I use period in the examples above, but you have to be careful about going to the right place...

In other words, this trunk/trunk thing happens all the time, but when you examine your repository URLs and working directory (use SVNX on OSX or TortoiseSVN on Windows), you will see that it's just your confusion :)

Yar
+1  A: 

Also, while creating a branch (or "branching", which to svn, is just a fancy term for copy), if you be proactive and first create the branch directory you get the same problem.
Suppose you want to move from your old "single-directory" approach to the "trunk-branch" approach.
You start with http://my/path
and want to go to a structure like this:
http://my/path/trunk,
http://my/path/branches/foo and
http://my/path/branches/bar

So if you first create the branch directories:
# svn mkdir http://my/path/branches
# svn mkdir http://my/path/branches/foo
# svn mkdir http://my/path/branches/bar
And then try this:
# svn copy http://my/path/trunk http://my/path/branches/foo

'trunk' gets copied into the branch:
# http://my/path/branches/foo/trunk/...

If you try to use wildcards, well, wildcards don't work:
# svn copy http://my/path/trunk/* http://my/path/branches/foo

The only way it all works is to NOT mkdir branches/foo but directly do this:
# svn copy http://my/path/trunk http://my/path/branches/foo

This works.

namespaceform
A: 

What happened with me was the desitnation path exists as a result SVN was copying inside the directory

I deleted the destination directory performed a copy and that seemed to do the job.

Maybe i should have done svn copy with force option but i went svn rm and then svn copy.

Jet Abe