SVK - Distributed Version Control - Part III
Introduction
Last week we explored using a local branch and keeping it in sync with the main repository. We also explored the incremental synchronization of local mirrors on our machine. This week we will be merging our changes back into the main repository and wrapping up our discussion of SVK for now.
Notation
Some of the lines in the command are truncated because they are too long. I have used the ‘_’ character as a line continuation character. If you see this character, look at the next line.
Merging From Your Local Branch To The Mirror
At the end of our last article, we had finished the work that we wanted to do and now we would like to merge our changes into the main repository so that others can access our changes. The assumption is that we have performed all of the due dillegence that software developers perform when they finalize a change and are ready to have those changes activated in the main repository, including keeping our local branch up to date with the main repository using the repository synchronization techniques outlined in previous articles and merging them into our local branch to keep our workarea current.
The time has finally come where everyone who uses the main repository gets to see the changes we have been working on.
When merging to a mirrored tree in SVK, we use the smerge command just like we would in our previous work, only this time the source and destination are switched. We are now merging to the mirror, however the process looks the same. The really cool thing about SVK however, is that when you perform a merge to a mirrored path, you not only update your mirror, but the repository that the mirror points to is also updated simultaneously.
So lets do it. Before actually performing the merge, connect to the network and sync your local repository.
svk sync //bieberlabs/trunk
Syncing http://subversion.bieberlabs.com/svn/bieberlabs/trunk
rbieber:/~>
Now that we are synced up, we will perform an svk smerge -C command to make sure we have no conflicts.
rbieber:/~>svk smerge -C //bieberlabs/new-feature-x _
//bieberlabs/trunk
Auto-merging (0, 409) /bieberlabs/new-feature-x _
to /bieberlabs/trunk (base /bieberlabs/trunk:408).
Checking locally against mirror source _
http://subversion.bieberlabs.com/svn/bieberlabs/trunk.
U website/index.php
D website/familypictures
New merge ticket: fd3a5cf1-f4e9-0310-b907-bd1e11f8034a: _
/bieberlabs/new-feature-x:409
rbieber:/~>
Some things to notice. Previously we saw quite a few changes coming from the mirrored repository to our local branch, including the re-adding of a photos directory with 68 pictures in the main repository. None of these changes are being merged back to the mirror. SVK is keeping track of the merges we have made from the main repository to our local branch and filtering them out (or skipping them) for us.
It winds up that with all the activity between the main repository and the local branch, the final result is that the only changes made by us in this whole process were the deletion of a directory, and modifications to our index.php file — and SVK knows that. We didn’t have to spend a lot of our valueable time towards an impossible schedule to figure it out!
Now that we know there are no conflicts (it’s nice to live in a perfect world!) we can actually perform a real merge to the mirror. We do this by substituting (in this case) the -C option with the -l option to get an initial log message that reflects each of our individual commits so we know what changes have been made through the time we have been developing on our local branch.
rbieber:/~>svk smerge -l //bieberlabs/new-feature-x //bieberlabs/trunk
Auto-merging (0, 409) /bieberlabs/new-feature-x to _
/bieberlabs/trunk (base /bieberlabs/trunk:408).
Waiting for editor...
Merging back to mirror source _
http://subversion.bieberlabs.com/svn/bieberlabs/trunk.
U website/index.php
D website/familypictures
New merge ticket: fd3a5cf1-f4e9-0310-b907-bd1e11f8034a: _
/bieberlabs/new-feature-x:409
Merge back committed as revision 24.
Syncing http://subversion.bieberlabs.com/svn/bieberlabs/trunk
Retrieving log information from 24 to 24
Committed revision 420 from revision 24.
rbieber:/~>
As you can see from the above messaging, a few things have happened during the actual merge:
- We were prompted for a log message. Even though this is prepopulated, you have to add something to it to let the tool know you want to continue with the merge, just like SVN and CVS.
- Our changes were merge to the mirrored path as we specified.
- Our changes were then merged from the mirrored repository to the main repository — automatically exposing them in the main repository for other developers to subsequently pull down.
- Our mirror was automatically resynced to be current.
Just to verify that our changes made it to the repository, we can go to our local installation of ViewCVS to verify the commit:

