[wiki:ContributingToTwistedLabs Contribute] > [wiki:TwistedDevelopment Development] > Review Process = Twisted Code Review Process = [[PageOutline(2-3, , inline)]] All commits to Twisted's trunk must follow this review process. The only exception is for the [https://github.com/twisted/twisted/blob/trunk/docs/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; [https://twistedmatrix.com/trac/newticket 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. * Note: '''if you're filing a bug because you noticed a regression in [wiki:ReleaseProcess a current pre-release], make sure to mark it as a regression, add it to the release milestone, and to post something to the mailing list as well'''. It's very important for us to spot regressions before they make it into a final release, so redundant communication is better in this case! * 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 [http://twistedmatrix.com/documents/current/core/development/policy/coding-standard.html 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 [CompatibilityPolicy 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 rst files in the [https://github.com/twisted/twisted/tree/trunk/docs docs/] directory) * A file in all relevant "topfiles" directories describing changes which affect users (See [#Newsfiles below]) == Authors: How to get your change reviewed == * There must be a bug in the Twisted bug tracker describing the desired outcome (See [#Filingbugsandwritingreviewrequests below]). * '''Note''': For security issues, see [wiki:Security 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. * If you are a Twisted committer: * Make sure your code is in a branch. * Make sure the 'branch' field on the ticket corresponds to the branch where the code is checked in. * [wiki:ContinuousIntegration/DeveloperWorkflow Force a build of your branch]. Make sure that it's **green**! == 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 [#Whocanreview below]). * Make sure that it's **green**! [wiki:ContinuousIntegration/DeveloperWorkflow Trigger a build if it was not done yet]. * There is one caveat to this rule. If one of the tools that we use to verify the code, such as `pydoctor`, `twistedchecker` or `pyflakes`, causes a build to fail, but for a reason that has to do with a bug in the tool rather than a problem with the code, file the bug in the tool, and then link from the bug report to the twisted ticket where you saw the spurious failure. You can [https://github.com/twisted/twistedchecker/issues file bugs in twistedchecker here], [https://github.com/twisted/pydoctor/issues pydoctor here], or [https://launchpad.net/pyflakes pyflakes here]. Don't block a branch on a tool bug, but also, don't let any spurious failures go without filing an appropriate bug on the relevant tool first. * If the contributor lacks permission to create branches in the official Twisted repository on github (`twisted/twisted`), you will need to push it to the official Twisted repository after a security review to cause all of the CI builders to process the branch. After verifying the change is not an attack on the CI system, use `admin/pr_as_branch` to push the changes into the official Twisted repository. Then create a new PR on github for the new branch and close the original PR. Be sure to reference the original PR in the new one so that the review history is easily discoverable. * Assign the ticket to yourself. * Review the change, and write a detailed comment about all potential improvements to the branch (See [#Howtobeagoodreviewer 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 (as a merge commit, using {{{ git merge --no-ff }}}!) and commit it. The message must follow this format (See [#Thecommitmessage below]). {{{ #!html
Merge <branch name>: Brief description Author: <comma_separated_names> Reviewer: <comma_separated_names> Fixes: ticket:<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 [#Revertingachange revert your merge]. * '''If this fix has implications for an ongoing [wiki:ReleaseProcess pre-release in progress]''', please announce it on the mailing list so that the release manager will know. A change definitely has implications for the release process if: - a pre-release has been issued for which there is no final release - this ticket was a known regression and is now closed, so another pre-release should be issued - this ticket was in the release milestone and is now closed, so another pre-release should be issued - as part of the final review, the reviewer noticed that this is fixing something that could be considered a regression. In general, if there's any doubt, communicate to the mailing list. The mailing list is fairly low traffic, and so a little extra noise about interesting developments is much better than letting an important fix slip through the cracks. If you're not sure whether something qualifies as a regression or not, let the release manager know so they can decide. == Details == === News files === 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 [https://github.com/twisted/twisted/blob/trunk/NEWS NEWS] file 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. [[https://github.com/twisted/twisted/tree/trunk/twisted/names/topfiles]], [[https://github.com/twisted/twisted/tree/trunk/twisted/words/topfiles]]), and one root directory ([[https://github.com/twisted/twisted/tree/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 `
Revert r<revision number>: Brief description A description of the problem, or a traceback if pertinent Reopens: ticket:<ticket number>}}} Reverted branches are to be reviewed again before being merged.