Thursday, July 17, 2008

SVK for SVN users

This post is about setting up SVK for SVN users. I assume you know enough about SVN, and you are looking for a quick documentation which can help in getting off the mark with SVK


At the end of reading this article you should:
  • Understand how to mirror an SVN repository
  • Understand how to Synchronize development between your local SVK repository and your central SVN repository
  • Understand how to create local development branches
  • Know typical day to day tricks for SVK usage

One problem with SVN is that you cannot take advantage of it when you are offline. Thats where SVK comes in which provides you the capability of distributed version control. 

Using SVK you:
  • Mirror an SVN repository in your local file system
  • Do your day to day development using the local SVK repository (online/offline)
  • Publish your changes back to the central SVN repository when deemed suitable (and when you are online)

Installation for different platforms is fairly well covered in

I just would like to let you know that I installed on my MAC and it was straightforward, without any surprises, and worked out of the box. 

SVK depotmap

SVK depot is a local database that SVK creates in which the mirrors of your SVN repositories are maintained .

Creating SVK depot

$svk depotmap --init

It will create a .svk directory inside your home directory. This is your default depot.

Setting up a mirror

Suppose you have the following svn repository structure:
- third-party
- mycalc
- trunk
- gui
- arithmetic
- tags
- branches
- crm
- trunk
- tags
- branches
Now you want to mirror the whole of trunk of your mycalc project. 
$svk mirror svn://  //mycalc/trunk
The above will mirror the svn repository into your default svk depot

A bit of explanation

The command is:
svk mirror url_of_svn_repository path_to_local_mirror
The path to local mirror is formed as:
  • The default depot has no name. Hence // above
  • I chose to use mycalc/trunk as the local mirror path. This way I would essentially replicate the same directory structure as is there in the central repository, avoiding other parts of the structure which I don't wish to replicate (like branches and tags)
To see the list of mirrors, please try:
$svk mirror --list
Path            Source
//mycalc/trunk   svn://

Note that the mirror doesn't yet have anything

Synchronizing the mirror with repository

$svk sync //mycalc/trunk
This will bring your local mirror //mycalc/trunk in sync with the central repository: svn:// 
  • Entire revision history for this repository is downloaded from central SVN server
  • This operation would consume quite a lot of time depending upon how large the repository is

Note: This brings in the entire history of a repository to local repository. So it is very time consuming. It may not be what you want. See below on import.

Working with your local repository

The SVK commands are pretty much the same as SVN commands:

  • To checkout : svk co //mycalc/trunk
  • To update : svk update
  • To commit : svk commit
  • To see the status: svk status
  • Listing the contents of a folder on repository: svk ls //mycalc/trunk/gui

Receiving other changes from central repository

Other people are working also and committing their changes to central repository. To receive those changes into your repository, try:

$svk pull //mycalc/trunk

Publishing your changes to central repository

When you are ready to publish your changes to central repository, try: 
$svn push //mycalc/trunk

SVK Star Merge

Subversion as of now doesn't support automatic merges. One has to record the revision numbers before merging code between two branches. SVK implements Star Merge algorithm first introduced in GNU Arch which makes merging code between branches a lot easier. 

More on this later..

SVK Integration with GUI clients
I haven't found any integration with GUI clients yet. May be sometime in future! Who knows!

My WishList

SVK + Subclipse : Most of my development so far has been done using Eclipse with the SubClipse plugin for SVN integration. I would very much love to have SVK support built-into SubClipse itself.

No comments: