Jens Krämer

Work offline with SVK and Subversion

 |  scm, linux

SVK comes in handy whenever you want to work on a project whose files are kept in a remote Subversion repository, but you don’t have network access.

Sure you could just hack away and commit once you’re online again, but this way you lose all the things you are using a version control system for: commit/rollback, changesets with meaningful descriptions, branches and so on.

Besides that, another huge plus of svk is the complete lack of any metadata inside working copies - no more .svn directories getting in your way!

Once you have SVK up and running on your system (see the SVK book and Installing SVK for help), you first mirror your Subversion project in your SVK depot (I’ll use the acts_as_ferret SVN project as an example):

svk mirror svn://projects.jkraemer.net/acts_as_ferret //acts_as_ferret/trunk

svk sync //acts_as_ferret/trunk will now pull the existing revisions from Subversion into your SVK repository.

Now checkout your svk project:

mkdir acts_as_ferret
cd acts_as_ferret
svk checkout //acts_as_ferret/trunk

As this trunk directory is a mirror, any commit done here will be propagated to the remote SVN server immediately. Not exactly what we want, yet. We need to create a branch for our offline work:

svk copy //acts_as_ferret/trunk //acts_as_ferret/local
svk checkout //acts_as_ferret/local

This local directory is where you do all your offline work. As the branch only exists in SVK, any commits done here will stay local to your machine.

Working with SVK is easy if you already know SVN, commit, update, checkout and diff all behave as expected.

To synchronize your work with the remote repository when online again, use the following commands:

  • svk sync //acts_as_ferret/trunk to get changes from the Subversion repository into your SVK trunk
  • svk pull . inside your local directory to merge the remote changes into your local branch
  • svk smerge -I -l //acts_as_ferret/local //acts_as_ferret/trunk to commit your changesets to SVN. This will commit one changeset after another, including the commit messages you used when you did svk commit while offline.

To sync and pull all your projects at once you can use svk sync -a and svk pull -a.