1. Patrick Mézard
  2. codereview

Overview

HTTPS SSH

Overview

This extension is a fork of the one in Go repository, which usage is described here:

http://golang.org/doc/contribute.html

The fork reshapes the contribution workflow to better fit a regular Mercurial workflow, and notably to use changesets instead of local changes. The extension brings the following commands:

  • cllogin: log in codereview server and save authentication token
  • clpush: create or update a changelist from a Mercurial changeset
  • clclose: close and optionally delete a changelist bound to a changeset
  • climport: turn a changelist into a regular local changeset
  • gofmt: run gofmt on changed files or changeset files.

See hg help codereview or hg help COMMAND for more details.

A simple coding session looks like:

... write some changes ...

$ hg commit -m "some changes"
$ hg clpush .
Issue created. URL: https://codereview.appspot.com/123456
amending changeset changelist metadata

... fix things on this changeset ...

$ hg commit --amend
$ hg clpush .
Issue updated. URL: https://codereview.appspot.com/123456

$ hg clpush --email . 
Issue updated. URL: https://codereview.appspot.com/123456
amending changeset changelist metadata

... code is being reviewed and possibly accepted ...

$ hg clclose .
Issue deleted. URL: https://codereview.appspot.com/123456

... and to import someone else work ...

$ hg climport 64740043
applying /temp/path/CL64740043XLUH_H.diff
CL 64740043 imported as:
  19212:0e8f9e38c4f4 archive/tar: Added support for GNU sparse files.

$ hg parents
changeset:   19212:0e8f9e38c4f4
tag:         tip
parent:      19197:70499e5fbe5b
user:        david...@gmail.com
date:        Sun Feb 23 18:05:51 2014 +0100
summary:     archive/tar: Added support for GNU sparse files.

Requirements and Setup

Note: this extension is experimental, is built on codereview -a collage of years of rietveld scripting-, and relies on Mercurial evolve extension which itself is experimental. That said, I use it as much as I can, and will fix issues as they arise.

  • Recent Mercurial, like >= 2.7 (or whatever evolve requires)
  • Evolve extension: https://bitbucket.org/marmoute/mutable-history Be sure to checkout its stable branch, unless you run a development version of Mercurial.
  • This extension, enabled and configured like:

    [extensions]
    codereview = /path/to/codereview/lib/codereview/codereview.py
    

The tests are usually run on Win7/Cygwin with Mercurial 2.9 and OSX with Mercurial 2.7, 2.8, 2.9 and tip, and Evolve stable branch.

How Does It Work?

The main difference with the original extension is changelists are mapped to Mercurial changesets and changelist metadata is stored in changesets description as CLMETA- lines.

clpush and clclose synchronizes local and remote data and metadata. climport creates regular changesets from remote changelists. Note they do not contain CLMETA- and are just normal changesets.

Preparing changes for review is reduced to writing and rewriting changesets. Obviously the evolve extension can be used for that (see amend, fold and uncommit commands for instance), but any other tools like histedit or regular commands like commit --amend or rebase will do.

Running the Tests

Note: some tests actually talk to codereview.appspot.com and create CLs.

You need a mercurial repository checkout, for instance at /path/to/hg. Evolve extension is also required, you can get it from:

https://bitbucket.org/marmoute/mutable-history

and put it in /path/to/evolve.

gofmt must be in $PATH (the extension gofmt bit has been kept from the Go fork and might be moved in another extension at some point).

Finally, you need a valid codereview.appspot.com cookie file. To get one, use codereview extension "code-login" command once (you need to have a codereview account). The file is available in

~/.codereview_upload_cookies_codereview.appspot.com

Copy it in the tests directory.

Now, to run the tests:

$ cd /path/to/codereview
$ (cd tests; /path/to/hg/tests/run-tests.py \
    --extra-config-opt=extensions.evolve=/path/to/evolve/evolve.py \
    test-clpush.t)