1*9880d681SAndroid Build Coastguard Worker============================= 2*9880d681SAndroid Build Coastguard WorkerCode Reviews with Phabricator 3*9880d681SAndroid Build Coastguard Worker============================= 4*9880d681SAndroid Build Coastguard Worker 5*9880d681SAndroid Build Coastguard Worker.. contents:: 6*9880d681SAndroid Build Coastguard Worker :local: 7*9880d681SAndroid Build Coastguard Worker 8*9880d681SAndroid Build Coastguard WorkerIf you prefer to use a web user interface for code reviews, you can now submit 9*9880d681SAndroid Build Coastguard Workeryour patches for Clang and LLVM at `LLVM's Phabricator`_ instance. 10*9880d681SAndroid Build Coastguard Worker 11*9880d681SAndroid Build Coastguard WorkerWhile Phabricator is a useful tool for some, the relevant -commits mailing list 12*9880d681SAndroid Build Coastguard Workeris the system of record for all LLVM code review. The mailing list should be 13*9880d681SAndroid Build Coastguard Workeradded as a subscriber on all reviews, and Phabricator users should be prepared 14*9880d681SAndroid Build Coastguard Workerto respond to free-form comments in mail sent to the commits list. 15*9880d681SAndroid Build Coastguard Worker 16*9880d681SAndroid Build Coastguard WorkerSign up 17*9880d681SAndroid Build Coastguard Worker------- 18*9880d681SAndroid Build Coastguard Worker 19*9880d681SAndroid Build Coastguard WorkerTo get started with Phabricator, navigate to `http://reviews.llvm.org`_ and 20*9880d681SAndroid Build Coastguard Workerclick the power icon in the top right. You can register with a GitHub account, 21*9880d681SAndroid Build Coastguard Workera Google account, or you can create your own profile. 22*9880d681SAndroid Build Coastguard Worker 23*9880d681SAndroid Build Coastguard WorkerMake *sure* that the email address registered with Phabricator is subscribed 24*9880d681SAndroid Build Coastguard Workerto the relevant -commits mailing list. If you are not subscribed to the commit 25*9880d681SAndroid Build Coastguard Workerlist, all mail sent by Phabricator on your behalf will be held for moderation. 26*9880d681SAndroid Build Coastguard Worker 27*9880d681SAndroid Build Coastguard WorkerNote that if you use your Subversion user name as Phabricator user name, 28*9880d681SAndroid Build Coastguard WorkerPhabricator will automatically connect your submits to your Phabricator user in 29*9880d681SAndroid Build Coastguard Workerthe `Code Repository Browser`_. 30*9880d681SAndroid Build Coastguard Worker 31*9880d681SAndroid Build Coastguard WorkerRequesting a review via the command line 32*9880d681SAndroid Build Coastguard Worker---------------------------------------- 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard WorkerPhabricator has a tool called *Arcanist* to upload patches from 35*9880d681SAndroid Build Coastguard Workerthe command line. To get you set up, follow the 36*9880d681SAndroid Build Coastguard Worker`Arcanist Quick Start`_ instructions. 37*9880d681SAndroid Build Coastguard Worker 38*9880d681SAndroid Build Coastguard WorkerYou can learn more about how to use arc to interact with 39*9880d681SAndroid Build Coastguard WorkerPhabricator in the `Arcanist User Guide`_. 40*9880d681SAndroid Build Coastguard Worker 41*9880d681SAndroid Build Coastguard WorkerRequesting a review via the web interface 42*9880d681SAndroid Build Coastguard Worker----------------------------------------- 43*9880d681SAndroid Build Coastguard Worker 44*9880d681SAndroid Build Coastguard WorkerThe tool to create and review patches in Phabricator is called 45*9880d681SAndroid Build Coastguard Worker*Differential*. 46*9880d681SAndroid Build Coastguard Worker 47*9880d681SAndroid Build Coastguard WorkerNote that you can upload patches created through various diff tools, 48*9880d681SAndroid Build Coastguard Workerincluding git and svn. To make reviews easier, please always include 49*9880d681SAndroid Build Coastguard Worker**as much context as possible** with your diff! Don't worry, Phabricator 50*9880d681SAndroid Build Coastguard Workerwill automatically send a diff with a smaller context in the review 51*9880d681SAndroid Build Coastguard Workeremail, but having the full file in the web interface will help the 52*9880d681SAndroid Build Coastguard Workerreviewer understand your code. 53*9880d681SAndroid Build Coastguard Worker 54*9880d681SAndroid Build Coastguard WorkerTo get a full diff, use one of the following commands (or just use Arcanist 55*9880d681SAndroid Build Coastguard Workerto upload your patch): 56*9880d681SAndroid Build Coastguard Worker 57*9880d681SAndroid Build Coastguard Worker* ``git diff -U999999 other-branch`` 58*9880d681SAndroid Build Coastguard Worker* ``svn diff --diff-cmd=diff -x -U999999`` 59*9880d681SAndroid Build Coastguard Worker 60*9880d681SAndroid Build Coastguard WorkerTo upload a new patch: 61*9880d681SAndroid Build Coastguard Worker 62*9880d681SAndroid Build Coastguard Worker* Click *Differential*. 63*9880d681SAndroid Build Coastguard Worker* Click *+ Create Diff*. 64*9880d681SAndroid Build Coastguard Worker* Paste the text diff or browse to the patch file. Click *Create Diff*. 65*9880d681SAndroid Build Coastguard Worker* Leave the Repository field blank. 66*9880d681SAndroid Build Coastguard Worker* Leave the drop down on *Create a new Revision...* and click *Continue*. 67*9880d681SAndroid Build Coastguard Worker* Enter a descriptive title and summary. The title and summary are usually 68*9880d681SAndroid Build Coastguard Worker in the form of a :ref:`commit message <commit messages>`. 69*9880d681SAndroid Build Coastguard Worker* Add reviewers (see below for advice) and subscribe mailing 70*9880d681SAndroid Build Coastguard Worker lists that you want to be included in the review. If your patch is 71*9880d681SAndroid Build Coastguard Worker for LLVM, add llvm-commits as a Subscriber; if your patch is for Clang, 72*9880d681SAndroid Build Coastguard Worker add cfe-commits. 73*9880d681SAndroid Build Coastguard Worker* Leave the Repository and Project fields blank. 74*9880d681SAndroid Build Coastguard Worker* Click *Save*. 75*9880d681SAndroid Build Coastguard Worker 76*9880d681SAndroid Build Coastguard WorkerTo submit an updated patch: 77*9880d681SAndroid Build Coastguard Worker 78*9880d681SAndroid Build Coastguard Worker* Click *Differential*. 79*9880d681SAndroid Build Coastguard Worker* Click *+ Create Diff*. 80*9880d681SAndroid Build Coastguard Worker* Paste the updated diff or browse to the updated patch file. Click *Create Diff*. 81*9880d681SAndroid Build Coastguard Worker* Select the review you want to from the *Attach To* dropdown and click 82*9880d681SAndroid Build Coastguard Worker *Continue*. 83*9880d681SAndroid Build Coastguard Worker* Leave the Repository and Project fields blank. 84*9880d681SAndroid Build Coastguard Worker* Add comments about the changes in the new diff. Click *Save*. 85*9880d681SAndroid Build Coastguard Worker 86*9880d681SAndroid Build Coastguard WorkerChoosing reviewers: You typically pick one or two people as initial reviewers. 87*9880d681SAndroid Build Coastguard WorkerThis choice is not crucial, because you are merely suggesting and not requiring 88*9880d681SAndroid Build Coastguard Workerthem to participate. Many people will see the email notification on cfe-commits 89*9880d681SAndroid Build Coastguard Workeror llvm-commits, and if the subject line suggests the patch is something they 90*9880d681SAndroid Build Coastguard Workershould look at, they will. 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard WorkerHere are a couple of ways to pick the initial reviewer(s): 93*9880d681SAndroid Build Coastguard Worker 94*9880d681SAndroid Build Coastguard Worker* Use ``svn blame`` and the commit log to find names of people who have 95*9880d681SAndroid Build Coastguard Worker recently modified the same area of code that you are modifying. 96*9880d681SAndroid Build Coastguard Worker* Look in CODE_OWNERS.TXT to see who might be responsible for that area. 97*9880d681SAndroid Build Coastguard Worker* If you've discussed the change on a dev list, the people who participated 98*9880d681SAndroid Build Coastguard Worker might be appropriate reviewers. 99*9880d681SAndroid Build Coastguard Worker 100*9880d681SAndroid Build Coastguard WorkerEven if you think the code owner is the busiest person in the world, it's still 101*9880d681SAndroid Build Coastguard Workerokay to put them as a reviewer. Being the code owner means they have accepted 102*9880d681SAndroid Build Coastguard Workerresponsibility for making sure the review happens. 103*9880d681SAndroid Build Coastguard Worker 104*9880d681SAndroid Build Coastguard WorkerReviewing code with Phabricator 105*9880d681SAndroid Build Coastguard Worker------------------------------- 106*9880d681SAndroid Build Coastguard Worker 107*9880d681SAndroid Build Coastguard WorkerPhabricator allows you to add inline comments as well as overall comments 108*9880d681SAndroid Build Coastguard Workerto a revision. To add an inline comment, select the lines of code you want 109*9880d681SAndroid Build Coastguard Workerto comment on by clicking and dragging the line numbers in the diff pane. 110*9880d681SAndroid Build Coastguard WorkerWhen you have added all your comments, scroll to the bottom of the page and 111*9880d681SAndroid Build Coastguard Workerclick the Submit button. 112*9880d681SAndroid Build Coastguard Worker 113*9880d681SAndroid Build Coastguard WorkerYou can add overall comments in the text box at the bottom of the page. 114*9880d681SAndroid Build Coastguard WorkerWhen you're done, click the Submit button. 115*9880d681SAndroid Build Coastguard Worker 116*9880d681SAndroid Build Coastguard WorkerPhabricator has many useful features, for example allowing you to select 117*9880d681SAndroid Build Coastguard Workerdiffs between different versions of the patch as it was reviewed in the 118*9880d681SAndroid Build Coastguard Worker*Revision Update History*. Most features are self descriptive - explore, and 119*9880d681SAndroid Build Coastguard Workerif you have a question, drop by on #llvm in IRC to get help. 120*9880d681SAndroid Build Coastguard Worker 121*9880d681SAndroid Build Coastguard WorkerNote that as e-mail is the system of reference for code reviews, and some 122*9880d681SAndroid Build Coastguard Workerpeople prefer it over a web interface, we do not generate automated mail 123*9880d681SAndroid Build Coastguard Workerwhen a review changes state, for example by clicking "Accept Revision" in 124*9880d681SAndroid Build Coastguard Workerthe web interface. Thus, please type LGTM into the comment box to accept 125*9880d681SAndroid Build Coastguard Workera change from Phabricator. 126*9880d681SAndroid Build Coastguard Worker 127*9880d681SAndroid Build Coastguard WorkerCommitting a change 128*9880d681SAndroid Build Coastguard Worker------------------- 129*9880d681SAndroid Build Coastguard Worker 130*9880d681SAndroid Build Coastguard WorkerOnce a patch has been reviewed and approved on Phabricator it can then be 131*9880d681SAndroid Build Coastguard Workercommitted to trunk. There are multiple workflows to achieve this. Whichever 132*9880d681SAndroid Build Coastguard Workermethod you follow it is recommend that your commit message ends with the line: 133*9880d681SAndroid Build Coastguard Worker 134*9880d681SAndroid Build Coastguard Worker:: 135*9880d681SAndroid Build Coastguard Worker 136*9880d681SAndroid Build Coastguard Worker Differential Revision: <URL> 137*9880d681SAndroid Build Coastguard Worker 138*9880d681SAndroid Build Coastguard Workerwhere ``<URL>`` is the URL for the code review, starting with 139*9880d681SAndroid Build Coastguard Worker``http://reviews.llvm.org/``. 140*9880d681SAndroid Build Coastguard Worker 141*9880d681SAndroid Build Coastguard WorkerThis allows people reading the version history to see the review for 142*9880d681SAndroid Build Coastguard Workercontext. This also allows Phabricator to detect the commit, close the 143*9880d681SAndroid Build Coastguard Workerreview, and add a link from the review to the commit. 144*9880d681SAndroid Build Coastguard Worker 145*9880d681SAndroid Build Coastguard WorkerNote that if you use the Arcanist tool the ``Differential Revision`` line will 146*9880d681SAndroid Build Coastguard Workerbe added automatically. If you don't want to use Arcanist, you can add the 147*9880d681SAndroid Build Coastguard Worker``Differential Revision`` line (as the last line) to the commit message 148*9880d681SAndroid Build Coastguard Workeryourself. 149*9880d681SAndroid Build Coastguard Worker 150*9880d681SAndroid Build Coastguard WorkerUsing the Arcanist tool can simplify the process of committing reviewed code 151*9880d681SAndroid Build Coastguard Workeras it will retrieve reviewers, the ``Differential Revision``, etc from the review 152*9880d681SAndroid Build Coastguard Workerand place it in the commit message. Several methods of using Arcanist to commit 153*9880d681SAndroid Build Coastguard Workercode are given below. If you do not wish to use Arcanist then simply commit 154*9880d681SAndroid Build Coastguard Workerthe reviewed patch as you would normally. 155*9880d681SAndroid Build Coastguard Worker 156*9880d681SAndroid Build Coastguard WorkerNote that if you commit the change without using Arcanist and forget to add the 157*9880d681SAndroid Build Coastguard Worker``Differential Revision`` line to your commit message then it is recommended 158*9880d681SAndroid Build Coastguard Workerthat you close the review manually. In the web UI, under "Leap Into Action" put 159*9880d681SAndroid Build Coastguard Workerthe SVN revision number in the Comment, set the Action to "Close Revision" and 160*9880d681SAndroid Build Coastguard Workerclick Submit. Note the review must have been Accepted first. 161*9880d681SAndroid Build Coastguard Worker 162*9880d681SAndroid Build Coastguard WorkerSubversion and Arcanist 163*9880d681SAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^^^^ 164*9880d681SAndroid Build Coastguard Worker 165*9880d681SAndroid Build Coastguard WorkerOn a clean Subversion working copy run the following (where ``<Revision>`` is 166*9880d681SAndroid Build Coastguard Workerthe Phabricator review number): 167*9880d681SAndroid Build Coastguard Worker 168*9880d681SAndroid Build Coastguard Worker:: 169*9880d681SAndroid Build Coastguard Worker 170*9880d681SAndroid Build Coastguard Worker arc patch D<Revision> 171*9880d681SAndroid Build Coastguard Worker arc commit --revision D<Revision> 172*9880d681SAndroid Build Coastguard Worker 173*9880d681SAndroid Build Coastguard WorkerThe first command will take the latest version of the reviewed patch and apply it to the working 174*9880d681SAndroid Build Coastguard Workercopy. The second command will commit this revision to trunk. 175*9880d681SAndroid Build Coastguard Worker 176*9880d681SAndroid Build Coastguard Workergit-svn and Arcanist 177*9880d681SAndroid Build Coastguard Worker^^^^^^^^^^^^^^^^^^^^ 178*9880d681SAndroid Build Coastguard Worker 179*9880d681SAndroid Build Coastguard WorkerThis presumes that the git repository has been configured as described in :ref:`developers-work-with-git-svn`. 180*9880d681SAndroid Build Coastguard Worker 181*9880d681SAndroid Build Coastguard WorkerOn a clean Git repository on an up to date ``master`` branch run the 182*9880d681SAndroid Build Coastguard Workerfollowing (where ``<Revision>`` is the Phabricator review number): 183*9880d681SAndroid Build Coastguard Worker 184*9880d681SAndroid Build Coastguard Worker:: 185*9880d681SAndroid Build Coastguard Worker 186*9880d681SAndroid Build Coastguard Worker arc patch D<Revision> 187*9880d681SAndroid Build Coastguard Worker 188*9880d681SAndroid Build Coastguard Worker 189*9880d681SAndroid Build Coastguard WorkerThis will create a new branch called ``arcpatch-D<Revision>`` based on the 190*9880d681SAndroid Build Coastguard Workercurrent ``master`` and will create a commit corresponding to ``D<Revision>`` with a 191*9880d681SAndroid Build Coastguard Workercommit message derived from information in the Phabricator review. 192*9880d681SAndroid Build Coastguard Worker 193*9880d681SAndroid Build Coastguard WorkerCheck you are happy with the commit message and amend it if necessary. Now switch to 194*9880d681SAndroid Build Coastguard Workerthe ``master`` branch and add the new commit to it and commit it to trunk. This 195*9880d681SAndroid Build Coastguard Workercan be done by running the following: 196*9880d681SAndroid Build Coastguard Worker 197*9880d681SAndroid Build Coastguard Worker:: 198*9880d681SAndroid Build Coastguard Worker 199*9880d681SAndroid Build Coastguard Worker git checkout master 200*9880d681SAndroid Build Coastguard Worker git merge --ff-only arcpatch-D<Revision> 201*9880d681SAndroid Build Coastguard Worker git svn dcommit 202*9880d681SAndroid Build Coastguard Worker 203*9880d681SAndroid Build Coastguard Worker 204*9880d681SAndroid Build Coastguard Worker 205*9880d681SAndroid Build Coastguard WorkerAbandoning a change 206*9880d681SAndroid Build Coastguard Worker------------------- 207*9880d681SAndroid Build Coastguard Worker 208*9880d681SAndroid Build Coastguard WorkerIf you decide you should not commit the patch, you should explicitly abandon 209*9880d681SAndroid Build Coastguard Workerthe review so that reviewers don't think it is still open. In the web UI, 210*9880d681SAndroid Build Coastguard Workerscroll to the bottom of the page where normally you would enter an overall 211*9880d681SAndroid Build Coastguard Workercomment. In the drop-down Action list, which defaults to "Comment," you should 212*9880d681SAndroid Build Coastguard Workerselect "Abandon Revision" and then enter a comment explaining why. Click the 213*9880d681SAndroid Build Coastguard WorkerSubmit button to finish closing the review. 214*9880d681SAndroid Build Coastguard Worker 215*9880d681SAndroid Build Coastguard WorkerStatus 216*9880d681SAndroid Build Coastguard Worker------ 217*9880d681SAndroid Build Coastguard Worker 218*9880d681SAndroid Build Coastguard WorkerPlease let us know whether you like it and what could be improved! We're still 219*9880d681SAndroid Build Coastguard Workerworking on setting up a bug tracker, but you can email klimek-at-google-dot-com 220*9880d681SAndroid Build Coastguard Workerand chandlerc-at-gmail-dot-com and CC the llvm-dev mailing list with questions 221*9880d681SAndroid Build Coastguard Workeruntil then. We also could use help implementing improvements. This sadly is 222*9880d681SAndroid Build Coastguard Workerreally painful and hard because the Phabricator codebase is in PHP and not as 223*9880d681SAndroid Build Coastguard Workertestable as you might like. However, we've put exactly what we're deploying up 224*9880d681SAndroid Build Coastguard Workeron an `llvm-reviews GitHub project`_ where folks can hack on it and post pull 225*9880d681SAndroid Build Coastguard Workerrequests. We're looking into what the right long-term hosting for this is, but 226*9880d681SAndroid Build Coastguard Workernote that it is a derivative of an existing open source project, and so not 227*9880d681SAndroid Build Coastguard Workertrivially a good fit for an official LLVM project. 228*9880d681SAndroid Build Coastguard Worker 229*9880d681SAndroid Build Coastguard Worker.. _LLVM's Phabricator: http://reviews.llvm.org 230*9880d681SAndroid Build Coastguard Worker.. _`http://reviews.llvm.org`: http://reviews.llvm.org 231*9880d681SAndroid Build Coastguard Worker.. _Code Repository Browser: http://reviews.llvm.org/diffusion/ 232*9880d681SAndroid Build Coastguard Worker.. _Arcanist Quick Start: https://secure.phabricator.com/book/phabricator/article/arcanist_quick_start/ 233*9880d681SAndroid Build Coastguard Worker.. _Arcanist User Guide: https://secure.phabricator.com/book/phabricator/article/arcanist/ 234*9880d681SAndroid Build Coastguard Worker.. _llvm-reviews GitHub project: https://github.com/r4nt/llvm-reviews/ 235