From 04b08da9af0c450d645ab7389d1467308cfc2db8 Mon Sep 17 00:00:00 2001
From: Michael Stapelberg
This document explains how to contribute changes to the Go project.
It assumes you have installed Go using the
-installation instructions and
+installation instructions and
have written and tested your code.
(Note that the
-The final line printed by
-The value of N varies over time, but the line must
-say “
@@ -104,41 +93,44 @@ the code review extension disables the standard
-Mercurial power users: if you prefer to use the Mercurial Queues extension, see
-Using Mercurial Queues with Codereview.
- Edit Replace YOUR_GO_ROOT with the value of
The
+After adding the extension,
The code review server uses a Google Account to authenticate.
(If you can use the account to
sign in at google.com,
-you can use it to sign in to the code review server.
+you can use it to sign in to the code review server.)
The email address you use on the Code Review site
will be recorded in the Mercurial change log
and in the gccgo
frontend lives elsewhere;
see Contributing to gccgo.)
@@ -46,24 +46,13 @@ tree to make sure the changes don't break other packages or programs:
cd $GOROOT/src
-./all.bash
+./all.bash # On Windows, run all.bat
make all
should be of the form:
+After running for a while, the command should print "ALL TESTS PASSED
".
-N known bugs; 0 unexpected bugs
-
-
-0 unexpected bugs
” and must not
-add “test output differs
.”
-Code review
hg commit
command.
Configure the extension
$GOROOT/.hg/hgrc
to add:
[extensions]
-codereview = YOUR_GO_ROOT/lib/codereview/codereview.py
+codereview = $GOROOT/lib/codereview/codereview.py
[ui]
username = Your Name <you@server.dom>
-$GOROOT
.
-The Mercurial configuration file format does not allow environment variable substitution.
+username
information will not be used unless
you are a committer (see below), but Mercurial complains if it is missing.
hg help codereview
+will show documentation for its commands. As the codereview extension is only
+enabled for your checkout in $GOROOT
, the remainder of this
+document assumes you are inside $GOROOT
when issuing commands.
+Log in to the code review site.
CONTRIBUTORS
file.
You can create a Google Account
associated with any address where you receive email.
+If you've enabled the two-step verification feature, don't forget to generate an
+application-specific password and use that when prompted for a password.
@@ -163,6 +155,19 @@ can use that nickname as a shorthand for naming reviewers and the CC list.
For example,
rsc
is an alias for rsc@golang.org
.
+Most Go installations use a release branch, but new changes should +only be made to the default branch. (They may be applied later to a release +branch as part of the release process.) +Before making a change, make sure you use the default branch: +
+ ++$ hg update default ++
@@ -263,6 +268,8 @@ The special sentence “Fixes issue 159.” associates the change with issue 159 in the Go issue tracker. When this change is eventually submitted, the issue tracker will automatically mark the issue as fixed. +(These conventions are described in detail by the +Google Project Hosting Issue Tracker documentation.)
@@ -277,15 +284,37 @@ which hg change
will print, something like:
CL created: http://codereview.appspot.com/99999
+
-If you need to re-edit the change description,
+If you need to re-edit the change description, or change the files included in the CL,
run hg change 99999
.
-You can see a list of your pending changes by running hg pending
(hg p
for short).
+Alternatively, you can use
+$ hg file 99999 somefile ++ +
+to add somefile
to CL 99999, and
+
+$ hg file -d 99999 somefile ++ +
+to remove somefile
from the CL.
+
+A file may only belong to a single active CL at a time. hg file
+will issue a warning if a file is moved between changes.
+
+Creating or uploading the change uploads a copy of the diff to the code review server,
+but it does not notify anyone about it. To do that, you need to run hg mail
+(see below).
+
To send out a change for review, run hg mail
using the change list number
assigned during hg change
:
Note that -r
and --cc
cannot be spelled --r
or -cc
.
+If your change relates to an open issue, please add a comment to the issue +announcing your proposed fix, including a link to your CL. +
You will probably revise your code in response to the reviewer comments. +
+You will probably revise your code in response to the reviewer comments. When
+you have done this, you can upload your change to the code review server
+without sending a notification by running hg upload
using the change
+list number assigned during hg change
+
+$ hg upload 99999 ++ +
When you have revised the code and are ready for another round of review, run
@@ -433,39 +483,59 @@ The reviewer approves the change by replying with a mail that saysLGTM
: looks good to me.
-
+You can see a list of your pending changes by running hg pending
(hg p
for short).
+
-After the code has been LGTM
'ed, it is time to submit
-it to the Mercurial repository.
-If you are a committer, you can run:
+You can import a CL proposed by someone else into your local Mercurial client
+by using the hg clpatch
command. Running
-$ hg submit 99999 +$ hg clpatch 99999
-This checks the change into the repository.
-The change description will include a link to the code review,
-and the code review will be updated with a link to the change
-in the repository.
+will apply the latest diff for CL 99999 to your working copy. If any of the
+files referenced in CL 99999 have local modifications, clpatch
+will refuse to apply the whole diff. Once applied, CL 99999 will show up in
+the output of hg pending
and others.
-If your local copy of the repository is out of date,
-hg submit
-will refuse the change:
+To revert a CL you have applied locally, use the hg revert
+command. Running
-$ hg submit 99999 -local repository out of date; must sync before submit +$ hg revert @99999+
+will revert any files mentioned on CL 99999 to their original state. This can +be an effective way of reverting one CL revision and applying another. +
+ +
+Once the CL has been submitted, the next time you run hg sync
+it will be removed from your local pending list. Occasionally the pending list
+can get out of sync leaving stale references to closed or abandoned CLs.
+You can use hg change -D 99999
to remove the reference to CL 99999.
+
+After the code has been LGTM
'ed, it is time to submit
+it to the Mercurial repository.
+
If you are not a committer, you cannot submit the change directly.
-Instead, a committer, usually the reviewer who said LGTM
,
+Instead a committer, usually the reviewer who said LGTM
,
will run:
The clpatch
command imports your change 99999 into
-the committer's local Mercurial client, at which point the committer
-can check or test the code more.
-(Anyone can run clpatch
to try a change that
-has been uploaded to the code review server.)
+
The submit
command submits the code. You will be listed as the
author, but the change message will also indicate who the committer was.
Your local client will notice that the change has been submitted
when you next run hg sync
.
+If you are a committer, you can run: +
+ ++$ hg submit 99999 ++ +
+This checks the change into the repository. +The change description will include a link to the code review, +and the code review will be updated with a link to the change +in the repository. +
-
+If your local copy of the repository is out of date,
+hg submit
will refuse the change:
+
+$ hg submit 99999 +local repository out of date; must sync before submit ++ +
Files in the Go repository don't list author names,
both to avoid clutter and to avoid having to keep the lists up to date.
@@ -497,7 +587,7 @@ and perhaps the AUTHORS
file.
The CONTRIBUTORS
file
defines who the Go contributors—the people—are;
-the AUTHORS
file, which defines
+the AUTHORS
file defines
who “The Go Authors”—the copyright holders—are.
The Go developers at Google will update these files when submitting
your first change.
@@ -525,7 +615,12 @@ This rigmarole needs to be done only for your first submission.
Code that you contribute should use the standard copyright header:
-// Copyright 2012 The Go Authors. All rights reserved. +// Copyright 2013 The Go Authors. All rights reserved. // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file.+ +
+Files in the repository are copyright the year they are added. It is not +necessary to update the copyright year on files that you change. +
-- cgit v1.2.3