Infrastructure/Phabricator

From KDE Community Wiki
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

Phabricator is KDE's task management and patch review system. This page is intended to serve as a general-purpose introduction to the most important aspects: submitting and reviewing patches. It should not take long before you are happily using Phabricator.

Information

The KDE community does not use the Phabricator bug reporting function. We continue to use bugzilla at https://bugs.kde.org


Basic Tasks

Logging in

Log in to Phabricator with your KDE Identity account. If you don't have one, you can sign up for one here. At the Phabricator home page, click the "Log in" button on the top of the page and enter your KDE Identity username and password:

If your KDE Identity account works on http://identity.kde.org, but not on http://phabricator.kde.org, please contact the KDE sysadmins at [email protected]

Getting help

The official documentation is in the Phabricator book and on their website -- note that since everything is under rapid development, most of the documentation is incomplete. A good way to find the information you're looking for is to search Phabricator upstream.

Posting a Patch using the website

First, create a diff file using git diff (or git format-patch) Log in to Phabricator and enter Code Review. Click the +Create Diff button in the upper-right corner of the screen. Paste the text of the diff or upload the file using the file dialog. Select the project at the bottom; if you start typing it will perform a search among active projects. For a reviewer, use the name of the project itself (the text-field will auto-complete valid projects to help you out). In some cases, you will want to request a review from particular people instead of or in addition to the group.

Note

You must make sure that there is at least one subscriber or reviewer for the diff. Phabricator automatically adds the correct subscriber(s) for many projects when the diff is submitted, but not all of them. If there are no subscribers or reviewers, nobody will get notified.


Formatting your patch

Once the patch lands, the Title will become the git commit message, so please follow commit message best practices.

If your patch is intended to fix a Bugzilla ticket, include one of the following on its own line in the Summary section:

BUG: 385942

or

FEATURE: 384936

(Just the Bugzilla ticket number, not the full URL)

Use BUG: If the Bugzilla describes a bug, and FEATURE if the Bugzilla ticket describes a feature request. Either of these tags will cause that Bugzilla ticket to be automatically closed when the patch is committed.

If you added the BUG: or FEATURE: tag, also add another tag indicating what version receives the fix or new feature:

FIXED-IN: [version]

Replace [version] with an appropriate version string; see Guidelines and HOWTOs/Write a version string to find out how to write one. If you can't figure it out, don't worry about it and just omit the tag; a KDE developer will help you add it during code review.

Here is more information about other special messages that interact with Bugzilla tickets. You can also add special messages that interact with other Phabricator tools (e.g. Maniphest tasks).

Using Arcanist to post patches

What is Arc?

Using the web UI to post patches gets tiresome after a while. Arcanist is a tool to simplify and speed up the process of posting, updating, and merging Phabricator patches.

Phabricator's fully featured command line tool to interface with your local Git repository. It can be used to submit your patches for review. After you have installed Arc, you can learn more using man arc or arc --help. Another command useful for getting a feel for Phabricator's style is arc anoid.

Installing on Linux

Getting arc is easy on Linux; just use your distro's package manager:

  • Debian/Ubuntu/KDE Neon: sudo apt install arcanist
  • Fedora: sudo dnf install arcanist
  • openSUSE: sudo zypper install arcanist
  • Arch/Antergos/Manjaro: sudo pacman -S arcanist
  • Windows: Arc installation guide The most non-obvious step is that you will need to configure your Php installation to use Curl. This requires editing the php.ini configuration file to add the line extension_dir = "ext" and add php_curl to the list of extensions. After adding php.exe to your path and installing arcanist/libphutil, you can run arc by defining a function in your Powershell profile:
     function arc { php -f "C:\path\to\arcanist.php" -- $args }

Workflow

The sanest and easiest way to use arc is to follow a typical feature branch workflow: keep your master branch synchronized with the upstream repository, and make all changes on separate branches.

Step 1: Create a new diff

Before editing anything, create a new branch for your patch:

$ git checkout -t -b <branchname> origin/master

Make changes on the feature branch. When you're ready to have your changes reviewed, do the following:

$ git add <space-separated list of all the files you changed>
$ git commit
$ arc diff

When you run arc diff, you will go through a series of dialogues. At the end, you will be asked to rewrite your Git commit message to fit the standard Differential format, like so:

<first line of original git commit message>

Summary: <rest of original commit message>

Reviewers: 

Differential Revision: <URL to the new diff>

<first line of original git commit message> will become the commit message, so please follow commit message best practices.

As when using the web UI, enter any special Bugzilla keywords (such as BUG: 385942) on their own lines in the "Summary" section.

As when using the web UI, for the "Reviewers" section, enter a hashtag for the review group--which is usually equal to the project name. For example, the review group forKrita is #krita and the review group for KDE PIM is #kde_pim. If you can't figure out the correct hashtag, leave the Reviewers section blank for now over arc's protestations and then edit your revision on the web UI after it's been created; you will be able to enter reviewers into a nice text box that auto-completes with valid reviewers, which is much more user-friendly.

Don't touch the "Differential Revision:" section.

Step 2: Update your diff

