Splinter – patch review for Bugzilla

OK, time to make good on my promise to write about Splinter some more and show it off. The basic idea of Splinter (hinted at in my last post) is that instead of doing patch review as a completely new system and building all the infrastructure from scratch, it should be possible to do the kind of interactive patch review featured by systems like Review Board or Rietveld directly on patches attached to Bugzilla.

When you visit Splinter’s display of patch attachment, you see a standard two-column patch display like:

Splinter review with comment

Any coments that people have previously made will show up inline. If you have comments to make yourself, you can double-click on a line and an editor will open where you can type the new comment:

Adding a comment with Splinter

I put up a (read-only) demo instance of Splinter where you can try this out live.

When you publish your review, it will be published as a comment in Bugzilla that looks (in part) something like:

::: js/ui/lookingGlass.js
@@ -355,3 +355,3 @@
             inspector.connect('closed', Lang.bind(this, function() {
                 this.actor.show();
-                global.stage.set_key_focus(this._entry);
+                Main.acquireKeyboardFocusStack(this._entry);

I'm not sure why we are setting the keyboard focus (either way) when the
inspector is closed, but using a stack-based acquire() seems
definitely wrong.

The idea of the format is to be readable if someone is just reading the comments in the review or in emails from Bugzilla, while still being parseable by Splinter for inline display.

A neat feature of Splinter is it uses the new DOM Storage mechanism to save in-progress reviews. You can leave the page for a review and come back to it any time and your review will be as you left it. (This requires a brand new browser, like Firefox 3.5.)

Using it yourself

Assuming that there’s interest, I’d like to make this available on bugzilla.gnome.org. The first step would be just having it there behind the scenes if you know the URL. The second step would be to write a small Bugzilla extension to link to add links to Splinter from review comments and from the attachments section.

But you don’t need to wait for this. If the above is something that you want now, then you can clone it from git://git.fishsoup.net/splinter (browse, README). In the proxy/ subdirectory, there’s a README file that describes how to run a local proxy server pointed to a Bugzilla instance. It’s really easy. Then connect to:

http://127.0.0.1:23080/index.html

in your web browser. Some aspects are a bit obscure as of yet; for example if posting a review hits “a mid-air conflict” then it will fail and you need to reload the page (safe because of the use of DOM Storage!) and try again. But it’s definitely usable.

Behind the scenes

The most interesting thing about Splinter is that the server referred to above is just a proxy server. The only reason that it is there at all is to safely get around cross-site-scripting restrictions; there’s no server side component at all. Instead, the Javascript code of Splinter uses the existing exposed web interfaces of Bugzilla (and your existing Bugzilla login credentials) to get information about the bug and post reviews back. Everything – parsing the patch files, building the display – is done in Javascript in your web browser.

One of the main reasons for doing it this way was language choice. I’m doing a lot of Javascript coding for gnome-shell, so its very much at my fingertips. And there was going to be Javascript and DOM manipulation in any case – I wanted a modern interactive interface for editing reviews. If I was going to write a server side component, I’d need to do it in Perl to integrate nicely with the Bugzilla environment, but my Perl is distinctly rusty. Everything in Javascript side-stepped that issue.

The Javascript approach also is easy for development – you don’t need a test Bugzilla instance to work on, you can just hack on the Javascript and HTML files, and use the proxy server to run your changes against a public Bugzilla instance.

The Javascript code uses JQuery extensively. It’s my second project using it, and I’m liking it a lot. In some ways, it’s really a meta-language on top of Javascript, but it gives a lot of power compactly and readably. (Readably if you don’t get too clever with it.) The source code also contains a SpiderMonkey-based test harness so that I could write tests for the non-interactive parts like parsing patches and run ‘make check’.

Future

Splinter is never going to be as nice for the single task of patch review as Review Board. But there’s quite a bit of low-hanging fruit to make it better. In addition to the small Bugzilla extension mentioned above, other things I’m thinking of include: better control of how much context is shown with a comment. A collapsed view of a review that just shows the review and the sections being commented on. A threaded display of the attachments of a bug showing their relationship to each other and the reviews on each version. The ability to add extra context around a particular section of a patch.

5 Comments

  1. Posted September 23, 2009 at 7:45 pm | Permalink

    FWIW, I’m actually thinking of integrating Review Board into Bugzilla to replace PatchReader:

    https://bugzilla.mozilla.org/show_bug.cgi?id=515210

    -Max

    • Owen
      Posted September 24, 2009 at 11:52 am | Permalink

      It will be interesting to see how that works out. I think there is some good integration that can be done between Bugzilla and Review Board but from the investigation I did, it wasn’t immediately clear to me that the sort of “captive” arrangement that you describe in that bug would be feasiable or desirable. Maintaining the workflow and user interface of Review Board and creating good bidirectional links and updating seemed more attractive.

  2. Posted September 24, 2009 at 3:37 am | Permalink

    This is very cool. I wonder if it would be possible to also package it as a Firefox extension or a Greasemonkey script so that you could use it on all Bugzillas without having to run the proxy server?

    • Owen
      Posted September 24, 2009 at 12:10 pm | Permalink

      Neat idea. I think it would be pretty easy to do it either way – either package up Splinter as a Firefox extension (just have the page as chrome:splinter), or write a Greasemonkey script that lifted specific cross-site-scripting restrictions and allowed a splinter page to do AJAX requests against different Bugzillas. The Firefox extension method would likely be less hacky and easier to install. But for now, I think my focus is more on getting it to work well with a cooperating bugzilla instance where the maintainer is willing to install a Bugzilla extension.

  3. Posted September 24, 2009 at 12:27 pm | Permalink

    This is indeed really cool, I’m looking forward to have it available for b.g.o.


Follow

Get every new post delivered to your Inbox.

%d bloggers like this: