Wednesday, February 24, 2010

SVN Import in Place

One thing that irritates me about SVN is that the solution to every problem is to blow away your working copy and check out a new version. Of course this means you never really fix anything. But, that's not my concern today. Today the goal is to add an unversioned project to a repository without deleting anything.

We assume the project is on one server and the repository is another. We are going to use SSH as our transfer. The SVN server and client packages are loaded and configured.

First, prepare the directory structure on the repository.
svnadmin create --fs-type fsfs /svnrepos/target
Everything else is done from the project server.

Establish connection between project server and repository.
vi ~/.ssh/config
host websvn
  hostname websvn   # resoled in /etc/hosts
  port 22                     # relocate if public
  user svnuser           # change as needed
  IdentityFile ~/.ssh/svnuser_id_rsa
Test it:
ssh websvn uptime

Use a dummy directory to create the repository skeleton.
cd /tmp; mkdir /tmp/target; cd /tmp/target
mkdir trunk branches tags
svn import -m "Initilize" . svn+ssh://websvn/svnrepos/target

Delete the dummy.
cd ~; rm -rf /tmp/target/

Move to the project's root and do a checkout against the empty repository.
cd /var/www/target/
# never trust anyone... backup! backup! backup!
tar czf /tmp/emergency.tgz *
svn co svn+ssh://websvn/svnrepos/target/trunk .
ls -ld .svn
If you get an error, you forgot the dot in the SVN command.

Add the directories and check in the pre-existing files.
svn add ./*
svn ci -m "Inplace import"

Use your WebSVN interface to confirm the files are in the repository.

No comments:

Post a Comment