How to mirror a SVK repository onto an SVN repository

Posted by Scott Laird Fri, 15 Jul 2005 07:55:38 GMT

As mentioned before, I’ve been using SVK to manage the changes that I’ve been making to Typo.

One of the items on my SVK to-do list was to figure out how to mirror a local SVK repository onto a public Subversion server. This is useful for a number of reasons:

  • It provides a backup if the local SVK tree is lost.
  • It allows me to use SVK on my laptop and work against the same SVK tree that I’m managing on my server.
  • It allows others to see what I have in my SVK tree.

The SVK documentation doesn’t provide an exact recipe for doing this, but it turns out to be pretty simple. First, make sure that you have a publicly-accessible Subversion server where you have write privileges. Follow the Subversion Book if you need help with this.

Next, tell SVK to mirror a chunk of the Subversion share into your local SVK depot:

$ svk mkdir //mirror
$ svk ls http://svn.scottstuff.net/public/
<follow the prompts and have it mirror it onto //mirror/public>
$ svk sync --all
$ svk mkdir //mirror/public/typo
$ svk smerge --baseless //typo/ //mirror/public/typo -m 'Initial publication'

The final mkdir operation should prompt you for your Subversion username and password; once this is done, you should have write access to the Subversion share for all future operations.

One thing that I probably should have done was use the -Il option to smerge instead of -m. With -Il, SVK commits each local change to the remote server individually, using the local commit message. Without it, all changes get bundled up in one big change, and this isn’t really ideal.

At this point the public Subversion server should have a complete copy of your local Typo tree. To keep it up to date, you’ll need to run something like svk smerge -Il //typo/ //mirror/public/typo from time to time.

Posted in , ,  | Tags , , , ,  | 5 comments

Distributed development with SVK

Posted by Scott Laird Thu, 07 Jul 2005 22:31:00 GMT

As mentioned yesterday, I’ve been looking for a good way to do revision-control my changes to Typo. Typo is maintained in a publicly-visible Subversion tree, so it’s easy to see when changes occur, but I don’t have the ability to write to the Typo tree, so I can’t use it to track my own changes. Since I currently have 4 or 5 different patches for Subversion floating around, plus a pile of local modifications (like adding Adsense banners and changing the ‘Link’ section in the sidebar), I really need some form of revision control.

I briefly tried to use Submaster yesterday, but it hasn’t been updated for Subversion 1.2, and I was unable to commit any changes. So I tried using SVK. Unlike Submaster, SVK is available in Debian’s sid tree, so it was trivial to install. After running apt-get install svk, I followed the tutorial and was up and running in a few minutes. It took a few minutes to import all 272 revisions from the Typo Subversion tree, but once that was complete I was able to make my own branch and start making changes within a couple minutes.

Here are the important steps to using SVK:

Initialize your local repository

The most recent SVK docs suggest using a single repository for everything, instead of managing a repository per project, so I’ll document that path. The command needed is:

$ svk depotmap --init

This will create a new depot in ~/.svk/local. This only needs to happen once, when you first install SVK.

Import your external Subversion repository

Since I want to track Typo’s SVN tree, I needed to tell SVK about it. That’s pretty easy, too:

$ svk mirror svn://leetsoft.com/typo/trunk //typo/trunk
$ svk sync --all

Once those were done, I had a full copy of the Typo SVN tree in my SVK repository’s //typo/trunk directory.

Build a local branch

It’s a lot easier to keep track of changes if you make a local branch and then apply all of your development directly to the branch. This works just like it does in Subversion:

$ svk cp //typo/trunk //typo/local

Check out the local branch

A local working branch isn’t much good if you can’t edit it, so check it out somewhere:

$ svk checkout //typo/local local-typo-changes

This will produce a directory called local-typo-changes in your current working directory, and will fill it will all of the files from the local Typo branch. You can now edit files in this tree and use all of the usual version control commands (svk commit, svk add, svk diff, etc–all of the usual Subversion or CVS commands will work with SVK as well).

Producing patches for external consumption

So, let’s say that you’ve hacked a couple nice new features into your local SVK tree. In my case, I added several different features, committing the changes after each change, but I sometimes I found bugs in features after I committed changes to other features. For instance, my threaded-comment patch was modified in revisions 229, 232, and 246. I wanted to roll up all three of those changes into a single testable patch, but not include any of the other changes that were in my tree, like per-article RSS comment feeds.

