blob: bd0ba808d2312e7927fc272bd6745995aa4a8e16 [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
25mail to the <a href="http://groups.google.com/group/golang-nuts">mailing
26list</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>
48cd $GOROOT/src
Shenghou Ma4c473c02012-10-11 23:33:57 +080049./all.bash # On Windows, run all.bat
Russ Cox38a41ee2009-11-06 10:04:22 -080050</pre>
51
52<p>
Shenghou Ma4c473c02012-10-11 23:33:57 +080053After running for a while, the command should print "<code>ALL TESTS PASSED</code>".
Russ Cox38a41ee2009-11-06 10:04:22 -080054</p>
55
Russ Cox6c7f9f62009-11-09 16:56:17 -080056<h2 id="Code_review">Code review</h2>
Russ Cox38a41ee2009-11-06 10:04:22 -080057
58<p>
59Changes to Go must be reviewed before they are submitted,
60no matter who makes the change.
Russ Cox9ad14c92009-11-06 10:33:46 -080061(In exceptional cases, such as fixing a build, the review can
62follow shortly after submitting.)
Russ Cox38a41ee2009-11-06 10:04:22 -080063A Mercurial extension helps manage the code review process.
64The extension is included in the Go source tree but needs
65to be added to your Mercurial configuration.
66</p>
67
Russ Cox9ad14c92009-11-06 10:33:46 -080068<h3>Caveat for Mercurial aficionados</h3>
69
Russ Cox38a41ee2009-11-06 10:04:22 -080070<p>
71<i>Using Mercurial with the code review extension is not the same
Russ Cox9ad14c92009-11-06 10:33:46 -080072as using standard Mercurial.</i>
Russ Cox38a41ee2009-11-06 10:04:22 -080073</p>
74
75<p>
Russ Cox9ad14c92009-11-06 10:33:46 -080076The Go repository is maintained as a single line of reviewed changes;
77we prefer to avoid the complexity of Mercurial's arbitrary change graph.
78The code review extension helps here: its <code>hg submit</code> command
79automatically checks for and warns about the local repository
80being out of date compared to the remote one.
81The <code>hg submit</code> command also verifies other
82properties about the Go repository.
Russ Cox696e8022009-11-07 18:56:00 -080083For example,
Russ Cox9ad14c92009-11-06 10:33:46 -080084it checks that Go code being checked in is formatted in the standard style,
85as defined by <a href="/cmd/gofmt">gofmt</a>,
86and it checks that the author of the code is properly recorded for
87<a href="#copyright">copyright purposes</a>.
88</p>
89
90<p>
91To help ensure changes are only created by <code>hg submit</code>,
92the code review extension disables the standard <code>hg commit</code>
93command.
94</p>
95
Russ Cox38a41ee2009-11-06 10:04:22 -080096<h3>Configure the extension</h3>
97
Russ Cox38a41ee2009-11-06 10:04:22 -080098<p>Edit <code>$GOROOT/.hg/hgrc</code> to add:</p>
99
100<pre>
101[extensions]
David Symonds156d85c2012-10-08 22:24:41 +1100102codereview = $GOROOT/lib/codereview/codereview.py
Russ Coxd55abfd2009-12-09 14:05:12 -0800103
104[ui]
105username = Your Name &lt;you@server.dom&gt;
Russ Cox38a41ee2009-11-06 10:04:22 -0800106</pre>
107
David Symonds156d85c2012-10-08 22:24:41 +1100108<p>
Russ Coxd55abfd2009-12-09 14:05:12 -0800109The <code>username</code> information will not be used unless
110you are a committer (see below), but Mercurial complains if it is missing.
Russ Cox38a41ee2009-11-06 10:04:22 -0800111</p>
112
Patrick Higgins6bf6cae2013-06-05 21:09:43 -0700113<h3>Understanding the extension</h3>
114
115<p>After adding the code review extension, you can run</p>
116
117<pre>
118$ hg help codereview
119</pre>
120
121<p>to learn more about its commands. To learn about a specific code-review-specific
122command such as <code>change</code>, run</p>
123
124<pre>
125$ hg help change
126</pre>
127
Russ Cox111fcf12012-12-11 13:36:43 -0500128<p>
Patrick Higgins6bf6cae2013-06-05 21:09:43 -0700129As the codereview extension is only enabled for your checkout
130in <code>$GOROOT</code>, the remainder of this document assumes you
131are inside <code>$GOROOT</code> when issuing commands.
Russ Cox111fcf12012-12-11 13:36:43 -0500132</p>
133
Rick Arnoldcea78cb2013-03-11 12:14:42 +1100134<p>
135Windows users may need to perform extra steps to get the code review
136extension working. See the
137<a href="https://code.google.com/p/go-wiki/wiki/CodeReview">CodeReview page</a>
138on the <a href="http://code.google.com/p/go-wiki/wiki">Go Wiki</a> for details.
139</p>
140
Russ Cox38a41ee2009-11-06 10:04:22 -0800141<h3>Log in to the code review site.</h3>
142
Russ Cox38a41ee2009-11-06 10:04:22 -0800143<p>
144The code review server uses a Google Account to authenticate.
145(If you can use the account to
Russ Cox830813f2009-11-08 21:08:27 -0800146<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 -0500147you can use it to sign in to the code review server.)
Russ Coxd55abfd2009-12-09 14:05:12 -0800148The email address you use on the Code Review site
149will be recorded in the <a href="http://code.google.com/p/go/source/list">Mercurial change log</a>
150and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file.
151You can <a href="https://www.google.com/accounts/NewAccount">create a Google Account</a>
152associated with any address where you receive email.
Shenghou Ma4c473c02012-10-11 23:33:57 +0800153If you've enabled the two-step verification feature, don't forget to generate an
154application-specific password and use that when prompted for a password.
Russ Cox38a41ee2009-11-06 10:04:22 -0800155</p>
156
157<pre>
158$ cd $GOROOT
Vish Subramanian8910e422009-11-06 17:08:47 -0800159$ hg code-login
Russ Cox38a41ee2009-11-06 10:04:22 -0800160Email (login for uploading to codereview.appspot.com): rsc@golang.org
161Password for rsc@golang.org:
162
163Saving authentication cookies to /Users/rsc/.codereview_upload_cookies_codereview.appspot.com
164</pre>
165
166<h3>Configure your account settings.</h3>
167
Russ Cox6672eb32009-11-10 18:06:50 -0800168<p>Edit your <a href="http://codereview.appspot.com/settings">code review settings</a>.
Russ Cox38a41ee2009-11-06 10:04:22 -0800169Grab a nickname.
Russ Cox696e8022009-11-07 18:56:00 -0800170Many people prefer to set the Context option to
Russ Cox38a41ee2009-11-06 10:04:22 -0800171&ldquo;Whole file&rdquo; to see more context when reviewing changes.
172</p>
173
174<p>Once you have chosen a nickname in the settings page, others
175can use that nickname as a shorthand for naming reviewers and the CC list.
176For example, <code>rsc</code> is an alias for <code>rsc@golang.org</code>.
177</p>
178
Andrew Gerrand32387052012-06-05 00:55:45 +1000179<h3>Switch to the default branch</h3>
180
181<p>
182Most Go installations use a release branch, but new changes should
183only be made to the default branch. (They may be applied later to a release
184branch as part of the release process.)
185Before making a change, make sure you use the default branch:
186</p>
187
188<pre>
189$ hg update default
190</pre>
191
Russ Cox9ad14c92009-11-06 10:33:46 -0800192<h3>Make a change</h3>
Russ Cox38a41ee2009-11-06 10:04:22 -0800193
194<p>
195The entire checked-out tree is writable.
196If you need to edit files, just edit them: Mercurial will figure out which ones changed.
197You do need to inform Mercurial of added, removed, copied, or renamed files,
Russ Cox696e8022009-11-07 18:56:00 -0800198by running
Russ Cox38a41ee2009-11-06 10:04:22 -0800199<code>hg add</code>,
200<code>hg rm</code>,
201<code>hg cp</code>,
202or
203<code>hg mv</code>.
204</p>
205
Russ Cox38a41ee2009-11-06 10:04:22 -0800206<p>When you are ready to send a change out for review, run</p>
207
208<pre>
209$ hg change
210</pre>
211
212<p>from any directory in your Go repository.
213Mercurial will open a change description file in your editor.
214(It uses the editor named by the <code>$EDITOR</code> environment variable, <code>vi</code> by default.)
215The file will look like:
216</p>
217
218<pre>
219# Change list.
220# Lines beginning with # are ignored.
221# Multi-line values should be indented.
222
Russ Cox696e8022009-11-07 18:56:00 -0800223Reviewer:
224CC:
Russ Cox38a41ee2009-11-06 10:04:22 -0800225
226Description:
227 &lt;enter description here&gt;
228
229Files:
230 src/pkg/math/sin.go
231 src/pkg/math/tan.go
232 src/pkg/regexp/regexp.go
233</pre>
234
235<p>
236The <code>Reviewer</code> line lists the reviewers assigned
237to this change, and the <code>CC</code> line lists people to
238notify about the change.
239These can be code review nicknames or arbitrary email addresses.
Rob Pike9ada8412011-05-13 16:25:31 -0700240Unless explicitly told otherwise, such as in the discussion leading
Florian Weimerb1175be2011-12-13 17:45:01 -0500241up to sending in the change list, leave the reviewer field blank.
242This means that the
Shawn Smith2f5f1932013-12-29 11:11:28 -0800243<a href="http://groups.google.com/group/golang-codereviews">golang-codereviews@googlegroups.com</a>
Florian Weimerb1175be2011-12-13 17:45:01 -0500244mailing list will be used as the reviewer.
Russ Cox38a41ee2009-11-06 10:04:22 -0800245</p>
246
247<p>
248Replace &ldquo;<code>&lt;enter description here&gt;</code>&rdquo;
249with a description of your change.
Nigel Tao3f383422011-01-05 13:00:08 +1100250The first line of the change description is conventionally a one-line
251summary of the change, prefixed by the primary affected package,
252and is used as the subject for code review mail; the rest of the
Russ Cox38a41ee2009-11-06 10:04:22 -0800253description elaborates.
254</p>
255
256<p>
257The <code>Files</code> section lists all the modified files
258in your client.
259It is best to keep unrelated changes in different change lists.
260In this example, we can include just the changes to package <code>math</code>
261by deleting the line mentioning <code>regexp.go</code>.
Russ Cox696e8022009-11-07 18:56:00 -0800262</p>
263
264<p>
265After editing, the template might now read:
Russ Cox38a41ee2009-11-06 10:04:22 -0800266</p>
267
268<pre>
269# Change list.
270# Lines beginning with # are ignored.
271# Multi-line values should be indented.
272
Shawn Smith2f5f1932013-12-29 11:11:28 -0800273Reviewer: golang-codereviews@googlegroups.com
Russ Cox38a41ee2009-11-06 10:04:22 -0800274CC: math-nuts@swtch.com
275
276Description:
Nigel Tao3f383422011-01-05 13:00:08 +1100277 math: improved Sin, Cos and Tan precision for very large arguments.
Russ Cox696e8022009-11-07 18:56:00 -0800278
Russ Cox38a41ee2009-11-06 10:04:22 -0800279 See Bimmler and Shaney, ``Extreme sinusoids,'' J. Math 3(14).
280 Fixes issue 159.
281
282Files:
283 src/pkg/math/sin.go
284 src/pkg/math/tan.go
285</pre>
286
287<p>
288The special sentence &ldquo;Fixes issue 159.&rdquo; associates
289the change with issue 159 in the <a href="http://code.google.com/p/go/issues/list">Go issue tracker</a>.
290When this change is eventually submitted, the issue
291tracker will automatically mark the issue as fixed.
Matthew Dempsky7d403872013-01-10 14:17:20 +1100292(These conventions are described in detail by the
293<a href="http://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 -0800294</p>
295
296<p>
297Save the file and exit the editor.</p>
298
299<p>
300The code review server assigns your change an issue number and URL,
301which <code>hg change</code> will print, something like:
302</p>
303
304<pre>
305CL created: http://codereview.appspot.com/99999
306</pre>
307
Dave Cheneyeda95902013-02-10 19:40:33 -0500308<h3>Adding or removing files from an existing change</h3>
309
Russ Cox38a41ee2009-11-06 10:04:22 -0800310<p>
Shenghou Ma4c473c02012-10-11 23:33:57 +0800311If you need to re-edit the change description, or change the files included in the CL,
Dave Cheneyeda95902013-02-10 19:40:33 -0500312run <code>hg change 99999</code>.
Russ Cox38a41ee2009-11-06 10:04:22 -0800313</p>
314
315<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500316Alternatively, you can use
Rob Pike7ae41e82013-02-28 13:32:36 -0800317</p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500318
319<pre>
320$ hg file 99999 somefile
321</pre>
322
323<p>
324to add <code>somefile</code> to CL 99999, and
325</p>
326
327<pre>
328$ hg file -d 99999 somefile
329</pre>
330
331<p>
332to remove <code>somefile</code> from the CL.
Russ Coxc64469f2013-01-18 14:08:42 -0500333</p>
334
335<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500336A file may only belong to a single active CL at a time. <code>hg file</code>
337will issue a warning if a file is moved between changes.
Russ Cox38a41ee2009-11-06 10:04:22 -0800338</p>
339
Russ Cox38a41ee2009-11-06 10:04:22 -0800340<h3>Synchronize your client</h3>
341
342<p>While you were working, others might have submitted changes
343to the repository. To update your client, run</p>
344
345<pre>
346$ hg sync
347</pre>
348
349<p>(For Mercurial fans, <code>hg sync</code> runs <code>hg pull -u</code>
350but then also synchronizes the local change list state against the new data.)</p>
351
352<p>
353If files you were editing have changed, Mercurial does its best to merge the
Russ Cox696e8022009-11-07 18:56:00 -0800354remote changes into your local changes. It may leave some files to merge by hand.
355</p>
356
357<p>
358For example, suppose you have edited <code>flag_test.go</code> but
359someone else has committed an independent change.
360When you run <code>hg sync</code>, you will get the (scary-looking) output
361(emphasis added):
Russ Cox38a41ee2009-11-06 10:04:22 -0800362
363<pre>
Russ Cox696e8022009-11-07 18:56:00 -0800364$ hg sync
365adding changesets
366adding manifests
367adding file changes
368added 1 changeset with 2 changes to 2 files
369getting src/pkg/flag/flag.go
370couldn't find merge tool hgmerge
371merging src/pkg/flag/flag_test.go
372warning: conflicts during merge.
373<i>merging src/pkg/flag/flag_test.go failed!</i>
3741 file updated, 0 files merged, 0 files removed, 1 file unresolved
375use 'hg resolve' to retry unresolved file merges
Russ Cox830813f2009-11-08 21:08:27 -0800376$
Russ Cox38a41ee2009-11-06 10:04:22 -0800377</pre>
378
Russ Cox696e8022009-11-07 18:56:00 -0800379<p>
380The only important part in that transcript is the italicized line:
381Mercurial failed to merge your changes with the independent change.
382When this happens, Mercurial leaves both edits in the file,
383marked by <code>&lt;&lt;&lt;&lt;&lt;&lt;&lt;</code> and
384<code>&gt;&gt;&gt;&gt;&gt;&gt;&gt;</code>.
385it is now your job to edit the file to combine them.
386Continuing the example, searching for those strings in <code>flag_test.go</code>
387might turn up:
388</p>
389
390<pre>
391 VisitAll(visitor);
392&lt;&lt;&lt;&lt;&lt;&lt;&lt; local
393 if len(m) != 7 {
394=======
395 if len(m) != 8 {
396&gt;&gt;&gt;&gt;&gt;&gt;&gt; other
397 t.Error("VisitAll misses some flags");
398</pre>
399
400<p>
401Mercurial doesn't show it, but suppose the original text that both edits
402started with was 6; you added 1 and the other change added 2,
Russ Coxd55abfd2009-12-09 14:05:12 -0800403so the correct answer might now be 9. First, edit the section
Russ Cox696e8022009-11-07 18:56:00 -0800404to remove the markers and leave the correct code:
405</p>
406
407<pre>
408 VisitAll(visitor);
409 if len(m) != 9 {
410 t.Error("VisitAll misses some flags");
411</pre>
412
413<p>
Russ Coxd55abfd2009-12-09 14:05:12 -0800414Then ask Mercurial to mark the conflict as resolved:
Russ Cox696e8022009-11-07 18:56:00 -0800415</p>
416
Russ Coxd55abfd2009-12-09 14:05:12 -0800417<pre>
418$ hg resolve -m flag_test.go
419</pre>
420
Russ Cox696e8022009-11-07 18:56:00 -0800421<p>
Russ Cox830813f2009-11-08 21:08:27 -0800422If you had been editing the file, say for debugging, but do not
423care to preserve your changes, you can run
Russ Cox696e8022009-11-07 18:56:00 -0800424<code>hg revert flag_test.go</code> to abandon your
Russ Coxd55abfd2009-12-09 14:05:12 -0800425changes, but you may still need to run
426<code>hg resolve -m</code> to mark the conflict resolved.
Russ Cox696e8022009-11-07 18:56:00 -0800427</p>
428
Russ Cox38a41ee2009-11-06 10:04:22 -0800429<h3>Mail the change for review</h3>
430
Dave Cheneyeda95902013-02-10 19:40:33 -0500431<p>
432Creating or uploading the change uploads a copy of the diff to the code review server,
433but it does not notify anyone about it. To do that, you need to run <code>hg mail</code>
434(see below).
435</p>
436
Russ Cox38a41ee2009-11-06 10:04:22 -0800437<p>To send out a change for review, run <code>hg mail</code> using the change list number
438assigned during <code>hg change</code>:</p>
439
440<pre>
441$ hg mail 99999
442</pre>
443
444<p>You can add to the <code>Reviewer:</code> and <code>CC:</code> lines
Russ Cox696e8022009-11-07 18:56:00 -0800445using the <code>-r</code> or <code>--cc</code> options.
446In the above example, we could have left the <code>Reviewer</code> and <code>CC</code>
Russ Cox38a41ee2009-11-06 10:04:22 -0800447lines blank and then run:
448</p>
449
450<pre>
Shawn Smith2f5f1932013-12-29 11:11:28 -0800451$ hg mail -r golang-codereviews@googlegroups.com --cc math-nuts@swtch.com 99999
Russ Cox38a41ee2009-11-06 10:04:22 -0800452</pre>
453
454<p>to achieve the same effect.</p>
455
456<p>Note that <code>-r</code> and <code>--cc</code> cannot be spelled <code>--r</code> or <code>-cc</code>.</p>
457
Dave Cheneyeda95902013-02-10 19:40:33 -0500458<p>
459If your change relates to an open issue, please add a comment to the issue
460announcing your proposed fix, including a link to your CL.
461</p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800462
463<h3>Reviewing code</h3>
464
465<p>
466Running <code>hg mail</code> will send an email to you and the reviewers
Jeremy Jackins959d0c72012-03-10 15:13:34 -0800467asking them to visit the issue's URL and make comments on the change.
Russ Cox38a41ee2009-11-06 10:04:22 -0800468When done, the reviewer clicks &ldquo;Publish and Mail comments&rdquo;
469to send comments back.
470</p>
471
472
473<h3>Revise and upload</h3>
474
Dave Cheneyeda95902013-02-10 19:40:33 -0500475<p>
476You will probably revise your code in response to the reviewer comments. When
477you have done this, you can upload your change to the code review server
478without sending a notification by running <code>hg upload</code> using the change
479list number assigned during <code>hg change</code>
480</p>
481
482<pre>
483$ hg upload 99999
484</pre>
485
486<p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800487When you have revised the code and are ready for another round of review, run
488</p>
489
490<pre>
Russ Coxc6336152010-01-13 16:44:40 -0800491$ hg mail 99999
Russ Cox38a41ee2009-11-06 10:04:22 -0800492</pre>
493
Russ Coxc6336152010-01-13 16:44:40 -0800494<p>again to upload the latest copy and send mail asking the reviewers to please take another look
495(<code>PTAL</code>).
Russ Cox38a41ee2009-11-06 10:04:22 -0800496You might also visit the code review web page and reply to the comments,
497letting the reviewer know that you've addressed them or explain why you
498haven't. When you're done replying, click &ldquo;Publish and Mail comments&rdquo;
499to send the line-by-line replies and any other comments.
Russ Cox38a41ee2009-11-06 10:04:22 -0800500</p>
501<p>
502The reviewer can comment on the new copy, and the process repeats.
503The reviewer approves the change by replying with a mail that says
504<code>LGTM</code>: looks good to me.
505</p>
506
Dave Cheneyeda95902013-02-10 19:40:33 -0500507<p>
508You can see a list of your pending changes by running <code>hg pending</code> (<code>hg p</code> for short).
509</p>
510
511<h3>Reviewing code by others</h3>
512
513<p>
514You can import a CL proposed by someone else into your local Mercurial client
515by using the <code>hg clpatch</code> command. Running
516</p>
517
518<pre>
519$ hg clpatch 99999
520</pre>
521
522<p>
523will apply the latest diff for CL 99999 to your working copy. If any of the
524files referenced in CL 99999 have local modifications, <code>clpatch</code>
525will refuse to apply the whole diff. Once applied, CL 99999 will show up in
526the output of <code>hg pending</code> and others.
527</p>
528
529<p>
530To revert a CL you have applied locally, use the <code>hg revert</code>
531command. Running
532</p>
533
534<pre>
535$ hg revert @99999
536</pre>
537
538<p>
539will revert any files mentioned on CL 99999 to their original state. This can
540be an effective way of reverting one CL revision and applying another.
541</p>
542
543<p>
544Once the CL has been submitted, the next time you run <code>hg sync</code>
545it will be removed from your local pending list. Occasionally the pending list
Oling Cataecbcd02013-02-15 14:01:12 +1100546can get out of sync leaving stale references to closed or abandoned CLs.
Dave Cheneyeda95902013-02-10 19:40:33 -0500547You can use <code>hg change -D 99999</code> to remove the reference to CL 99999.
Oling Cataecbcd02013-02-15 14:01:12 +1100548</p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500549
Russ Cox5facb842009-12-09 14:39:41 -0800550<h3>Submit the change after the review</h3>
Russ Cox38a41ee2009-11-06 10:04:22 -0800551
552<p>
Russ Cox5facb842009-12-09 14:39:41 -0800553After the code has been <code>LGTM</code>'ed, it is time to submit
Oling Cataecbcd02013-02-15 14:01:12 +1100554it to the Mercurial repository.
Dave Cheneyeda95902013-02-10 19:40:33 -0500555</p>
556
557<p>
558If you are not a committer, you cannot submit the change directly.
559Instead a committer, usually the reviewer who said <code>LGTM</code>,
560will run:
561</p>
562
563<pre>
564$ hg clpatch 99999
565$ hg submit 99999
566</pre>
567
Oling Cataecbcd02013-02-15 14:01:12 +1100568<p>
Dave Cheneyeda95902013-02-10 19:40:33 -0500569The <code>submit</code> command submits the code. You will be listed as the
570author, but the change message will also indicate who the committer was.
571Your local client will notice that the change has been submitted
572when you next run <code>hg sync</code>.
573</p>
574
575<p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800576If you are a committer, you can run:
577</p>
578
579<pre>
580$ hg submit 99999
581</pre>
582
583<p>
584This checks the change into the repository.
585The change description will include a link to the code review,
586and the code review will be updated with a link to the change
587in the repository.
588</p>
589
590<p>
591If your local copy of the repository is out of date,
Oling Cataecbcd02013-02-15 14:01:12 +1100592<code>hg submit</code> will refuse the change:
Russ Cox38a41ee2009-11-06 10:04:22 -0800593</p>
594
595<pre>
Russ Coxd55abfd2009-12-09 14:05:12 -0800596$ hg submit 99999
Russ Cox38a41ee2009-11-06 10:04:22 -0800597local repository out of date; must sync before submit
598</pre>
599
Dave Cheneyeda95902013-02-10 19:40:33 -0500600<h2 id="copyright">Copyright</h2>
Russ Cox38a41ee2009-11-06 10:04:22 -0800601
Russ Coxd55abfd2009-12-09 14:05:12 -0800602<p>Files in the Go repository don't list author names,
603both to avoid clutter and to avoid having to keep the lists up to date.
604Instead, your name will appear in the <a href="http://code.google.com/p/go/source/list">Mercurial change log</a>
605and in the <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
606and perhaps the <a href="/AUTHORS"><code>AUTHORS</code></a> file.
607</p>
608
609<p>The <a href="/CONTRIBUTORS"><code>CONTRIBUTORS</code></a> file
610defines who the Go contributors&mdash;the people&mdash;are;
Caleb Spare41f32e02013-01-06 22:44:16 -0500611the <a href="/AUTHORS"><code>AUTHORS</code></a> file defines
Russ Coxd55abfd2009-12-09 14:05:12 -0800612who &ldquo;The Go Authors&rdquo;&mdash;the copyright holders&mdash;are.
613The Go developers at Google will update these files when submitting
614your first change.
615In order for them to do that, you need to have completed one of the
616contributor license agreements:
617<ul>
618<li>
619If you are the copyright holder, you will need to agree to
620the <a href="http://code.google.com/legal/individual-cla-v1.0.html">individual
621contributor license agreement</a>, which can be completed online.
622</li>
623<li>
624If your organization is the copyright holder, the organization
625will need to agree to the <a href="http://code.google.com/legal/corporate-cla-v1.0.html">corporate contributor license agreement</a>.
626(If the copyright holder for your code has already completed the
627agreement in connection with another Google open source project,
628it does not need to be completed again.)
629</li>
630</ul>
631
632<p>
633This rigmarole needs to be done only for your first submission.
634</p>
635
636<p>Code that you contribute should use the standard copyright header:</p>
Russ Cox38a41ee2009-11-06 10:04:22 -0800637
638<pre>
David Symonds8f3fc5472014-01-01 00:00:22 +1100639// Copyright 2014 The Go Authors. All rights reserved.
Russ Cox38a41ee2009-11-06 10:04:22 -0800640// Use of this source code is governed by a BSD-style
641// license that can be found in the LICENSE file.
642</pre>
Dave Cheneyeda95902013-02-10 19:40:33 -0500643
644<p>
645Files in the repository are copyright the year they are added. It is not
646necessary to update the copyright year on files that you change.
647</p>