xref: /titanic_44/usr/src/tools/scripts/webrev.1 (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)

CDDL HEADER START

The contents of this file are subject to the terms of the
Common Development and Distribution License (the "License").
You may not use this file except in compliance with the License.

You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
or http://www.opensolaris.org/os/licensing.
See the License for the specific language governing permissions
and limitations under the License.

When distributing Covered Code, include this CDDL HEADER in each
file and include the License file at usr/src/OPENSOLARIS.LICENSE.
If applicable, add the following below this CDDL HEADER, with the
fields enclosed by brackets "[]" replaced with your own identifying
information: Portions Copyright [yyyy] [name of copyright owner]

CDDL HEADER END

Copyright 2008 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.


webrev 1 "5 Dec 2008"
NAME
webrev - Generate HTML codereview materials
SYNOPSIS
webrev [ common-options ] webrev [ common-options ] file-list-file | - webrev [ common-options ] -w wx-file webrev [ common-options ] -l arguments to 'putback' See OPTIONS for common-options. Note that the -l option is only applicable to TeamWare workspaces.
DESCRIPTION
webrev builds a set of HTML files suitable for performing code review of source changes in a web browser. It supports Mercurial, Subversion and Teamware repositories. At its most basic, usage is:
 $ webrev
In which case webrev attempts to figure out the list of files for review (note that when using Teamware putback, this may take a long time; see the -l option). If that fails, or if more control over the set of files is needed, a file list may be specified. webrev also attempts to deduce a basis for comparison (interchangeably called the parent, but see SCM INTERACTIONS below). A basis for comparison is needed in order to determine the differences introduced by the code changes under review. By default, webrev creates a webrev directory in the workspace directory that contains the generated HTML files, a generated PDF review, and a patch representing the changes. It also places a copy of the file list in that directory, and of both the old and new raw files in the $webrev_root/raw_files directory. To output the webrev somewhere other than the default location, use the -o <outdir> option, or set the WDIR environment variable. For example:
 $ webrev -o ~/public_html/myreview/

In the index file, each file is listed on a line with a link to the relevant review materials. Comments for each delta will be included automatically. Bug numbers (any sequence of 5 or more digits) and ARC cases (ARC name followed by year/number, e.g. PSARC/2003/436) in the comment will become hyperlinks in the associated web interface. As a review aid, content may be added to the index file in two ways. First, the author may manually edit the file (for example by including text that explains the changes in front of the links for each file). Note that if webrev is run again, manual edits will be lost. Second, if a file named webrev-info is present at the root of the workspace, it will be automatically included in the index file. To include a different file, see the -i option. For each file in the file list, webrev compares the file with the version in the basis for comparison (i.e. the parent workspace) and generates a variety of HTML renderings of the differences between the two files; which of these renderings to use is largely a matter of personal preference. Additional, webrev emits a patch, the old and new versions of the file, and a "raw" copy of the file which is suitable for download. For files which express differences, source is formatted according to the following color coding:

 unchanged : black
 removed : brown
 changed : blue
 new : bold blue
SCM INTERACTIONS

webrev attempts to interact with the source code management system currently in use. webrev needs to be able locate the code under review (i.e. the workspace) and the basis for comparison (i.e. the parent). The method for doing so depends upon the SCM in use, which webrev will also attempt to auto-discover. In all cases, webrev must either discover the list of files which have changed, or else this list must be manually specified, either in "webrev file list" format or in "wx" format. See FILE LIST for more details.

In all cases, if the user has activated the workspace with the ws (1) or bldenv (1) commands, webrev will use the CODEMGR_PARENT and CODEMGR_WS environment variables to identify parent and child workspaces respectively. To manually specify the basis for comparison, use the -p option or specify the CODEMGR_PARENT variable in either the file list or the environment.

Discovering the SCM in use.
webrev makes use of which_scm (1) to determine the SCM in use for a given workspace.
TeamWare
In the case of TeamWare webrev will use the output of "workspace name" to discover the workspace root, if not otherwise specified.

webrev will attempt to use a wx (1) active list in CODEMGR_WS/wx/active. To direct webrev to determine the file list from the output of putback "(1)," use the -l option. (Note that webrev may also elect to use putback if it cannot determine the file list from wx "(1))." The -l option indicates that subsequent arguments should be treated as arguments to putback "(1)." This can be used to prune the set of files which putback examines, or to reference a teamware flp (file list program).

Mercurial
In the case of Mercurial webrev will attempt to use the output from the hg (1) "hg root" to identify the workspace root, and the "hg path default" command to identify the parent workspace.
Subversion
In the case of Subversion webrev will attempt to use the output from the svn (1) "svn info" to find the workspace root and subversion repository URL.

The file list will be created from the output of the "svn status" command.

OPTIONS

10 "-D" Delete remote webrev via SFTP. Default remote host is cr.opensolaris.org, default remote directory for removal is the same as workspace/repository basename. Remote target can be overriden using -t option. If combined with -U the deletion will be performed first. Also, if used together with -U and the removal fails, no upload is done. Without -U option no webrev will be generated, just like if -n option was used. The deletion is done by moving the webrev to special directory in user's home directory. It is expected that the remote host periodically runs a script which deletes the contents of this directory. See the ENVIRONMENT VARIABLES section for more details about this directory.

10 "-i " include-file Include the specified file into the index.html file which is generated as part of the webrev. This allows a snippet of XHTML to be added by the webrev author. User content is contained by a <div> tag and the markup should validate as XHTML 1.0 Transitional.

10 "-l " putback-args Extract the file list from the output of putback -n. Any arguments supplied will be passed to putback "(1)." See SCM INTERACTIONS. For more information about file lists, see FILE LIST. This argument should appear last.

10 "-N" Suppress all comments from all output forms html, txt and pdf.

10 "-n" Do not generate webrev. Useful whenever only upload is needed.

10 -O Enable OpenSolaris mode: bug links are generated relative to bugs.opensolaris.org, SAC links are generated relative to www.opensolaris.org, and sources which appear in usr/closed are automatically elided from the review.

10 "-o " output-dir Place output from running the script in the directory specified. If specified, this option takes precedence over the WDIR environment variable.

10 "-p " basis-of-comparison Specify a basis of comparison meaningful for the SCM currently in use. See SCM INTERACTIONS and INCREMENTAL REVIEWS.

10 "-t " target Upload target. Specified in form of URI identifier. For SCP/SFTP it is ssh://user@remote_host:remote_dir and for rsync it is rsync://user@remote_host:remote_dir. This option can override the -o option if the URI is fully specified. The target is relative to the top level directory of the default sftp/rsync directory tree.

10 "-U" Upload the webrev. Default remote host is cr.opensolaris.org. Default transport is rsync. If it fails, fallback to SCP/SFTP transport is done.

10 "-w " wx-file Extract the file list from the wx "active" file specified. 'wx' uses this mode when invoking webrev. The list is assumed to be in the format expected by the wx package. See FILE LIST, below.

FILE LIST

Webrev needs to be told or to discover which files have changed in a given workspace. By default, webrev will attempt to autodetect the list of changed files by first consulting wx "(1)." If this information is not available, webrev tries to consult the SCM (Source Code Manager) currently in use. If that fails, the user must intervene by specifying either a file list or additional options specific to the SCM in use.

Webrev Format
A webrev formatted file list contains a list of all the files to be included in the review with paths relative to the workspace directory, e.g.
usr/src/uts/common/fs/nfs/nfs_subr.c
usr/src/uts/common/fs/nfs/nfs_export.c
usr/src/cmd/fs.d/nfs/mountd/mountd.c

Include the paths of any files added, deleted, or modified. You can keep this list of files in the webrev directory that webrev creates in the workspace directory (CODEMGR_WS). If CODEMGR_WS is not set, it may be specified as an environment variable within the file list, e.g.

CODEMGR_WS=/home/brent/myws
usr/src/uts/common/fs/nfs/nfs_subr.c
usr/src/uts/common/fs/nfs/nfs_export.c
usr/src/cmd/fs.d/nfs/mountd/mountd.c

To compare the workspace against one other than the parent (see also the -p option), include a CODEMGR_PARENT line in the file list, like:

CODEMGR_WS=/home/brent/myws
CODEMGR_PARENT=/ws/onnv-gate
usr/src/uts/common/fs/nfs/nfs_subr.c
usr/src/uts/common/fs/nfs/nfs_export.c
usr/src/cmd/fs.d/nfs/mountd/mountd.c

Finally, run webrev with the name of the file containing the file list as an argument, e.g.

 $ webrev file.list

If "-" is supplied as the name of the file, then stdin will be used.

wx Format
If the -w flag is specified then webrev will assume the file list is in the format expected by the "wx" package: pathname lines alternating with SCCS comment lines separated by blank lines, e.g.
usr/src/uts/common/fs/nfs/nfs_subr.c

1206578 Fix spelling error in comment

usr/src/uts/common/fs/nfs/nfs_export.c

4039272 cstyle fixes

usr/src/cmd/fs.d/nfs/mountd/mountd.c

1927634 mountd daemon doesn't handle expletives
INCREMENTAL REVIEWS
When conducting multiple rounds of code review, it may be desirable to generate a webrev which represents the delta between reviews. In this case, set the parent workspace to the path to the old webrev:
$ webrev -o ~/public_html/myreview-rd2/ \\
 -p ~/public_html/myreview/
ENVIRONMENT VARIABLES
The following environment variables allow for customization of webrev:

CDIFFCMD and UDIFFCMD are used when generating Cdiffs and Udiffs respectively; their default values are "diff -b -C 5" and "diff -b -U 5". To generate diffs with more (or less) than 5 lines of context or with more (or less) strict whitespace handling, set one or both of these variables in the user environment accordingly. WEBREV_BUGURL may be set to an alternate bug-to-HTML interface (providing the BUG number can be appended to the URL). The default URL is "http://monaco.sfbay.sun.com/detail.jsp?cr=". WDIR sets the output directory. It is functionally equivalent to the -o option. WDIFF specifies the command used to generate Wdiffs. Wdiff generates a full unified context listing with line numbers where unchanged sections of code may be expanded and collapsed. It also provides a "split" feature that shows the same file in two HTML frames one above the other. The default path for this script is /ws/onnv-gate/public/bin/wdiff but WDIFF may be set to customize this to use a more convenient location. WEBREV_TRASH_DIR specifies alternative location of trash directory for remote webrev deletion using the -D option. The directory is relative to the top level directory of the default sftp/rsync directory tree. The default value of this directory is ".trash".

UPLOADING WEBREVS
A webrev can be uploaded to remote site using the -U option. To simply generate new webrev and upload it to the default remote host use the following command:
$ webrev -U

This will generate the webrev to local directory named 'webrev' and upload it to remote host with remote directory name equal to local workspace/repository name. To change both local and remote directory name, -U can be combined with -o option. The following command will store the webrev to local directory named "foo.onnv" and upload it to the remote host with the same directory name:

$ webrev -U -o $CODEMGR_WS/foo.onnv

If there is a need for manual change of the webrev before uploading, -U can be combined with -n option so that first command will just generate the webrev and the second command will upload it without generating it again:

$ webrev
$ webrev -n -U

For custom remote targets, -t option allows to specify all components:

$ webrev -U -t \\
 ssh://user@cr.opensolaris.org:foo/bar/bugfix.onnv

If the remote path is specified as absolute, webrev will assume all the directories are already created. If the path is relative, webrev will try to create all needed directories. This only works with SCP/SFTP transport.

By default, rsync transport will use SSH for transferring the data to remote site. To specify custom username, use entry in SSH client configuration file, for example:

Host cr.opensolaris.org
 Hostname cr.opensolaris.org
 User vkotal
SEE ALSO
putback "(1)," workspace "(1)," hg "(1)," ssh_config "(4)," svn "(1)," which_scm "(1)"
ACKNOWLEDGEMENTS
Acknowledgements to Rob Thurlow, Mike Eisler, Lin Ling, Rod Evans, Mike Kupfer, Greg Onufer, Glenn Skinner, Oleg Larin, David Robinson, Matthew Cross, David L. Paktor, Neal Gafter, John Beck, Darren Moffat, Norm Shulman, Bill Watson, Pedro Rubio and Bill Shannon for valuable feedback and insight in building webrev. Have fun!

Brent Callaghan 11/28/96