Aurélien Gâteau

reviewboard-am, applying patches from ReviewBoard made easy

written on Friday, August 16, 2013

Let's imagine you are a KDE developer and contribute to a reasonably successful project. This project often receives patches, and these patches are reviewed using KDE Review Board. Pre-commit reviewing helps improving quality, so it's good for us.

So far so good, you go through all those review requests, but actually downloading the diff and applying it to your local checkout of the source tree gets old very fast: developers are lazy creatures after all... Pretty soon you end up doing only static reviews: read the code, comment on mistakes you notice from this read and once it looks good enough, tick the "Ship It" check box. After all, the person who wrote that code certainly tested it before requesting a review, right? I am as guilty as others there, I did a few reviews that way in the past and I felt bad about it.

Fixing laziness with code

A year ago, I got bored and spent some time to put together a simple command-line tool using Review Board API: reviewboard-am. Given a review-id, reviewboard-am downloads the diff, applies it to the current repository and commits the changes using information from the review request (author name, email request summary and description).

Here it is in action, applying a commit on Gwenview:

$ reviewboard-am 112061
Fetching request info
Downloading diff
Creating rb-112061.patch
Running 'git am rb-112061.patch'
Applying: Move code to check next image is selected after removal to ContextManager

I shared it with a few friends, but it stayed relatively unknown, hosted in a Gist on GitHub.

This week I finally took the time to move it to a proper place, it is now part of the kde-dev-scripts repository. I hope it simplifies your life reviewing and applying patches.

What about rbt patch?

A few months after I initially wrote this script, Review Board developers released version 0.5 of RBTools, a set of command line utilities to work with Review Board servers. RBTools 0.5 features rbt patch, a tool to apply patches from a Review Board server.

The main difference with reviewboard-am is rbt patch applies the patch but does not do the commit for you (a feature which I imagine is more difficult to implement in a cross-VCS way). It may be good enough for you though. In any case it certainly beats downloading and applying the diff by hand.

This post was tagged git, kde, review board and tips