30

Currently I have a root-level repository set up for each project, like so:

Project1
Project2
Project3
Project5
Project5

I'd like to reorganise this so that rather than a repository for each individual project, I just have one for each logical grouping, and then the projects would just be folders within those 'group repositories', e.g:

WebSites
    Project1
    Project2
DesktopApps
    Project3
Libraries
    Project4
    Project5

Is this at all possible while retaining the history of the existing repositories? I've looked around quite a bit but all I can find is stuff on moving folders about within the same repository, and moving folders out of a repository into a new repository.

It's only for personal stuff anyway, so it's not the end of the world if it's just a straight 'no' - but it would be nice to know so I'm not just banging my head against a wall :)

Mark Bell
  • 28,985
  • 26
  • 118
  • 145

4 Answers4

25

You should be able to dump it, then reload it to a subdirectory of a new repository:

svnadmin dump http://oldrepo/ > mydump

svnadmin load --parent-dir my/new/folder http://newrepo/ < mydump

Steven Robbins
  • 26,441
  • 7
  • 76
  • 90
  • hotcopy is not a good idea if you are importing the files into an already existing repository where you want to keep the history of whatever was there before the import. "svnadmin dump/load" is the way to go. – Anders Sandvig Jan 26 '09 at 10:58
  • I've never trusted hotcopy to do anything.. I prefer the safety net of dump/load.. just giving him some options though :) – Steven Robbins Jan 26 '09 at 11:08
  • 5
    It appears no one actually bothered to try this. You cannot do an svnadmin dump on a URL. It has to be a local repository. – Baxissimo Mar 19 '09 at 01:46
  • Well actually, I did try it - it's just that I replaced the URL's with local paths without thinking (because I was working locally on the server machine). Maybe Steve can edit his answer. – Mark Bell Sep 30 '09 at 14:01
  • 1
    Since svnadmin works via direct repository access (and thus can only be used on the machine that holds the repository), it refers to the repository with a path, not a URL. – mac Jul 28 '14 at 14:07
  • 1
    Looks like a network aware version [svnrdump](http://svnbook.red-bean.com/en/1.7/svn.ref.svnrdump.c.dump.html) exists since 1.7 – bottlenecked Nov 30 '14 at 18:59
  • This can also load mydump into the sub-directory inside a big svn repo, using the same pattern. – CodyChan Jun 12 '17 at 09:48
11

svnbook: Migrating Repository Data Elsewhere

Karsten
  • 14,572
  • 5
  • 30
  • 35
  • 2
    [Link-only answers are not good answers](http://meta.stackoverflow.com/tags/link-only-answers/info). – Jonathon Reinhart Dec 15 '13 at 18:46
  • 3
    It wasn't a link only answer. Karsten let you know it was the svn book and gave the title of the chapter. It was terse and relevant. It's as "link only" as your comment is. – bryjohns Sep 15 '14 at 18:26
1

Since the accepted answer is incomplete and hasn't been corrected, here's how you actually do it.

(1) Your source repo is a single-project repo, with top-level dir foo. Go to your old server and create a dump file:

[old-server]$ svnadmin dump /path/to/old-repo > foo.dump

(2) Your target repo already contains two projects, with top-level dirs bar and baz, and is at http://new-server/svn. Now create an additonal foo top level:

[client]$ svn ls http://new-server/svn/
bar/
baz/
[client]$ svn mkdir -m "Adding new foo project" http://new-server/svn/foo
[client]$ svn ls http://new-server/svn/
bar/
baz/
foo/

(3) On your new server, the repo is at /path/to/new-repo (which is what http://new-server/svn/ maps to). Note that the svn mkdir above didn't actually create a new directory in /path/to/new-repo; it just changed the database. Go to the new server and

[new-server]$ svnadmin load /path/to/new-repo --parent-dir foo < foo.dump

Done, with complete history. You can now check out foo as:

[client]$ svn co http://new-server/svn/foo foo

If this is the first time you've done an svnadmin, you may find that you get file permission errors (txn-current-lock/etc) if, for example, the repo is owned by apache, and you're not in the apache group. The easiest fix is to add yourself to the apache group.

EML
  • 9,619
  • 6
  • 46
  • 78
1

You can use tailor to import the revisions into the new repository. It checks out the code from the old repository one revision after another and commits it to the new repository.

This can also be used to convert the history of one type of version control system to another.

An tailor project file would look like this:

[DEFAULT]
root-directory = /var/tmp/tailor
verbose = true

[myproject]
source = svn:oldrepo
target = svn:newrepo
start-revision = INITIAL

[svn:oldrepo]
repository = svn://oldhost.example.com/svnroot
module = trunk
subdir = repo-in

[svn:newrepo]
repository = svn://newhost.example.com/some/path
module = trunk
subdir = repo-out

If this file is called settings.cfg, this will copy /trunk of the old repository revison by revison to the new location:

tailor --configfile=settings.cfg myproject

The target repository needs to already exist and probably should have an empty trunk subdirectory.

sth
  • 222,467
  • 53
  • 283
  • 367
  • It should in theory also be possible to use tailor to do svn to svn, but I'm having trouble getting it to work. Why would you want to do that? Because svnadmin dump will only work on local repositories. You cannot dump a repo at a URL. – Baxissimo Mar 19 '09 at 01:54
  • I added an example configuration that works for svn->svn copying. I hope you can adapt it for your case with some tweaking... – sth Mar 19 '09 at 02:51
  • Where can I find tailor ? – Krunal May 31 '18 at 07:29