tags:

views:

100

answers:

1

Hi all,

I've got an svn repo with no trunk dir. I'd like to create the trunk and branches dirs, and move all my files (currently in the root) into trunk.

Creating trunk works just fine:

macbook[601]  # svn mkdir trunk
A         trunk
macbook[602]  # svn commit trunk
Adding         trunk
Committed revision 67.

moving everything into trunk fails:

macbook[604] # svn move * trunk
svn: Cannot copy path 'trunk' into its own child 'trunk/trunk'

is there a way to do this without giving it all the file and dir names individually? There are threads describing how to do this with TortoiseSVN, but i'd like to know the right way to do it with the svn commandline.

Thanks.


EDIT:

W. Craig, thanks for your quick and helpful answer.
I did run into some complications; perhaps someone can give me a bit of advice about how to resolve them.

I started out with everything up to date, including an empty "trunk" directory. I also had several files that are not managed by SVN:

note: Prior to attempting this, I moved some files into the "notes" subdir and successfully committed that change. I can give more details if that's helpful.

macbook[582] ~/dev/dictionary # svn stat
?       vendor/plugins/redbox_broken
?       config/database.yml
?       lib/dict.rb.original
?       public/javascripts/redbox.js.big
macbook[583] ~/dev/dictionary # ll
total 64
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 MISC
-rw-r--r--   1 stupakov  stupakov  10011 Oct 18  2009 README
-rw-r--r--   1 stupakov  stupakov    307 Oct 18  2009 Rakefile
-rw-r--r--   1 stupakov  stupakov   9514 Jun 17 22:05 TO_DO.txt
drwxr-xr-x   7 stupakov  stupakov    238 Mar 11 21:07 app
drwxr-xr-x  11 stupakov  stupakov    374 Jun  5 16:02 config
drwxr-xr-x   7 stupakov  stupakov    238 Jun 17 22:05 db
drwxr-xr-x   4 stupakov  stupakov    136 Oct 18  2009 doc
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 features
drwxr-xr-x  17 stupakov  stupakov    578 Jun 17 20:51 lib
drwxr-xr-x   4 stupakov  stupakov    136 Apr  4 20:04 log
drwxr-xr-x   6 stupakov  stupakov    204 Oct 18  2009 nbproject
drwxr-xr-x   9 stupakov  stupakov    306 Jun 17 21:55 notes
drwxr-xr-x  11 stupakov  stupakov    374 Oct 18  2009 public
drwxr-xr-x  15 stupakov  stupakov    510 Oct 18  2009 script
drwxr-xr-x  13 stupakov  stupakov    442 Oct 18  2009 spec
drwxr-xr-x   7 stupakov  stupakov    238 Oct 18  2009 stories
drwxr-xr-x   9 stupakov  stupakov    306 Oct 18  2009 test
drwxr-xr-x   7 stupakov  stupakov    238 Feb 17 22:46 tmp
drwxr-xr-x   3 stupakov  stupakov    102 Jun 17 22:05 trunk
drwxr-xr-x   5 stupakov  stupakov    170 Apr  3 20:10 vendor
-rw-r--r--   1 stupakov  stupakov   1151 Sep 26  1998 whale.gif
macbook[584] ~/dev/dictionary # ll trunk

I attempted to "svn move" everything into trunk.

macbook[585] ~/dev/dictionary # echo $(cat ~/flist)
README Rakefile app config db doc features lib log nbproject notes public script spec stories test tmp vendor whale.gif
macbook[586] ~/dev/dictionary # svn move $(cat ~/flist) trunk

The response from SVN was a long list of files scheduled for addition and deletion.

I then got a failure when trying to commit this.

macbook[589] ~/dev/dictionary # svn commit -m "moving everything to trunk subdir"
Deleting       README
Deleting       Rakefile
Deleting       app
Deleting       config
Deleting       db
Deleting       doc
Deleting       features
Deleting       lib
Deleting       log
Deleting       nbproject
Deleting       notes
svn: Commit failed (details follow):
svn: Item '/dictionary/notes' is out of date

And now the "notes" dir has a conflict

macbook[597] ~/dev/dictionary # svn stat notes
D     C notes
      >   local delete, incoming edit upon update
D       notes/HACKATHON
D       notes/newsgroup_questions.txt
D       notes/svn_rails.sh
D       notes/mysql_notes.txt
D       notes/HOW
D       notes/css_notes.txt

I attempted to update "notes" to an older revision, but the conflict did not allow that:

macbook[606] ~/dev/dictionary # svn up notes -r 68
   C notes
At revision 68.
Summary of conflicts:
  Tree conflicts: 1

Then I attempted to "svn resolve" the conflict:

macbook[612] ~/dev/dictionary # svn resolve --accept=working notes
Resolved conflicted state of 'notes'
macbook[613] ~/dev/dictionary # ll notes
macbook[614] ~/dev/dictionary # svn stat notes -v
D               68       70 stupakov     notes
D               70       70 stupakov     notes/HACKATHON
D               70       70 stupakov     notes/newsgroup_questions.txt
D               70       70 stupakov     notes/svn_rails.sh
D               70       70 stupakov     notes/mysql_notes.txt
D               70       70 stupakov     notes/HOW
D               70       29 stupakov     notes/css_notes.txt

I figured I should revert rather than committing the scheduled move in case something else was messed up, so I did this:

macbook[630] ~/dev/dictionary # svn revert .

However, the adds and deletes are still scheduled.

I'd appreciate any suggestions for how to do the following:

1) Bring my local copy to the state it was in before doing "svn move list_of_dirs trunk"

2) Ensure that the "notes" dir is up to date and does not interfere with the "svn move"

3) Successfully move all dirs from my root dir into "trunk"

Thanks very much.

+2  A: 

You're using a MacBook, so let's assume bash for your shell:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
svn move $(cat /tmp/files) trunk

This will work as long as you don't have spaces in your file names. If you do, then use this instead:

# Select all the relevant files/directories (less trunk, branches, and tags)
ls * | egrep -v "trunk|branches|tags" > /tmp/files

# Move them within the repository
cat /tmp/files | while read file ; do
    svn move "${file}" trunk
done
Craig Trader