Step by step: Moving code between Subversion repositories
Posted on 2008-07-23 - Comments
As many coders will tell you, there reaches a point where you realise that you absolutely, positively must keep your code in a a revision control system. In my working life, I’ve used Microsoft’s ageing SourceSafe and more recently the vastly superior SubVersion (SVN).
There’s many powerful GUIs out there which you can use to interact with SVN, and make the checking out and checking in very easy. If you primarily use a desktop GUI (like me), then chances are you use a SVN client GUI to interact with SVN on a day-to-day basis.
But what happens when you need to move code between repositories?
I first realised I needed to reorganise my repositories when my single "clients" repository was growing unwieldy. It was one large repository, with all my client work organised into folders by the project name. This method keeps things very tidy, but increments the version numbers with every commit on every project and means you have a very long root log.
A better way, I realised, is to keep the unrelated projects organised in their own repositories – but how to move the code out of my client repository into a new one?
To do this, you’ll need shell access to your SVN server (surely you do – otherwise, how do you create your repositories?)
SVN provides the
svnadmin dump command to export data from your repository.
In my case, to dump the contents of my entire clients repository, I did the
svnadmin dump clients > clients-dumpfile
which creates a text file called clients-dumpfile containing all the revision data for my clients repository. Note that this can create a very large file, as it’s not stored in the ultra-efficient space-saving SVN database any longer.
Say I want to move all my code from a folder called client-1, and put it in its own repository. First thing I need to do, is to create the destination repository:
svnadmin create client-1-repository
Now – the dumpfile contains all the code for all the projects, so how do I filter out the other projects? (this is all one line)
cat clients-dumpfile | svndumpfilter include client-1 --drop-empty-revs --renumber-revs > client-1-filtered-dumpfile
What does this do? It takes the previously created
clients-dumpfile and sends
it through the
svndumpfilter program. I’ve told it to include the
folder (and throw away everything else). I’ve told it to drop the empty
revisions left behind by the thrown away data, and renumber the rest of the
revisions so my new repository is nicely sequentially numbered. The results
from svndumpfilter are output into a new file called
Finally, you simply load the data into the new repository:
svnadmin load client-1-repository < client-1-filtered-dumpfile
Hopefully, you now have a populated repository with your clients' code.
- Next generation console wishlist 2013-02-18
- Digital conversations preserved 2011-02-21
- Pastel de Nata recipe 2011-01-10
- Fixing a bricked D-Link DSL-G624T 2010-01-22
- Learning PHP - Part 6: functions 2009-11-03
- Learning PHP - Part 5: your first dynamic web page 2009-11-03
- Learning PHP - Part 4: controlling flow 2009-11-02
- Symptoms of a Wordpress hack 2009-11-02
- Learning PHP - Part 3: array basics 2009-10-26
- Learning PHP - Part 2: variable basics 2009-10-25
- Learning PHP - Part 1: introduction 2009-10-24
- Unsetting HTTP headers in PHP 2008-08-06
- Intermittent 1px gap in Firefox 3 2008-07-30
- Understanding Linux file permissions 2008-07-29
- Step by step: Moving code between Subversion repositories 2008-07-23
- Novell client on OpenSuse 10.3 2007-10-08
- Removing Windows from Apple's Bootcamp 2007-10-01
- HTTP authentication in PHP 2007-06-12
- Microformats and me 2007-06-11