After arc uploads the patch to phabricator, the project's reviewers will take a look and give you some comments. If you get a thumbs up immediately, you can skip this step. But often you will get a review like "looks good, we can take it if you fix problems x, y, and z." Make the necessary changes, add an extra commit to the git branch, and update the Phabricator revision:

[implement changes based on review comments]
$ git add -u
$ git commit
$ arc diff

Step 3: Land your diff

If you do not have a KDE Developer Account, then someone who does will have to land your patch for you. Otherwise, you can do it yourself once the patch has been accepted and reviewers have given you permission to "ship it!"

$ [make sure you are on your feature branch]
$ arc land

This will squash all of the commits in your feature branch together. Phabricator aims for a tight correspondence of one commit = one change = one diff. If you don't want to squash your commits, using Arc for the last step is unnecessary, as Phabricator will monitor the repo and mark the diff as closed when it sees the commit. You can push using git push instead.

If you are new to arc, you may want to double-check the commit message before actually pushing to make sure the commit looks as intended. You can do so with arc land --hold, which will squash your feature-branch in a single commit on master, without pushing it. arc land also assumes the upstream branch is called "origin/master." Usually, that is the case, but if you have been asked to commit to a "stable branch", you can do so using the --onto argument with the branch name, e.g:

arc land --onto Applications/18.04

Arcanist Tips & Tricks

Updating the summary of the Differential from the local Git commit message

If you changed the commit message locally and want to update the text in the summary in Differential, call Arc like this:

$ arc diff --edit --verbatim

Marking patches as dependent on other patches

Sometimes you will want to submit a patch that depends on another patch, creating a dependency chain.

If each patch is intended for a different project

Example: you submit a patch to add new feature in KIO, and then submit another patch for Dolphin that uses that feature. Here's what you do:

  1. Create your first patch as above
  2. When creating the second patch, add the following to its own line in the "Summary" section:
    Depends on DXXXX
    (Replace "DXXXX" with the ID of the dependent patch, not the full URL)

If the patches are all for the same project

Example: you are implementing multiple new features for a single project that each depend on the patch for the prior feature. Here's what you do:

  1. Create a branch to track the first feature:
    $ git checkout -t -b <branch name for feature 1> origin/master
    

    Then implement the feature and make a commit.

  2. Then create a branch for your second feature, tracking the first branch:
    git checkout -t -b <branch name for feature 2> --track <branch name for feature 1>
    

    As above, implement the feature and make a commit. Continue this pattern for any other required dependent features.

  3. When you're ready to turn your dependency chain feature branches into patches, do the following:
    $ git checkout <branch name for feature 1>
    $ arc diff [then go through the process of creating the patch normally]
    $ git checkout <branch name for feature 2>
    git commit --amend  [then add the special text "Depends on DXXXX", replacing DXXXX with the ID of the first patch
    $ arc diff [then go through the process of creating the patch normally]
    

    ...And so on.

  4. After you get comments, you will have to make changes to your patches and re-base dependent patches:
    $ git checkout <branch name for feature 1>
    [Make changes]
    $ git add -u
    $ git commit
    $ arc diff
    $ git checkout <branch name for feature 2>
    $ git rebase <branch name for feature 1>
    $ git add -u
    $ git commit
    $ arc diff
    

    ...And so on.

  5. When you're ready to land any or all of your patches, do it in sequence, starting from the patch with no unmet dependencies:
    $ git checkout <branch name for feature 1>
    $ arc land
    $ git checkout <branch name for feature 2>
    $ git rebase origin/<target branch>
    $ arc land
    


Advanced Tasks

Once in a while a reviewer will tell you to do specific things. This section will help you to figure out what is meant to be done.

Look before you diff

You can check with arc which what Arcanist will do before performing the actual upload with arc diff if you are unsure what will happen.

arc diff: specify a revision manually

Sometimes - if you messed up with your git branches - arc cannot properly determine which revision (D12345) should be updated. In this case you can use arc diff --update D12345. See arc help diff.

"Please to that in a separate commit"

FAQ: Is there a special arc command to do that or does it mean to manually post a separate patch to Phabricator?

arc command: TODO (if exists)

To separate changes in git there are different methods. This is a loose list of those:

  • plain old copy-and-paste
  • cherry-picking for separate commits
    • maybe in combination with git-cola's "Grab File" from a specific revision and git revert
  • chunk-based interactive rebase, put it in the stash, update old revision, create new revision from stash.
    • tutorial?


Then run `arc diff` to create a new revision for those extracted changes.

In general, it is best to avoid adding unrelated changes from the beginning. :-)

Customization

Creating custom dashboard feeds

You can customize your Phabricator homepage by creating a new dashboard. However, the selection of what you can post on your dashboard is limited. The defaults will show all tasks from all projects.

To narrow this down, you need to define a custom query to serve as a filter. For example, if you work on Plasma Mobile and want to monitor the to-do list, perhaps you want to show only tasks which are in the Plasma Mobile and are tagged as open. To do that, enter Maniphest, select "advanced search," select the appropriate terms, then click "save custom query." You can give your query a name. Once it is saved, the query will become available as a new filter for creating feeds on your dashboard. (In Differential you seem to need to perform the test search before the "save query" button becomes visible.)