tags:

views:

2231

answers:

3

After considering the answers to my previous question (One SVN Repository or many?), I've decided to take the 4 or so repositories I have and consolidate them into one. This of course leads to the question, what's the best way to do this?

Is there a way to combine two or more repositories maintaining the version history for both?

Edit: I should also point out that I'm using Assembla.com, which does not provide access to the svnadmin command, AFAIK

Another edit: Does this even matter? If svnadmin works on URLs, then it's no problem then.

+1  A: 

Yes, using svnadmin dump e svnadmin load.

Let's assume that you have to repositories, one with HEAD revision 100 and the other with HEAD revision 150.

You dump the first repository and load it in the new one: you end up with the full story of the first repository, from revision 0 to revision 150.

Then you dump the second repository and load it in the new one: it gets loaded with its full history, the only things that change are the actual revision numbers. The history of the second repository will be represented in the new repository from revision 151 to revision 250.

The full history of both repositories is preserver, only the revision numbers change for the repository that is imported for second.

The same of course applies for more than two repositories.

EDIT: I posted while you were editing, so I didn't see your note...

Davide Gualano
Just a quick note - it looks like a bit of Italian slipped through while you were writing your comment. That should be "and", not "e" :-)
Simon Howard
Eheh, you are right, sometimes my italian fingers types faster than my trying-to-be-english brain can handle :D
Davide Gualano
+12  A: 

Edit: Oh well, the question edit was made while I was typing. This is an answer to

Is there a way to combine two or more repositories maintaining the version history for both?


Assuming that

The existing repositories have a structure like:

  • repository root
    • branches
    • tags
    • trunk

and you want a structure something like:

  • repository root
    • projectA
      • branches
      • tags
      • trunk
    • projectB
      • branches
      • tags
      • trunk

Then for each of your project repositories:

svnadmin dump > project<n>.dmp

Then for each of the dump files:

svnadmin load --parent-dir "project<n>" <filesystem path to repos>

More complex manipulations are possible, but this is the simplest, most straightforward. Changing the source repository structure during a dump/load is hazardous, but doable through a combination of svnadmin dump, svndumpfilter, hand-editing or additional text filters and svnadmin load


Dealing with a third party provider

  • Request svnadmin dump files for each of your repositories. The provider should be willing/able to provide this - it is your code!
  • Create an SVN repository locally.
  • Perform the actions listed above for the dump files.
  • Verify the repository structure is correct with your favorite client.
  • Create a dump file for the combined repositories.
  • Request that the provider populate a new repository from this dump file.

YMMV: This seems to be a reasonable approach, but I've never worked with a third party provider like this.

Ken Gentle
that last bit is just what i was after! I was just about to give up on my chances when I read this. thanks.
nickf
If your subversion hoster uses subversion 1.4 or later you can always svnsync the repository to a local repository and (after syncing) dump that database.
Bert Huijben
And some subversion providers (e.g. Google Code) allow svnsyncing /to/ a repository. So you can upload the result with svnsync there after performing the merge somewhere else.
Bert Huijben
Be sure you create an empty "project<n>" directory in your destination repository before running "svnadmin load --parent-dir "{project[n]}" {filesystem path to repos} < {filesystem path to dmp}".
Aaron Greenlee
+1  A: 

If you don't have access to svnadmin, it would be hard but doable. Let's say you have repositories A and B, and want to merge them into repository C. Here's the steps you would have to use to accomplish this.

  1. Check out revision 1 of repository A to your hard disk.

  2. Create a directory, called Repository_A on the root of your C repository, and check this out to your local hard disk.

  3. Copy the files from your check out of A (minus) the .svn files, to your checkout of C, in the Repository_A folder.

  4. Perform a Commit on C.

Update your working copy of repository A to revision 2 , and perform steps 3 and 4, and repeat with each successive revision until you reach the head.

Now do the same with B.

This would basically do the same as @Davide Gualano was suggesting, without requiring svnadmin. You could probably write a simple script to do this for your, of if there aren't a lot of revisions, you could just do it manually.

Kibbee
Yes, the final result will be the same as the solution using svnadmin dump and load, but it will propably take lots of time.
Davide Gualano