Moving code from one SVN to another

I am currently working on merging some of the projects from two different SVN repositories to one repository. I don’t want to do a full dump of one and restore to the other, because the organization is a bit different in each. The solution is something like this:

  1. Dump the entire source repository
  2. Use svndumpfilter to split the dump into separate files
  3. Import each file separately into the right spot in the target repository

Here’s a couple one-liners to split the dump file (I love Unix):

$ cat source_repo.dump |grep -a ^Node-path: | grep -v / |uniq | sed “s/Node-path: //g” > projectlist.txt
$ for i in `cat projectlist.txt`; do cat svn_oasis.dump | svndumpfilter include $i > $i.dump; done

The first command creates a list of top level directories, and the second does the splitting. Now, you have a separate dump file for each different top level directory in the source repo. This can be tweaked if you want to split it based on different criteria.

Once you have the dump file for a project and you want to import it, you use a command like this:

cat project.dump | svnadmin load /usr/local/svn/myrepo

Make sure that the path you are importing doesn’t exist. I did not make sure, then I think svnadmin imported a bunch of stuff, but was unable to create the top level dir, so it probably left a bunch of orphaned crap in the repo. The load process seems pretty half baked, so be careful 🙂

Advertisements

One thought on “Moving code from one SVN to another

  1. Rom

    You probably want to sort before running uniq…. uniq only collapses adjacent lines, so the following would happen:

    A
    A
    B
    C
    C
    A
    B

    Would turn in to:

    A
    B
    C
    A
    B

    So not unique… adding | sort | before uniq would solve that tho.

    Then again maybe the list was already sorted by your dump, altho I wouldn’t risk it!

    Rom

    Reply

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s