Search this site


Metadata

Articles

Projects

Presentations

Merging multiple svn repositories

Over the past several years, I've used mainly CVS. I tried switching to subversion, which has been slow-going. To speed that process, I merged all of my repositories together into one svn repo. I also used cvs2svn.py to convert everything in cvs to svn, which put everything into /trunk/ in the repository - not what I wanted. A simple script fixes that:
repo=file:///path/to/repo
svn ls $repo/trunk | xargs -I@ -n1 svn mv $repo/trunk/@ $repo/@

I used svn poorly at first - one repository per project. To fix that, I needed to dump all of them (with svnadmin) and load them into a central repository:

# svnadmin dump all of my svn repositories
repodir="/home/foo
for i in $repodir/SVN/*; do 
  echo $i;
  svnadmin dump $i > $(basename $i).dump
done
# load all of my dumpped repositories into the new one
repo="/home/foo/NEWSVN"
svnadmin create $repo
for i in *.dump; do 
  proj="$(echo $i | cut -d. -f1)";
  svn mkdir -m "mkdir $proj for import" file://$repo/$proj
  svnadmin load --parent-dir $proj $repo < $i
done

3 responses to 'Merging multiple svn repositories'

Showing last 3 comments... (Click here to view all comments)

Colin wrote at Sun Mar 25 13:51:40 2007...
This has saved me a lot of time, thanks soooo much. Glad to know I'm not the only muppet who started out with a repository per project.

Thanks, Colin =)

feto wrote at Mon Jul 30 09:53:50 2007...
Does this way save all the repositories history as well?

Jordan Sissel wrote at Mon Jul 30 13:04:15 2007...
@feto,

Yep. That was one of my requirements. History of each repository is maintained and imported into the new, single svn repo.


Leave a reply

You need javascript enabled to use this form. Anti-spam efforts ongoing. Also, if the comment doesn't show up, it's because the form expired. Go back and copy your comment, reload the form, and resubmit. Apologies if this is a hassle, I'm just playing with antispam methods right now. If this insists on not working, please email me about it.

Name (required)
E-mail (optional, if you want me to be able to email you back)
URL (also optional)
Comment: