|Version 57 (modified by glyph, 4 years ago) (diff)|
Twisted Code Review Process
All commits to Twisted's trunk must follow this review process. The only exception is for the [source:trunk/doc/fun/Twisted.Quotes Twisted Quotes] file. There are no other exceptions!
Both authors and reviewers should be intimately familiar with all requirements on this page.
Authors: Before you get started
For the most part, we'd love for you to jump right in and start writing code! The code review process should catch any serious problems with your contribution, and the continuous integration system should catch most tricky cross-platform issues. It's easy to get too caught up in trying to do everything perfectly the first time and never get any code written, so you should usually err on the side of just trying something out rather than waiting for someone to tell you if it's OK. That being said, there are a few things that you should really be aware of before you write your first line of code:
- Make sure you have a clear idea of what work needs doing. Write down your idea first; file a ticket before you write a patch. A really good ticket will give a precise description of what needs to change and why it needs changing; it avoids giving precise details of exactly how the code needs to change, because the patch should supply those details. A really bad ticket will say "here is a patch I wrote, apply it". If you're just getting started with contributing to Twisted, it would be good to find an existing ticket rather than come up with something yourself, so you have an idea how to go through the process before you start making difficult changes. You'll need to have a good description of your work for other parts of the process as well (the NEWS file, the commit message) which is another reason thinking about what you're trying to do helps.
- Try not to write too much code at once. A good change really needs to be be under 1000 lines of diff for a reviewer to be able to deal with it before getting fatigued and missing things. Really, you should be aiming for things in the neighborhood of 200 lines. This is for your benefit as well as the reviewer's; we don't want you to spend weeks on a 10,000-line monster of a feature, only to have it rejected because we're not interested in having such a feature at all.
Authors: Things your branch or patch must contain
- Code which follows the coding standard.
- 100% unit test coverage for all modified and new code (even if it didn't have tests before)
- 100% API docstring coverage for all modified and new code (even if it didn't have docs before)
- No backwards-incompatible changes. Please also be sparing when adding 'public' names to the API, as they must be supported in the future. If it can start with an underscore and not be exposed publicly, it probably should.
- Appropriate new or modified "End User" guide documentation (in the form of Lore-formatted xhtml files in the [source:trunk/doc doc/] directory)
- A file in all relevant "topfiles" directories describing changes which affect users (See below)
Authors: How to get your change reviewed
- There must be a bug in the Twisted bug tracker describing the desired outcome (See below).
- Note: For security issues, see Security.
- Add the "review" keyword to the ticket.
- Remove the owner field by selecting the blank option next to "Assign to".
- Alternatively, assign it to someone who has already agreed to review it.
- Write a comment with any relevant information for the reviewer.
Reviewers: How to review a change
- Be familiar with the Twisted codebase, coding standard, and these review requirements.
- Don't be the author of the change (See below).
- Assign the ticket to yourself.
- Review the change, and write a detailed comment about all potential improvements to the branch (See below).
- Remove the "review" keyword from the ticket.
- Assign the ticket back to the author.
- If the change is ready for trunk, indicate so by writing "please merge" or "+1".
- Alternatively, if the author does not have commit access to trunk, merge the change for them.
Authors: How to merge the change to trunk
- Merge the change into a checkout of Twisted trunk and commit it. The message must follow this format (See below).
Merge <branch name>: Brief description Author: <names> Reviewer: <names> Fixes: #<ticket number> Long description (as long as you wish)
- After the change is merged wait for the buildbots to finish running, if there is a regression on a supported builder you should revert your merge.
It is now up to the authors of individual changes to write high-level descriptions for their changes. These descriptions will be aggregated into the release notes distributed with Twisted releases. If we just let each author add to the [source:trunk/twisted/topfiles/NEWS NEWS] files on every commit, though, we would run into lots of spurious conflicts. To avoid this, we have come up with a scheme involving separate files for each change.
Changes must be accompanied by an entry in at least one topfiles directory. There are topfiles directories for each subproject (eg. [[source:trunk/twisted/names/topfiles]], [[source:trunk/twisted/words/topfiles]]), and one root directory ([[source:trunk/twisted/topfiles]]) for core Twisted changes. If a change affects multiple areas of Twisted, then each affected area can have a topfiles entry to detail the relevant changes. An entry must be a file named <ticket number>.<change type> (eg. 1234.bugfix). You should replace <ticket number> with the ticket number which is being resolved by the change (if multiple tickets are resolved, multiple files with the same contents should be added). The <change type> extension is replaced by one of the following literal strings:
|feature||Tickets which are adding a new feature|
|bugfix||Tickets which are fixing a bug|
|doc||Tickets primarily about fixing or improving documentation (any variety)|
|removal||Tickets which are deprecating something or removing something which was already deprecated|
|misc||Tickets which are very minor and not worth summarizing outside of the svn changelog. These should be empty (their contents will be ignored)|
To get a sense of how the text in these files is presented to users, take a look at [source:trunk/NEWS the real overall news file] and [source:trunk/twisted/web/topfiles/NEWS one of the subproject news files]. The goal when writing the content for one of these files is to produce text that will fit well into the overall news files.
The entry should contain a high-level description of the change suitable for end users. Generally, the grammatical subject of the sentence should be a Python object, and the verb should be something that the object does, prefixed with "now".
Here are some examples:
twisted.protocols.amp now raises InvalidSignature when bad arguments are passed to Command.makeArguments
The new module twisted.internet.endpoints provides an interface for specifying address families separately from socket types.
twisted.trial.util.findObject is now deprecated.
twisted.conch.insults.colors is now deprecated in favor of twisted.conch.insults.helper.
twisted.runner.procmon.ProcessMonitor's active, consistency, and consistencyDelay attributes are now deprecated.
twisted.internet.interfaces.IReactorTime.cancelCallLater, deprecated since Twisted 2.5, has been removed.
You don't need to worry about newlines in the file; the contents will be rewrapped when added to the NEWS files.
See enforcenews.py for the svn pre-commit hook which enforces this policy.
Filing bugs and writing review requests
Tickets should be described well enough that the change is already justified and the new code should be easy enough to read that further explanations aren't necessary to understand it, but sometimes diffs themselves can be more difficult to read than either the old or new state of the code, so comments like the implementation of foo moved from bar.py to baz.py can sometimes make a reviewer's job easier.
Who can review?
Changes must be reviewed by a developer other than the author of the changes. If changes are paired on, a third party must review them. If changes constitute the work of several people who worked independently, a non-author must review them.
A reviewer need not necessarily be familiar with the specific area of Twisted being changed, but he or she should feel confident in his or her abilities to spot problems in the change.
How to be a good reviewer
First, make sure all of the obvious things are accounted for. Check the "Things your branch or patch must contain" list above, and make sure each point applies to the branch. Use pyflakes to check the basic quality of the code. The following command will check all the files modified and added by a branch merge:
svn status | grep '^\M\|^A' | cut -c 8- | xargs pyflakes
A reviewer may reject a change for various reasons, many of which are hard to quantify. Basically, use your best judgement, and don't be afraid to point out problems which don't fit into the list of branch requirements laid out in this document.
Here are some extra things to consider while reviewing a change:
- Is the code written in a straightforward manner which will allow it to be easily maintained in the future, possibly by a developer other than the author?
- If it introduces a new feature, is that feature generally useful and have its long term implications been considered and accounted for?
- Will it result in confusion to application developers?
- Does it encourage application code using it to be well factored and easily testable?
- Is it similar to any existing feature offered by Twisted, such that it might make sense as an extension or modification to some other piece of code, rather than an entirely new functional unit?
- Does it require new documentation and examples?
When you're done with the review, always say what the next step should be: for example, if the author is a committer, can they commit after making a few minor fixes? If your review feedback is more substantial, should they re-submit for another review?
If you are officially "doing a review" - in other words, removing the review keyword - please make sure you do a complete review and look for all of these things, so that the author has as much feedback as possible to work with while their ticket is out of the review state. If you don't have time to do a complete review, and you just notice one or two things about the ticket, just make a comment to help the future reviewer, and don't remove the review keyword, so another reviewer might have a look. For example, say, "I just checked for a news file and I noticed there wasn't one", or, "I saw some trailing whitespace in these methods". If you remove the review keyword, you may substantially increase the amount of time that the author has to wait for a real, comprehensive review, which is very frustrating.
The commit message
Several tools exist which parse commit messages to trunk, so the Author, Reviewer, and Fixes lines should conform to this format exactly. Multiple Fixes lines will close multiple tickets. Refs may also be used to attach the commit message to another ticket which is not being closed. The commit message should also describe the change being made in a modest amount of detail.
Reverting a change
If a change set somehow introduces a test suite regression or is otherwise found to be undesirable, it is to be reverted. Any developer may revert a commit which introduces a test suite regression on a supported platform. The revert message should be as explicit as possible. If it's a failure, put the message of the error in the commit message, possibly with the identifier of the buildbot slave. If there are too many failures, it can be put in the tracker, with a reference in the message. Use the "Reopens" tag to automatically reopen the ticket:
Revert r<revision number>: Brief description A description of the problem, or a traceback if pertinent Reopens: #<ticket number>
Reverted branches are to be reviewed again before being merged.