In Conclusion
In the last three articles, we have the basic areas of distributed, activity based development necessary to get someone new to SVK productive. I hope that as we have walked through the use of this tool, I have illustrated the huge gains you can receive from beginning to use it.
There are obvious areas in which I have neglected to cover from a conceptual level like conflict resolution, however this process under SVN is covered quite extensively in the Resolving Conflicts chapter of the SVN book written by the Subversion developers. There are also other commands and types of merges that SVK can perform that I will leave to the reader to explore.
SVK is a very powerful tool. The main disadvantage of it is that is written in PERL, and therefore can be difficult to install, and slow to start up. However, these disadvantages are far outweighed by the advantages that the tool brings to the table.
The ability to work while disconnected from a central repository and the automatic merge tracking features of SVK are of incredible value to anyone wanting to give flexibility and true distributed capabilities to their development staff. I highly recommend that you take the time to explore this tool and explore for yourself the new capabilities and flexibility, not to mention just plain time savings SVK brings to the table.
Back to part II | Start Over at Part I
Related posts
This work is licensed under a Creative Commons Attribution-Share Alike 2.5 License.







17 Comments so far
Leave a comment
By Jan Hudec on 03.21.05 3:37 am
emerge svk
and viola!
Still interested in maybe contributing, will see how my schedule goes.
Later
By Gert Burger on 04.25.05 5:51 am
By Richard on 07.19.05 3:10 am
By Ron Bieber on 07.23.05 9:23 am
Good documentation is a necessity, especially for versioning systems. That’s why I am using subversion and now I will be using svk.
By mpiktas on 07.27.05 1:54 am
By MÃ¥rten Larsson on 08.30.05 9:21 am
By Ron Bieber on 08.30.05 5:16 pm
s Blogs, and Googler Blogs tags: blogs google Version Control with SVK tags: documentation svk SVK - Distributed Version Control - Part I tags: svk SVK - Distributed Version Control - Part II tags: svk SVK - Distributed Version Control - Part III tags: svk Faster Testing with Rails 1.0 tags: rails tdd testing Collaborative Document Editing with svk ONLamp.com: Collaborative Document Editing with svk tags: svk Painless Merging with SVK: An Interview with Chia-liang Kao O
By sneer.org on 10.28.05 4:55 am
del.icio.us/ntalbott del.icio.us warning: non-utf8 string! (sorry) del.icio.us warning: non-utf8 string! (sorry) del.icio.us warning: non-utf8 string! (sorry) Distributed development with SVK Thread Patterns
By blog.talbott.ws on 11.10.05 4:36 pm
By Charles Gerungan on 08.27.06 2:19 am
Tanks a lot.
By augusto on 12.03.06 11:45 am
[...] - Part I - Part II - Part III [...]
By jprenaud.info » Blog Archive » Using svk to mirror a subversion repository on 06.30.07 3:32 am
I would really appreciate your opinion on this point as you have some experience with SVK implementation. Feel free to contact me via email if you’d like some precisions about my needs.
By LeParrain on 07.18.07 5:01 am
Thanks for a great intro to svk. Got me going lickity split!
-pgm
By Pete McKinstry on 11.28.07 11:55 pm
By Ron Bieber on 11.29.07 5:25 am
Installing SVK is also trivial on Mac OS X. Just download 2 .dmg files, double-click them, and everything works!
http://homepage.mac.com/hiirem/svkbuilds.html
By Jay Hannah on 12.27.07 5:06 pm
- Using SVK on Debian
By Daniele Primon on 02.20.08 1:53 pm
Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>