This turns out to be very easy. First, I created a subdirectory for patchsets within SVK. This isn’t necessary, but I felt like a bit of organization would be useful:

$ svk mkdir //typo/patchsets

Then I created a new threaded-comments branch, starting with the official Typo SVN tree:

$ svk cp //typo/trunk //typo/patchsets/commentthread

Next, I merged the comment thread changesets from my local tree into the commentthread tree:

$ svk merge -c 229 //typo/local //typo/patchsets/commentthread -l
$ svk merge -c 232 //typo/local //typo/patchsets/commentthread -l
$ svk merge -c 246 //typo/local //typo/patchsets/commentthread -l

The -l uses the previous commit message as part of the new merge commit message.

Finally, I checked out the commentthread tree and tested it:

$ svk checkout //typo/patchsets/commentthread commentthread
$ cd commentthread
$ ruby script/server

This way, I had a completely clean tree, using only the comment thread changes, and I was able to verify that everything worked correctly. As it turned out, I’d missed a couple small changes that had snuck into my main tree as part of other, non-commentthread commits, so if I’d submitted this patch without testing, it wouldn’t have worked for people. So, I made the changes, tested things, checked the changes in, and then produced a patch:

$ xemacs <files>
$ ruby script/server
$ svk commit -m 'Fixed stuff'
$ svk diff //typo/trunk //typo/patchsets/commentthread

Now I can go back to working on my main branch. When I fix bugs in the comment thread code in my local branch, I just need to merge the new commit into the commentthread branch and re-diff. Assuming that revision 270 is comment-thread related:

$ cd commentthread
$ svk merge -c 270 -m 'Merge commit 270 from local tree'
$ svk update
$ ruby script/server
$ svk diff //typo/trunk //typo/patchsets/commentthread

One new patch, tested and ready for submission.

Merging with upstream changes

So, what happens when the upstream SVN tree changes? Well, that’s easy enough. First, re-sync your local copy of the trunk:

$ svk sync //typo/trunk
$ svk smerge //typo/trunk //typo/patchsets/articlerss
<follow the directions>
$ cd <working directory>
$ svk update
<verify and test>
$ svk diff //typo/trunk //typo/patchsets/articlerss

I my case, one of my patches was accepted upstream with minor changes. Once I accepted the merge into my patchset tree, I wanted to promote the changes into my main working tree. I did it this way because it should be easier to merge in this order. Probably. Anyway:

$ svk smerge //typo/patchsets/articlerss //typo/local
<follow the directions>
$ ruby script/server
<test>

At this point, my working tree is synced back up with the mainline.


All in all, SVK isn’t much harder to use then plain Subversion, and the ability to import and modify complete trees is fantastic. My next couple goals are:

  1. Figure out how to export my local changes to a publically-visible SVN server, like the one at svn.scottstuff.net.

  2. Figure out how to manage a SVK share on my development web server and on my laptop. This shouldn’t be hard, but I’m still not fully up to speed with SVK.

Posted in , ,  | Tags , , , ,  | 11 comments

Distributed development with Subversion?

Posted by Scott Laird Wed, 06 Jul 2005 14:31:00 GMT

My recent spate of typo patches has left me with a bit of a dilemma. Typo is managed using the Subversion version control system. That’s great–Subversion is quite nice–except I don’t have (and don’t really want) commit privileges to the master Typo SVN repository. I can check things out and edit them, and use Subversion to make patches, but once my patches start piling up, I’m left without any form of local version control. I can’t tell my patches apart, and there’s no easy way for me to merge my patches with other changes without totally losing control of which change goes with which patch.

This has to be a fairly common problem–a lot of open-source software is developed using Subversion these days, and CVS has similar problems. I could just set up my own Subversion repository for Typo changes, but syncing it with the upstream tree will be a pain.

Does anyone have any “best practices” suggestions?

The only thing that I see online that might be helpful is Submaster, but it’s full of comments like this:

WARNING: This is just a proof-of-concept implementation. Don’t use it in production environments! You have been warned!

