blob: 32ff09bdd3e23bb0a2b9d2d0601617d16dab3693 [file] [log] [blame]
Andrew Gerrand7cb21a72012-01-19 11:24:54 +11001<!--{
2 "Title": "Contribution Guidelines"
3}-->
Russ Coxfb39a4d2009-10-23 15:24:08 -07004
Russ Cox6c7f9f62009-11-09 16:56:17 -08005<h2 id="Introduction">Introduction</h2>
Rob Pike5b72f9c2009-11-01 20:48:21 -08006
7<p>
Russ Coxd55abfd2009-12-09 14:05:12 -08008This document explains how to contribute changes to the Go project.
Russ Cox696e8022009-11-07 18:56:00 -08009It assumes you have installed Go using the
Jonathan Feinberg452f40f2012-09-26 14:39:31 -040010<a href="/doc/install/source">installation instructions</a> and
Russ Coxd55abfd2009-12-09 14:05:12 -080011have <a href="code.html">written and tested your code</a>.
12(Note that the <code>gccgo</code> frontend lives elsewhere;
Ian Lance Taylor2528f332009-11-06 14:15:41 -080013see <a href="gccgo_contribute.html">Contributing to gccgo</a>.)
Russ Cox38a41ee2009-11-06 10:04:22 -080014</p>
Russ Coxfb39a4d2009-10-23 15:24:08 -070015
Rob Pike96ee38b2009-12-17 12:12:47 +110016<h2 id="Design">Discuss your design</h2>
17
18<p>
19The project welcomes submissions but please let everyone know what
20you're working on if you want it to become part of the main repository.
21</p>
22
23<p>
24Before undertaking to write something new for the Go project, send
Brad Fitzpatrick967901a2014-03-05 14:09:03 -080025mail to the <a href="https://groups.google.com/group/golang-nuts">mailing
Rob Pike96ee38b2009-12-17 12:12:47 +110026list</a> to discuss what you plan to do. This gives everyone a
27chance to validate the design, helps prevent duplication of effort,
28and ensures that the idea fits inside the goals for the language
29and tools. It also guarantees that the design is sound before code
30is written; the code review tool is not the place for high-level
31discussions.
32</p>
33
34<p>
35In short, send mail before you code.
36And don't start the discussion by mailing a change list!
37</p>
38
Russ Coxd55abfd2009-12-09 14:05:12 -080039<h2 id="Testing">Testing redux</h2>
Russ Cox830813f2009-11-08 21:08:27 -080040
41<p>
Russ Coxd55abfd2009-12-09 14:05:12 -080042You've <a href="code.html">written and tested your code</a>, but
43before sending code out for review, run all the tests for the whole
44tree to make sure the changes don't break other packages or programs:
Russ Cox38a41ee2009-11-06 10:04:22 -080045</p>
46
47<pre>
Nathan John Youngmand5f208c2014-03-17 09:35:04 +110048$ cd go/src
49$ ./all.bash
Russ Cox38a41ee2009-11-06 10:04:22 -080050</pre>
51
52<p>
Nathan John Youngmand5f208c2014-03-17 09:35:04 +110053(To build under Windows use <code>all.bat</code>.)
54</p>
55
56<p>
Shenghou Ma4c473c02012-10-11 23:33:57 +080057After running for a while, the command should print "<code>ALL TESTS PASSED</code>".
Russ Cox38a41ee2009-11-06 10:04:22 -080058</p>
59
Russ Cox6c7f9f62009-11-09 16:56:17 -080060<h2 id="Code_review">Code review</h2>
Russ Cox38a41ee2009-11-06 10:04:22 -080061
62<p>
63Changes to Go must be reviewed before they are submitted,
64no matter who makes the change.
Russ Cox9ad14c92009-11-06 10:33:46 -080065(In exceptional cases, such as fixing a build, the review can
66follow shortly after submitting.)
Russ Cox38a41ee2009-11-06 10:04:22 -080067A Mercurial extension helps manage the code review process.
68The extension is included in the Go source tree but needs
69to be added to your Mercurial configuration.
70</p>
71
Russ Cox9ad14c92009-11-06 10:33:46 -080072<h3>Caveat for Mercurial aficionados</h3>
73
Russ Cox38a41ee2009-11-06 10:04:22 -080074<p>
75<i>Using Mercurial with the code review extension is not the same
Russ Cox9ad14c92009-11-06 10:33:46 -080076as using standard Mercurial.</i>
Russ Cox38a41ee2009-11-06 10:04:22 -080077</p>
78
79<p>
Russ Cox9ad14c92009-11-06 10:33:46 -080080The Go repository is maintained as a single line of reviewed changes;
81we prefer to avoid the complexity of Mercurial's arbitrary change graph.
82The code review extension helps here: its <code>hg submit</code> command
83automatically checks for and warns about the local repository
84being out of date compared to the remote one.
85The <code>hg submit</code> command also verifies other
86properties about the Go repository.
Russ Cox696e8022009-11-07 18:56:00 -080087For example,
Russ Cox9ad14c92009-11-06 10:33:46 -080088it checks that Go code being checked in is formatted in the standard style,
89as defined by <a href="/cmd/gofmt">gofmt</a>,
90and it checks that the author of the code is properly recorded for
91<a href="#copyright">copyright purposes</a>.
92</p>
93
94<p>
95To help ensure changes are only created by <code>hg submit</code>,
96the code review extension disables the standard <code>hg commit</code>
97command.
98</p>
99
Russ Cox38a41ee2009-11-06 10:04:22 -0800100<h3>Configure the extension</h3>
101
Nathan John Youngmand5f208c2014-03-17 09:35:04 +1100102<p>Edit <code>.hg/hgrc</code> in the root of your Go checkout to add:</p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800103
104<pre>
105[extensions]
Nathan John Youngmand5f208c2014-03-17 09:35:04 +1100106codereview = /path/to/go/lib/codereview/codereview.py
Russ Coxd55abfd2009-12-09 14:05:12 -0800107
108[ui]
109username = Your Name &lt;you@server.dom&gt;
Russ Cox38a41ee2009-11-06 10:04:22 -0800110</pre>
111
David Symonds156d85c2012-10-08 22:24:41 +1100112<p>
Russ Coxd55abfd2009-12-09 14:05:12 -0800113The <code>username</code> information will not be used unless
114you are a committer (see below), but Mercurial complains if it is missing.
Russ Cox38a41ee2009-11-06 10:04:22 -0800115</p>
116
Nathan John Youngmand5f208c2014-03-17 09:35:04 +1100117<p>
118As the codereview extension is only enabled for your Go checkout, the remainder of this document assumes you
119are inside the go directory when issuing commands.
120</p>
121
122<p>To contribute to subrepositories, edit the <code>.hg/hgrc</code> for each
123subrepository in the same way. For example, add the codereview extension to
124<code>code.google.com/p/go.tools/.hg/hgrc</code>.
125</p>
126
Patrick Higgins6bf6cae2013-06-05 21:09:43 -0700127<h3>Understanding the extension</h3>
128
129<p>After adding the code review extension, you can run</p>
130
131<pre>
132$ hg help codereview
133</pre>
134
135<p>to learn more about its commands. To learn about a specific code-review-specific
136command such as <code>change</code>, run</p>
137
138<pre>
139$ hg help change
140</pre>
141
Russ Cox111fcf12012-12-11 13:36:43 -0500142<p>
Nathan John Youngmand5f208c2014-03-17 09:35:04 +1100143Windows users may need to perform extra steps to get the code review
Rick Arnoldcea78cb2013-03-11 12:14:42 +1100144extension working. See the
Nathan John Youngmand5f208c2014-03-17 09:35:04 +1100145<a href="https://code.google.com/p/go-wiki/wiki/CodeReview">CodeReview page</a>
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800146on the <a href="https://code.google.com/p/go-wiki/wiki">Go Wiki</a> for details.
Rick Arnoldcea78cb2013-03-11 12:14:42 +1100147</p>
148
Russ Cox38a41ee2009-11-06 10:04:22 -0800149<h3>Log in to the code review site.</h3>
150
Russ Cox38a41ee2009-11-06 10:04:22 -0800151<p>
152The code review server uses a Google Account to authenticate.
153(If you can use the account to
Russ Cox830813f2009-11-08 21:08:27 -0800154<a href="https://www.google.com/accounts/Login?hl=en&amp;continue=http://www.google.com/">sign in at google.com</a>,
Caleb Spare41f32e02013-01-06 22:44:16 -0500155you can use it to sign in to the code review server.)
Russ Coxd55abfd2009-12-09 14:05:12 -0800156The email address you use on the Code Review site
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800157will be recorded in the <a href="https://code.google.com/p/go/source/list">Mercurial change log</a>
Russ Coxd55abfd2009-12-09 14:05:12 -0800158and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file.
159You can <a href="https://www.google.com/accounts/NewAccount">create a Google Account</a>
160associated with any address where you receive email.
Shenghou Ma4c473c02012-10-11 23:33:57 +0800161If you've enabled the two-step verification feature, don't forget to generate an
162application-specific password and use that when prompted for a password.
Russ Cox38a41ee2009-11-06 10:04:22 -0800163</p>
164
165<pre>
Vish Subramanian8910e422009-11-06 17:08:47 -0800166$ hg code-login
Russ Cox38a41ee2009-11-06 10:04:22 -0800167Email (login for uploading to codereview.appspot.com): rsc@golang.org
168Password for rsc@golang.org:
169
170Saving authentication cookies to /Users/rsc/.codereview_upload_cookies_codereview.appspot.com
171</pre>
172
173<h3>Configure your account settings.</h3>
174
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800175<p>Edit your <a href="https://codereview.appspot.com/settings">code review settings</a>.
Russ Cox38a41ee2009-11-06 10:04:22 -0800176Grab a nickname.
Russ Cox696e8022009-11-07 18:56:00 -0800177Many people prefer to set the Context option to
Russ Cox38a41ee2009-11-06 10:04:22 -0800178&ldquo;Whole file&rdquo; to see more context when reviewing changes.
179</p>
180
181<p>Once you have chosen a nickname in the settings page, others
182can use that nickname as a shorthand for naming reviewers and the CC list.
183For example, <code>rsc</code> is an alias for <code>rsc@golang.org</code>.
184</p>
185
Andrew Gerrand32387052012-06-05 00:55:45 +1000186<h3>Switch to the default branch</h3>
187
188<p>
189Most Go installations use a release branch, but new changes should
190only be made to the default branch. (They may be applied later to a release
191branch as part of the release process.)
192Before making a change, make sure you use the default branch:
193</p>
194
195<pre>
196$ hg update default
197</pre>
198
Russ Cox9ad14c92009-11-06 10:33:46 -0800199<h3>Make a change</h3>
Russ Cox38a41ee2009-11-06 10:04:22 -0800200
201<p>
202The entire checked-out tree is writable.
203If you need to edit files, just edit them: Mercurial will figure out which ones changed.
204You do need to inform Mercurial of added, removed, copied, or renamed files,
Russ Cox696e8022009-11-07 18:56:00 -0800205by running
Russ Cox38a41ee2009-11-06 10:04:22 -0800206<code>hg add</code>,
207<code>hg rm</code>,
208<code>hg cp</code>,
209or
210<code>hg mv</code>.
211</p>
212
Russ Cox38a41ee2009-11-06 10:04:22 -0800213<p>When you are ready to send a change out for review, run</p>
214
215<pre>
216$ hg change
217</pre>
218
219<p>from any directory in your Go repository.
220Mercurial will open a change description file in your editor.
221(It uses the editor named by the <code>$EDITOR</code> environment variable, <code>vi</code> by default.)
222The file will look like:
223</p>
224
225<pre>
226# Change list.
227# Lines beginning with # are ignored.
228# Multi-line values should be indented.
229
Russ Cox696e8022009-11-07 18:56:00 -0800230Reviewer:
231CC:
Russ Cox38a41ee2009-11-06 10:04:22 -0800232
233Description:
234 &lt;enter description here&gt;
235
236Files:
237 src/pkg/math/sin.go
238 src/pkg/math/tan.go
239 src/pkg/regexp/regexp.go
240</pre>
241
242<p>
243The <code>Reviewer</code> line lists the reviewers assigned
244to this change, and the <code>CC</code> line lists people to
245notify about the change.
246These can be code review nicknames or arbitrary email addresses.
Rob Pike9ada8412011-05-13 16:25:31 -0700247Unless explicitly told otherwise, such as in the discussion leading
Florian Weimerb1175be2011-12-13 17:45:01 -0500248up to sending in the change list, leave the reviewer field blank.
249This means that the
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800250<a href="https://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
Florian Weimerb1175be2011-12-13 17:45:01 -0500251mailing list will be used as the reviewer.
Russ Cox38a41ee2009-11-06 10:04:22 -0800252</p>
253
254<p>
255Replace &ldquo;<code>&lt;enter description here&gt;</code>&rdquo;
256with a description of your change.
Nigel Tao3f383422011-01-05 13:00:08 +1100257The first line of the change description is conventionally a one-line
258summary of the change, prefixed by the primary affected package,
259and is used as the subject for code review mail; the rest of the
Russ Cox38a41ee2009-11-06 10:04:22 -0800260description elaborates.
261</p>
262
263<p>
264The <code>Files</code> section lists all the modified files
265in your client.
266It is best to keep unrelated changes in different change lists.
267In this example, we can include just the changes to package <code>math</code>
268by deleting the line mentioning <code>regexp.go</code>.
Russ Cox696e8022009-11-07 18:56:00 -0800269</p>
270
271<p>
272After editing, the template might now read:
Russ Cox38a41ee2009-11-06 10:04:22 -0800273</p>
274
275<pre>
276# Change list.
277# Lines beginning with # are ignored.
278# Multi-line values should be indented.
279
Shawn Smith2f5f1932013-12-29 11:11:28 -0800280Reviewer: golang-codereviews@googlegroups.com
Russ Cox38a41ee2009-11-06 10:04:22 -0800281CC: math-nuts@swtch.com
282
283Description:
Nigel Tao3f383422011-01-05 13:00:08 +1100284 math: improved Sin, Cos and Tan precision for very large arguments.
Russ Cox696e8022009-11-07 18:56:00 -0800285
Russ Cox38a41ee2009-11-06 10:04:22 -0800286 See Bimmler and Shaney, ``Extreme sinusoids,'' J. Math 3(14).
287 Fixes issue 159.
288
289Files:
290 src/pkg/math/sin.go
291 src/pkg/math/tan.go
292</pre>
293
294<p>
295The special sentence &ldquo;Fixes issue 159.&rdquo; associates
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800296the change with issue 159 in the <a href="https://code.google.com/p/go/issues/list">Go issue tracker</a>.
Russ Cox38a41ee2009-11-06 10:04:22 -0800297When this change is eventually submitted, the issue
298tracker will automatically mark the issue as fixed.
Matthew Dempsky7d403872013-01-10 14:17:20 +1100299(These conventions are described in detail by the
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800300<a href="https://code.google.com/p/support/wiki/IssueTracker#Integration_with_version_control">Google Project Hosting Issue Tracker documentation</a>.)
Russ Cox38a41ee2009-11-06 10:04:22 -0800301</p>
302
303<p>
304Save the file and exit the editor.</p>
305
306<p>
307The code review server assigns your change an issue number and URL,
308which <code>hg change</code> will print, something like:
309</p>
310
311<pre>
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800312CL created: https://codereview.appspot.com/99999
Russ Cox38a41ee2009-11-06 10:04:22 -0800313</pre>
314
Bill Thiede822b2cb2014-07-03 17:42:23 -0400315<h3>Mail the change for review</h3>
316
317<p>
318Creating or uploading the change uploads a copy of the diff to the code review server,
319but it does not notify anyone about it. To do that, you need to run <code>hg mail</code>
320(see below).
321</p>
322
323<p>To send out a change for review, run <code>hg mail</code> using the change list number
324assigned during <code>hg change</code>:</p>
325
326<pre>
327$ hg mail 99999
328</pre>
329
330<p>You can add to the <code>Reviewer:</code> and <code>CC:</code> lines
331using the <code>-r</code> or <code>--cc</code> options.
332In the above example, we could have left the <code>Reviewer</code> and <code>CC</code>
333lines blank and then run:
334</p>
335
336<pre>
337$ hg mail -r golang-codereviews@googlegroups.com --cc math-nuts@swtch.com 99999
338</pre>
339
340<p>to achieve the same effect.</p>
341
342<p>Note that <code>-r</code> and <code>--cc</code> cannot be spelled <code>--r</code> or <code>-cc</code>.</p>
343
344<p>
345If your change relates to an open issue, please add a comment to the issue
346announcing your proposed fix, including a link to your CL.
347</p>
348
349<h3>Reviewing code</h3>
350
351<p>
352Running <code>hg mail</code> will send an email to you and the reviewers
353asking them to visit the issue's URL and make comments on the change.
354When done, the reviewer clicks &ldquo;Publish and Mail comments&rdquo;
355to send comments back.
356</p>
357
358
359<h3>Revise and upload</h3>
360
361<p>
362When you have revised the code and are ready for another round of review,
363you can upload your change and send mail asking the reviewers to
364please take another look (<code>PTAL</code>). Use the change list number
365assigned during <code>hg change</code>
366</p>
367
368<pre>
369$ hg mail 99999
370</pre>
371
372
373<p>
374Or to upload your change without sending a notification, run
375</p>
376
377<pre>
378$ hg upload 99999
379</pre>
380
381<p>
382You will probably revise your code in response to the reviewer comments.
383You might also visit the code review web page and reply to the comments,
384letting the reviewer know that you've addressed them or explain why you
385haven't. When you're done replying, click &ldquo;Publish and Mail comments&rdquo;
386to send the line-by-line replies and any other comments.
387</p>
388
389<p>
390The reviewer can comment on the new copy, and the process repeats.
391The reviewer approves the change by replying with a mail that says
392<code>LGTM</code>: looks good to me.
393</p>
394
395<p>
396You can see a list of your pending changes by running <code>hg pending</code> (<code>hg p</code> for short).
397</p>
398
Dave Cheneyeda95902013-02-10 19:40:33 -0500399<h3>Adding or removing files from an existing change</h3>
400
Russ Cox38a41ee2009-11-06 10:04:22 -0800401<p>
Shenghou Ma4c473c02012-10-11 23:33:57 +0800402If you need to re-edit the change description, or change the files included in the CL,
Dave Cheneyeda95902013-02-10 19:40:33 -0500403run <code>hg change 99999</code>.
Russ Cox38a41ee2009-11-06 10:04:22 -0800404</p>
405
406<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500407Alternatively, you can use
Rob Pike7ae41e82013-02-28 13:32:36 -0800408</p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500409
410<pre>
411$ hg file 99999 somefile
412</pre>
413
414<p>
415to add <code>somefile</code> to CL 99999, and
416</p>
417
418<pre>
419$ hg file -d 99999 somefile
420</pre>
421
422<p>
423to remove <code>somefile</code> from the CL.
Russ Coxc64469f2013-01-18 14:08:42 -0500424</p>
425
426<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500427A file may only belong to a single active CL at a time. <code>hg file</code>
428will issue a warning if a file is moved between changes.
Russ Cox38a41ee2009-11-06 10:04:22 -0800429</p>
430
Russ Cox38a41ee2009-11-06 10:04:22 -0800431<h3>Synchronize your client</h3>
432
433<p>While you were working, others might have submitted changes
434to the repository. To update your client, run</p>
435
436<pre>
437$ hg sync
438</pre>
439
440<p>(For Mercurial fans, <code>hg sync</code> runs <code>hg pull -u</code>
441but then also synchronizes the local change list state against the new data.)</p>
442
443<p>
444If files you were editing have changed, Mercurial does its best to merge the
Russ Cox696e8022009-11-07 18:56:00 -0800445remote changes into your local changes. It may leave some files to merge by hand.
446</p>
447
448<p>
449For example, suppose you have edited <code>flag_test.go</code> but
450someone else has committed an independent change.
451When you run <code>hg sync</code>, you will get the (scary-looking) output
452(emphasis added):
Russ Cox38a41ee2009-11-06 10:04:22 -0800453
454<pre>
Russ Cox696e8022009-11-07 18:56:00 -0800455$ hg sync
456adding changesets
457adding manifests
458adding file changes
459added 1 changeset with 2 changes to 2 files
460getting src/pkg/flag/flag.go
461couldn't find merge tool hgmerge
462merging src/pkg/flag/flag_test.go
463warning: conflicts during merge.
464<i>merging src/pkg/flag/flag_test.go failed!</i>
4651 file updated, 0 files merged, 0 files removed, 1 file unresolved
466use 'hg resolve' to retry unresolved file merges
Russ Cox830813f2009-11-08 21:08:27 -0800467$
Russ Cox38a41ee2009-11-06 10:04:22 -0800468</pre>
469
Russ Cox696e8022009-11-07 18:56:00 -0800470<p>
471The only important part in that transcript is the italicized line:
472Mercurial failed to merge your changes with the independent change.
473When this happens, Mercurial leaves both edits in the file,
474marked by <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and
475<code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>.
476it is now your job to edit the file to combine them.
477Continuing the example, searching for those strings in <code>flag_test.go</code>
478might turn up:
479</p>
480
481<pre>
482 VisitAll(visitor);
483&lt;&lt;&lt;&lt;&lt;&lt;&lt; local
484 if len(m) != 7 {
485=======
486 if len(m) != 8 {
487&gt;&gt;&gt;&gt;&gt;&gt;&gt; other
488 t.Error("VisitAll misses some flags");
489</pre>
490
491<p>
492Mercurial doesn't show it, but suppose the original text that both edits
493started with was 6; you added 1 and the other change added 2,
Russ Coxd55abfd2009-12-09 14:05:12 -0800494so the correct answer might now be 9. First, edit the section
Russ Cox696e8022009-11-07 18:56:00 -0800495to remove the markers and leave the correct code:
496</p>
497
498<pre>
499 VisitAll(visitor);
500 if len(m) != 9 {
501 t.Error("VisitAll misses some flags");
502</pre>
503
504<p>
Russ Coxd55abfd2009-12-09 14:05:12 -0800505Then ask Mercurial to mark the conflict as resolved:
Russ Cox696e8022009-11-07 18:56:00 -0800506</p>
507
Russ Coxd55abfd2009-12-09 14:05:12 -0800508<pre>
509$ hg resolve -m flag_test.go
510</pre>
511
Russ Cox696e8022009-11-07 18:56:00 -0800512<p>
Russ Cox830813f2009-11-08 21:08:27 -0800513If you had been editing the file, say for debugging, but do not
514care to preserve your changes, you can run
Russ Cox696e8022009-11-07 18:56:00 -0800515<code>hg revert flag_test.go</code> to abandon your
Russ Coxd55abfd2009-12-09 14:05:12 -0800516changes, but you may still need to run
517<code>hg resolve -m</code> to mark the conflict resolved.
Russ Cox696e8022009-11-07 18:56:00 -0800518</p>
519
Dave Cheneyeda95902013-02-10 19:40:33 -0500520<h3>Reviewing code by others</h3>
521
522<p>
523You can import a CL proposed by someone else into your local Mercurial client
524by using the <code>hg clpatch</code> command. Running
525</p>
526
527<pre>
528$ hg clpatch 99999
529</pre>
530
531<p>
532will apply the latest diff for CL 99999 to your working copy. If any of the
533files referenced in CL 99999 have local modifications, <code>clpatch</code>
534will refuse to apply the whole diff. Once applied, CL 99999 will show up in
535the output of <code>hg pending</code> and others.
536</p>
537
538<p>
539To revert a CL you have applied locally, use the <code>hg revert</code>
540command. Running
541</p>
542
543<pre>
544$ hg revert @99999
545</pre>
546
547<p>
548will revert any files mentioned on CL 99999 to their original state. This can
549be an effective way of reverting one CL revision and applying another.
550</p>
551
552<p>
553Once the CL has been submitted, the next time you run <code>hg sync</code>
554it will be removed from your local pending list. Occasionally the pending list
Oling Cataecbcd02013-02-15 14:01:12 +1100555can get out of sync leaving stale references to closed or abandoned CLs.
Dave Cheneyeda95902013-02-10 19:40:33 -0500556You can use <code>hg change -D 99999</code> to remove the reference to CL 99999.
Oling Cataecbcd02013-02-15 14:01:12 +1100557</p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500558
Russ Cox5facb842009-12-09 14:39:41 -0800559<h3>Submit the change after the review</h3>
Russ Cox38a41ee2009-11-06 10:04:22 -0800560
561<p>
Russ Cox5facb842009-12-09 14:39:41 -0800562After the code has been <code>LGTM</code>'ed, it is time to submit
Oling Cataecbcd02013-02-15 14:01:12 +1100563it to the Mercurial repository.
Dave Cheneyeda95902013-02-10 19:40:33 -0500564</p>
565
566<p>
567If you are not a committer, you cannot submit the change directly.
568Instead a committer, usually the reviewer who said <code>LGTM</code>,
569will run:
570</p>
571
572<pre>
573$ hg clpatch 99999
574$ hg submit 99999
575</pre>
576
Oling Cataecbcd02013-02-15 14:01:12 +1100577<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500578The <code>submit</code> command submits the code. You will be listed as the
579author, but the change message will also indicate who the committer was.
580Your local client will notice that the change has been submitted
581when you next run <code>hg sync</code>.
582</p>
583
584<p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800585If you are a committer, you can run:
586</p>
587
588<pre>
589$ hg submit 99999
590</pre>
591
592<p>
593This checks the change into the repository.
594The change description will include a link to the code review,
595and the code review will be updated with a link to the change
596in the repository.
597</p>
598
599<p>
600If your local copy of the repository is out of date,
Oling Cataecbcd02013-02-15 14:01:12 +1100601<code>hg submit</code> will refuse the change:
Russ Cox38a41ee2009-11-06 10:04:22 -0800602</p>
603
604<pre>
Russ Coxd55abfd2009-12-09 14:05:12 -0800605$ hg submit 99999
Russ Cox38a41ee2009-11-06 10:04:22 -0800606local repository out of date; must sync before submit
607</pre>
608
Robert Hencke75ba1812014-04-25 20:09:04 -0700609<h3>More information</h3>
610
611<p>
612In addition to the information here, the Go community maintains a <a href="https://code.google.com/p/go-wiki/wiki/CodeReview">CodeReview</a> wiki page.
613Feel free to contribute to this page as you learn the review process.
614</p>
615
Dave Cheneyeda95902013-02-10 19:40:33 -0500616<h2 id="copyright">Copyright</h2>
Russ Cox38a41ee2009-11-06 10:04:22 -0800617
Russ Coxd55abfd2009-12-09 14:05:12 -0800618<p>Files in the Go repository don't list author names,
619both to avoid clutter and to avoid having to keep the lists up to date.
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800620Instead, your name will appear in the <a href="https://code.google.com/p/go/source/list">Mercurial change log</a>
Russ Coxd55abfd2009-12-09 14:05:12 -0800621and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
622and perhaps the <a href="/AUTHORS"><code>AUTHORS</code></a> file.
623</p>
624
625<p>The <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
626defines who the Go contributors&mdash;the people&mdash;are;
Caleb Spare41f32e02013-01-06 22:44:16 -0500627the <a href="/AUTHORS"><code>AUTHORS</code></a> file defines
Russ Coxd55abfd2009-12-09 14:05:12 -0800628who &ldquo;The Go Authors&rdquo;&mdash;the copyright holders&mdash;are.
629The Go developers at Google will update these files when submitting
630your first change.
631In order for them to do that, you need to have completed one of the
632contributor license agreements:
633<ul>
634<li>
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800635If you are the copyright holder, you will need to agree to the
636<a href="https://developers.google.com/open-source/cla/individual">individual
Russ Coxd55abfd2009-12-09 14:05:12 -0800637contributor license agreement</a>, which can be completed online.
638</li>
639<li>
640If your organization is the copyright holder, the organization
Brad Fitzpatrick967901a2014-03-05 14:09:03 -0800641will need to agree to the
642<a href="https://developers.google.com/open-source/cla/corporate">corporate
643contributor license agreement</a>.
Russ Coxd55abfd2009-12-09 14:05:12 -0800644(If the copyright holder for your code has already completed the
645agreement in connection with another Google open source project,
646it does not need to be completed again.)
647</li>
648</ul>
649
650<p>
651This rigmarole needs to be done only for your first submission.
652</p>
653
654<p>Code that you contribute should use the standard copyright header:</p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800655
656<pre>
David Symonds8f3fc5472014-01-01 00:00:22 +1100657// Copyright 2014 The Go Authors. All rights reserved.
Russ Cox38a41ee2009-11-06 10:04:22 -0800658// Use of this source code is governed by a BSD-style
659// license that can be found in the LICENSE file.
660</pre>
Dave Cheneyeda95902013-02-10 19:40:33 -0500661
662<p>
663Files in the repository are copyright the year they are added. It is not
664necessary to update the copyright year on files that you change.
665</p>