Home > Uncategorized > Using SVK to Synchronize SVN Repositories

Using SVK to Synchronize SVN Repositories

For any of you folks out there that have the unfortunate circumstance of having two SVN repositories which both have to be read/write, there is a way to easily do this using SVK.

I had some help on this from this article here: http://wiki.opengarden.org/User%3APeteE/Synchronizing_SVN_Repositories_With_Svk That article covers what to do if you are synchronizing only in one direction.  You can in fact synchronize in both directions, so here’s instructions with that in mind:

After downloading and installing SVK, initialize the default depot (storage location for SVK data):

svk depotmap –init

You can also make a separate depot specifically where you will keep the two repositories you are synchronizing.

svk depotmap /syncstuff/ c:\repo\syncstuff

Now, for some reason when I did this (hopefully some SVK guru can explain this and I’ll update the article), I had to manually copy the contents of my HOME_DIR/.svk/local folder into the path above (c:\repo\syncstuff\), otherwise it produced the error: Can’t open file ‘c:\repo\syncstuff\format’

Once that’s done, you use the mirror command to associate a path in SVK with a repot SVN repository.  You do this for each repository, e.g.:

svk mirror /syncstuff/mirror1 https://svn.mirror1.com/

svk mirror /syncstuff/mirror2 https://svn.mirror2.com/

The above commands only perform the association of the path in SVK with the remote repository – it doesn’t actually copy any data.

Use the sync command to synchronize each set of data (pull down each of the revisions locally into SVK):

svk sync /syncstuff/mirror1

svk sync /syncstuff/mirror2

While you could the next part in various ways, when I tried this I started with all of my files in the first repository (mirror1, let’s say) and the second repository was empty.  So the first task was to merge from mirror1 to mirror2.  When you do this you’ll want to include the –baseless options, which tells SVK that the source trees are totally different sets of information and we are going to sync them (as opposed to after you have synced everything up, you omit this flag to let SVK optimize what it’s doing since it now knows that these two trees were once the same and we’re just syncing new modifications):

svk smerge –incremental –baseless /syncstuff/mirror1 /syncstuff/mirror2

Then, you can merge in both directions like this:

svk smerge –incremental /syncstuff/mirror1 /syncstuff/mirror2

svk smerge –incremental /syncstuff/mirror2 /syncstuff/mirror1

You’ll end up with the same code in both places.  See below for caveats.


So far the only gotcha I’ve run into is that you have to resolve conflicts in both directions.  This can be painful if you have too many conflicts.  So far, it’s worked for me, with the conflicts being relatively minimal.

Bear in mind that conflicts are often the result of lack of coordination among developers, rather than technical issues (i.e. two people [re]writing the same section of a project is not a technical problem, it’s an administrative problem.).  At least that’s my viewpoint anyway.

Anyhow, if you’re looking for bidirectional SVN repository synchronization – hopefully this helps.


In the end, the project that this article was based on experience from eventually failed.  The conflicts got too far out of control and after spending scores of minutes resolving conflicts in both directions (which seem to start repeating again and again once things get out of sync) at each synchronize, I finally gave up.

Categories: Uncategorized
  1. Tyson
    September 24, 2008 at 12:36 am

    Did you intend on runing “svk mirror” with the exact same remote repository URL in both cases?

  2. September 24, 2008 at 1:20 am

    Tyson – Nope, that was an error. Fixed now; thanks.

  3. greg
    December 9, 2008 at 1:07 pm

    how about: “can’t find merge base for …. and ….”?

    • December 11, 2008 at 6:55 am

      Sorry Greg, no ideas off the top of my head. I was using this technique for a bit, but the project I was using it for kind of stalled and died, so I haven’t had my hands on SVK for a while.

  1. June 26, 2009 at 8:29 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: