Synchronizing SVN Repositories With Svk

    SVK is a distributed source control management system.  At MindTouch, we use svk to mirror the public parts of our MindTouch svn repository to our public svn repository at SourceForge.net.  Below is a brief tutorial on how we use SVK to do our mirrorring.  Since the MindTouch repository requires authentication, you won't be able to use this tutorial unless you have credentials.  However, it's a good real-world example.

     

    Initialize the Depot

    svk depotmap --init
    

     

    Create the mirrors

    NOTE: you'll be prompted for credentials for the MindTouch SVN repository.  The SF.net SVN repository only requires credentials in order to commit changes so you'll be prompted for credentials when performing a merge operation.

    svk mirror //mirror/public-source https://svn.mindtouch.com/source/public/
    

    svk mirror //mirror/public-target https://dekiwiki.svn.sourceforge.net/svnroot/dekiwiki/public

     

    Sync the mirrors

    svk sync -a

    Now go and get a cup of coffee, bake some brownies, and walk the dog.

    Once the sync has been completed, you can perform merges between the two mirrors.  The first merge needs to be performed manually (since you'll be prompted for credentials), but svn will cache the credentials so subsequent merges can be done via cron.

     

    Merge the private repository into the public repository

    svk smerge --incremental --baseless //mirror/public-source //mirror/public-target

     

    Create the cron job

    Create a script named sync_svn.sh:

    #!/bin/bash
    

    svk smerge -IB //mirror/public-source //mirror/public-target svk sync -a

     Make the script executable

    chmod +x sync_svn.sh
    

     Add it to your user's crontab

    crontab -e

    Add the cron entry

    */10 * * * *  /home/petee/sync_svk.sh 
    

     

    Additional Notes

    UTF-8 support

    If you're using files with UTF-8 characters, make SURE you have a UTF-8 local installed and have your LANGUAGE environment variable set.  If you don't, you will see an error message like:

    Use of uninitialized value in join or string at (eval 46) line 2.
    Can't encode  as ascii.
    

    On Debian, you can do this by running:

    dpkg-reconfigure locales

     

    And selecting: en_US.UTF-8 UTF-8

    Then make sure to add the following to your ~/.bashrc

    export LANG="en-US.UTF-8"
    export LANGUAGE="en-US.UTF-8"
    


    SVK Reference

    Additional informaion on SVK can be found at the following locations:

    Tag page
    You must login to post a comment.

    Copyright © 2011 MindTouch, Inc. Powered by