NOTE: This version of SubMaster is written for Subversion 0.35.0. It might not work with any other version of subversion as it is now.

That doesn’t instill confidence.

Update: I gave Submaster a brief spin this morning. I was able to create a Submaster repository, but I was unable to check changes into the local repository without getting errors from svn. I suspect that it has problems with Subversion 1.2.

Since that doesn’t look like it’ll work, I’m going to give SVK a try. The short tutorial on the SVK wiki makes it look pretty simple. It’s currently cloning 272 revisions out of the Typo SVN tree; hopefully it’ll actually work right once it’s done.

Update 2: This is continued in a new article.

Posted in ,  | Tags , , , ,  | 3 comments

Trac

Posted by Scott Laird Tue, 08 Mar 2005 18:47:02 GMT

I’ve been playing with Trac a bit recently for a hobby project, and I’m really impressed. Trac is an open-source project management application that combines bug tracking, a wiki, and a Subversion browser into a nicely integrated little package. You can think of it as a sort of light-weight do-it-yourself SourceForge, minus the mailing lists and hosted downloads.

One of its cooler features is the ability to provide a single integrated RSS feed that lists SVN checkins, bug tracker progress, and wiki changes all in a single feed.

Unlike certain other bug trackers, Trac’s bug database is actually usable by mere mortals. It does a nice job balancing complexity and simplicity while still being reasonably configurable. For instance, it’s really easy to change Trac’s bug priority and severity options–just run trac-admin on the command line and use its priority and severity commands. Like Joe, I agree that 5 priority levels are at least 2 too many.

Posted in  | Tags , , , ,  | 2 comments

Borges

Posted by Scott Laird Tue, 13 Apr 2004 03:16:26 GMT

I’ve been playing with Borges, a Ruby web application server for the past week or so at work. It’s an interesting beast; it’s continuation-based, which means the flow of control in Borges apps is much closer to traditional programming then it is to normal web applications. I don’t have a good example handy, but it’s kind of mind-twisting, because you can make non-event-driven web applications with it. I’ll probably move some of my Asterisk stuff over to Borges, partly because Borges could use a good example, and partly because the big pile of Asterisk stuff that I’ve been accumulating could use a better web framework.

Posted in ,  | Tags , , ,  | no comments

ab2vcard: A command-line tool for converting OS X Address Books to a directory full of vCards

Posted by Scott Laird Wed, 10 Mar 2004 13:37:48 GMT

As mentioned yesterday, I’m now exporting all of the entries in my OS X Address Book into Subversion. In order to do this, I needed to hack up a conversion tool. Since I have it working for me, I figured I’d share it. So, I’d like to announce ab2vcard version 1.0. You can download an OS X installer package plus the source.

The whole thing is pretty trivial to use. Just run /usr/local/bin/ab2vcard directory, and it’ll create a vCard for everyone in your Address Book in the directory directory. If you add the -d flag, then it’ll erase files that aren’t currently in your address book. If you add the -s flag, then it’ll try to check changes into Subversion. The README that’s included gives more detail, as does the manpage.

It’s written in Objective C and derived from ’contacts’ by Shane Celis. Since I now have a whopping 4 hours of experience with Objective C, don’t expect the code to be spotless, but it shouldn’t be too bad. Objective C is a surprisingly easy language, if you already know C and are somewhat familiar with other Smalltalk-influenced languages. The hard part is getting the hang of all of the framework code, but Apple’s documentation helped with that.

Let me know if you find any bugs, or if you find this useful for anything.

Posted in , ,  | Tags , , ,  | no comments

More Pragmatic Programmer books

Posted by Scott Laird Tue, 14 Oct 2003 23:00:47 GMT

Dave Thomas and Andy Hunt’s The Pragmatic Programmer is one of the best programming books that I’ve read in years. Dave’s talk at last year’s Ruby Conference was one of the highlights of the event for me. Now, they’re back with a pair of new books:

It’s been a busy couple of months here as we prepare to launch our new book-printing imprint, The Pragmatic Bookshelf. We spent the year writing the first two books, Pragmatic Version Control and Pragmatic Unit Testing. [PragDave]

Time for two more entries on my to-read list.

Posted in ,  | Tags , , ,  | no comments