Archive

Archive for June, 2008

Using SVK to Synchronize SVN Repositories

June 3, 2008 5 comments

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.

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.

Update:

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.

Advertisements
Categories: Uncategorized