views:

222

answers:

4
+2  Q: 

Svn Repo Syncing

I would like to keep a copy of a 3rd parties code in my SVN repo. (so I can run reports and tests)

How could I sync a certain folder / path from their repo into mine?

Obviously I can't just do an export from their repo and commit to mine because this would miss deletes.

Extra cool points for an automated solution.

svn:externals could be used, but would not be ideal. If the 3rd party repo was switched off, I wouldn't have access to the code.

Thanks,

+4  A: 

If the 3rd party code resides in the SVN repo, you can use svn:externals property.

Eugene Morozov
This doesn't keep it in his repo. svn:externals is just a slightly-more-automated way of doing an svn checkout from the remote repo in a certain place.
Curt Sampson
A: 

You should probably make a mirror of SVN using some DVCS tool like Mercurial (using hgsubversion or hgsvn) or Git (git-svn).

stepancheg
A: 

I'm thinking svk might be able to do this. You would set mirrors for both your source and target repositories, and have two check-outs pointing to the same location.

Then just pull from the source repository and push to the target... or something like that.

And you should be able to automate it with a shell script run by a cron job.

Evan
+2  A: 

I do exactly this with svk.

There's some documentation on mirroring and svn repo with svk but it's not very good; perhaps this summary of the procedure will help.

  1. Set your SVKROOT environment variable to an appropriate path for your svk repo, if you don't want it in the default location under your home directory. Note that this will contain everything you ever do with svk, including mirrors of multiple svn repos, so it can get quite large.

  2. svk init to initialize the repo. You should be asked if you want to initialize it (if it doesn't already exist). You may also get an error message after that, "Command not recognized, try /usr/bin/svk help."; this seems to be a harmless bug.

  3. Set up your mirrors giving the path to the repo you want to mirror, and the path within your svk repo where you'd like to place the mirror, e.g.:

    svk mirror sv+ssh://foo.com/data/repo/head/project //mirror/foo.com/project svk mirror sv+ssh://bar.com/data/repo/head/funstuff //mirror/bar.com/funstuff

  4. Run svk sync -a to synchronize all mirrors. This is what you run whenever you want to update your copy to the latest version from the mirrored repos.

    If you get an error the first time about the Time::Progress module being missing, you're probably using a recent version of Fedora, Ubuntu, or another distribution with a broken svk package. There are some workarounds for this; I simply did sudo cpan Time::Progress to grab what I needed from CPAN.

  5. Do an svk co /mirror/foo.com/project to get a checkout of your project. You'll have full history and everything else of course, just using the svk command instead of the svn command.

Curt Sampson