Jonathan Oxer
[Blog]
Blog > Cloning part of a Subversion repo
>> Cloning part of a Subversion repo
Sun, Feb 25th 1:36pm 2007: Linux
At IVT we have a few different Subversion repos for different purposes, including a catch-all that's just called "software" which is used for whatever random stuff people want to put in there. Typically little helper scripts and that sort of thing.
But every now and then one of those little throw-away things takes on a life of its own and grows into something more serious. That's happened a couple of times recently including with Release Monkey, which started out as a couple of helper scripts for package building but started getting a lot of attention (possibly because I wouldn't stop talking about it!) and we wanted to GPL it.
We created a new repo for it, imported the code as it stood at the time, and made it accessible. But that sucks, because all of a sudden thousands of lines of code appear magically as revision 1 and all the history of why things were done in that particular way is lost, at least to the outside world who can't backtrack through our internal "software" repo to see the real history.
So for Xen Image Manager I thought there had to be a better way: some way to extract the changes and history for just a specific subdirectory out of our "software" repo and use that to seed a new repo. Basically I wanted it to look exactly as if Xim had been developed in a dedicated repo right from the start.
And of course someone has already done the hard work and created the tool to help do exactly that: svndumpfilter.
Here's the recipe I used, just in case it's helpful to someone else.
Start by getting a complete dump of the original repo:
Filter that dumpfile to extract just the subdirectory you want:
You could just use that dumpfile and load it straight into a fresh repo if you want to, but if you're willing to get your hands dirty and tamper with the dumpfile it's possible to make the repo layout a bit neater and make it look like you had the foresight to put things in the right place the first time. In my case I had all the Xim code straight in a subdir in the repo instead of using sensible subdirs for trunk, tags, and branches, so I wanted to rename the existing subdir to "trunk".
Open up the dumpfile and look for the stanza that shows the subdir being added to the repo. In my case it looked like this:
I just renamed the Node-path value to "trunk".
Then go through the rest of the dumpfile and replace all path references ("%s/xenimagemanager/trunk/gc" did the job for me).
Now create a new repo to load everything into, and squirt in the dumpfile:
And you're done!
At IVT we have a few different Subversion repos for different purposes, including a catch-all that's just called "software" which is used for whatever random stuff people want to put in there. Typically little helper scripts and that sort of thing.
But every now and then one of those little throw-away things takes on a life of its own and grows into something more serious. That's happened a couple of times recently including with Release Monkey, which started out as a couple of helper scripts for package building but started getting a lot of attention (possibly because I wouldn't stop talking about it!) and we wanted to GPL it.
We created a new repo for it, imported the code as it stood at the time, and made it accessible. But that sucks, because all of a sudden thousands of lines of code appear magically as revision 1 and all the history of why things were done in that particular way is lost, at least to the outside world who can't backtrack through our internal "software" repo to see the real history.
So for Xen Image Manager I thought there had to be a better way: some way to extract the changes and history for just a specific subdirectory out of our "software" repo and use that to seed a new repo. Basically I wanted it to look exactly as if Xim had been developed in a dedicated repo right from the start.
And of course someone has already done the hard work and created the tool to help do exactly that: svndumpfilter.
Here's the recipe I used, just in case it's helpful to someone else.
Start by getting a complete dump of the original repo:
$ svnadmin dump software > software.dumpFilter that dumpfile to extract just the subdirectory you want:
$ cat software.dump | svndumpfilter include xenimagemanager > xim.dumpYou could just use that dumpfile and load it straight into a fresh repo if you want to, but if you're willing to get your hands dirty and tamper with the dumpfile it's possible to make the repo layout a bit neater and make it look like you had the foresight to put things in the right place the first time. In my case I had all the Xim code straight in a subdir in the repo instead of using sensible subdirs for trunk, tags, and branches, so I wanted to rename the existing subdir to "trunk".
Open up the dumpfile and look for the stanza that shows the subdir being added to the repo. In my case it looked like this:
Node-path: xenimagemanager
Node-action: add
Node-kind: dir
Prop-content-length: 10
Content-length: 10I just renamed the Node-path value to "trunk".
Then go through the rest of the dumpfile and replace all path references ("%s/xenimagemanager/trunk/gc" did the job for me).
Now create a new repo to load everything into, and squirt in the dumpfile:
$ svnadmin create xim
$ svnadmin load xim < xim.dumpAnd you're done!
[ Back to top ]