The View from the Moon

20061220 Wednesday December 20, 2006

Webrev revised

I recently putback a bunch of work on webrev, a tool which produces HTML-based code reviews.  webrev is much older than web-2.0 generation tools like Google's Mondrian and other commercial code review tools I have seen, but it has done a good job for us for many years.   That said, webrev has built up a long "wish list" of improvements that folks would like to see, evidenced by the dozen or so RFEs about webrev I found in our bug database.  Another problem is that a lot of folks at Sun have been using hacked up versions of webrev for many years, leading to a proliferation of different versions.  As I started working my way through these, I set the goals of my project as follows:

  • Improve the functionality to encompass common wish-list items
  • Clean up the implementation in preparation for Subversion and Mercurial support (which other folks have been prototyping)
  • Redo the command line interface so that simply invoking 'webrev' from the command line attempts to do something useful; rework the options processing to be more extensible and add new options.

Once I talked things over on tools-discuss@opensolaris.org and got some additional suggestions I finished the implementation and putback the fixes. You can see the results here: [old webrev] [new webrev]. Here is the heads up message I sent out about the work, and a quick rundown of the changes I made:

  • You can now run 'webrev' standalone and expect it to "just work." If you have 'wx' initialized, it will use that. If not, it'll use Teamware (and soon, Mercurial and Subversion).
  • Webrev now emits a GNU-patch compatible patch of the changes and a PDF version of the codereview.
  • An "OpenSolaris" mode is now present: use it via 'wx webrev -O' or 'webrev -O'.
  • As might be obvious from the above point, wx now passes arguments to 'wx webrev' on through to webrev.
  • The command line output has changed. Here is a sample:
    $ webrev
    SCM detected: teamware
    File list from: 'wx list -w' ... done
    Workspace: /builds/dp/webrev-fixes
    Compare against: /ws/onnv-clone
    Including: /builds/dp/webrev-fixes/webrev-info
    Output to: /builds/dp/webrev-fixes/webrev
    Output Files:
    usr/src/tools/scripts/webrev.1
    patch cdiffs udiffs wdiffs sdiffs frames ps old new
    usr/src/tools/scripts/webrev.sh
    patch cdiffs udiffs wdiffs sdiffs frames ps old new
    Generating PDF: Done.
    index.html: Done.
  • Teamware-only operation (i.e. when wx is not present) is improved. For example, you can now easily compare the gate against the clone:
         CODEMGR_WS=/ws/onnv-gate webrev -p /ws/onnv-clone -o ~/gatechanges
I also made these improvements:
  • Improved man page
  • Implemented a common color scheme and visual design
  • Delta comments are now shown at the top of each file
  • Printing support via media=print stylesheets
  • Support for generating webrev against previous webrev
  • Overhauled command line parsing including new options:
    • -o <outputdir>
    • -i <include-file>
    • -p <compare-against>
    • -w <wx-file>
    • -O [OpenSolaris mode]
    • -l <options to putback>
  • Cleaned up and improved index.html page.
  • XHTML compliance (or close)
I'm optimistic that folks beyond Sun will find the new webrev useful, particularly once we get Subversion and Mercurial support dropped in.
(2006-12-20 19:44:55.0) Permalink Comments [6]
Trackback: http://blogs.sun.com/dp/entry/webrev_revised
 

Comments:

Excellent! Thanks for the updates. And I'm looking for Subversion support too. It would be great to have an ability to compare two branches in Subversion repository (since that's how lots of folks work - they modify changes in their private branch in svn repository, then send the committed changes for review, and after the review they merge the changes to the trunk. So, producing a webrev against only local changes is not very useful in such scenario.

Also, older webrevs are sort-of Solaris-centric and do not work correctly under Linux or Cygwin. It would be great to have this script portable.

Posted by Vladimir Sizikov on December 21, 2006 at 02:17 AM PST #

It's great to see webrev being maintained and enhanced.

We've been using older versions of webrev in Java ME land for a while but it's sort of stuck to Solaris. A lot of people use Windows and Linux for development and it's quite inconvenient to have to get over to a Solaris box to generate a webrev.

The Solaris dependencies mainly seem to be on ksh and nawk. I've been a fan of ksh its day but I have to admit that bash can be found everywhere now. Porting to bash shouldn't be too difficult. I'm not sure about nawk... gawk might be widespread enough but I'm not sure. (It's not on MacOS X for instance.)

Is there any interest or support for these kinds of changes? I could contribute if there is.

s'marks

Posted by Stuart Marks on December 21, 2006 at 05:09 PM PST #

Thanks for the comments, guys. I wasn't aware of the portability issue (and hey, no one ever filed a bug or RFE on this, either). Probably we could recode the nawk bits in perl. What I'd really like to do is split out the various "diff" generating pieces into separate perl scripts, like 'wdiff'. I guess I still don't really think of the use of ksh as a "Solaris-ism"-- ksh is widely available.

Posted by Dan Price on December 22, 2006 at 12:08 AM PST #

Re. portability, I can live with ksh, most Linuxes do have ksh, and it's possible to install it under Cygwin as well. Not so for nawk. Nawk is typically available under Solaris, while gawk is available under Linux and Cygwin. The problem under some Linux envs is that they have fake nawk which is just a link to gawk and it doesn't work with webrev script. The problem with Solaris boxes is that not all of them do have gawk... Hmm, messsy.

And one more feature request, if you don't mind. It would be really nice to improve webrev so that it could highlight only PARTS of full lines, those that are indeed changed. So if a user just fixed a typo in a line, the only typo should be highlighted, not the full line. It's done in OpenGrok already: Here.

Posted by Vladimir Sizikov on December 22, 2006 at 01:44 AM PST #

Second draft of changes for Mercurial support: http://blogs.sun.com/darren/entry/updated_webrev_with_mercurial_support

Posted by Darren J Moffat on January 05, 2007 at 09:50 AM PST #

Hi Dan, thanks for the reply. Yeah, webrev has probably been copied around within Sun (and maybe outside) and modified umpteen times. Is there a bugtraq category for it? If so, I'd be happy to file an RFE for it. It's probably a better place to track this stuff than comments on your blog entry. :-)

I agree, too, a pressing need is to refactor it into separate scripts (or maybe a script library) that breaks apart the HTML-generating functions from the file-finding/SCM stuff.

If ksh is more widely available that I had thought, then maybe we're OK there. For nawk, I can see two approaches. (1) Recode in a portable common subset of the various awks. I'm not sure that exists. :-) (2) Recode in perl as you suggested. Not sure which of these is the better option.

Posted by Stuart Marks on January 05, 2007 at 10:41 AM PST #

Post a Comment:

Comments are closed for this entry.
Dan Price's Weblog
[about me]