SkillAgentSearch skills...

Review

MozPhab: Phabricator review submission/management tool (`moz-phab`)

Install / Use

/learn @mozilla-conduit/Review
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

moz-phab

Phabricator CLI from Mozilla to support submission of a series of commits.

Installation

moz-phab can be installed with pip3 install MozPhab.

For detailed installation instructions please see:

moz-phab will periodically check for updates and seamlessly install the latest release when available. To force update moz-phab, run moz-phab self-update.

Changelog

Changelog is available on the MozPhab page on Mozilla Wiki.

Configuration

moz-phab has an INI style configuration file to control defaults: ~/.moz-phab-config

This file will be created if it doesn't exist.

[ui]
no_ansi = False
hyperlinks = True

[vcs]
safe_mode = False

[git]
remote =
command_path =

[hg]
command_path =

[submit]
auto_submit = False
always_blocking = False
warn_untracked = True
ai_review = False

[patch]
apply_to = base
create_bookmark = True
create_topic = False
create_branch = True
always_full_stack = False
branch_name_template = phab-D{rev_id}
create_commit = True

[updater]
self_last_check = 0
self_auto_update = True
get_pre_releases = False

[error_reporting]
report_to_sentry = True
  • ui.no_ansi : Never use ANSI colours (default: auto-detected).
  • ui.hyperlinks : Enable terminal hyperlinks for revision IDs and bug numbers (default: True).
  • vcs.safe_mode : Use only safe VCS settings (default: False). Use --safe-mode option to switch it on for a one-time usage.
  • git.remote: Comma separated string. Default remotes used to find the first unpublished commit. Default, empty string, means that a list of remotes will be read from git remote command.
  • git.command_path: Command path to Git binary.
  • hg.command_path: Command path to Mercurial binary.
  • submit.auto_submit : When True the confirmation prompt will be skipped (default: False).
  • submit.always_blocking : When True reviewers in commit descriptions will be marked as blocking. reviewers specified on the command line override this setting (default: False).
  • submit.warn_untracked : When True show a warning if there are uncommitted or untracked changes in the working directory (default: True).
  • submit.ai_review : When True moz-phab will automatically request an AI review for newly created revisions. AI review is not requested for updates to existing revisions; use the --ai flag to explicitly request AI review on updates (default: False).
  • patch.apply_to : [base/here] Where to apply the patches by default. If "base" moz-phab will look for the SHA1 in the first commit. If "here" - current commit/checkout will be used (default: base).
  • patch.create_bookmark : Affects only when patching a Mercurial repository. If True moz-phab will create a bookmark (based on the last revision number) for the new DAG branch point.
  • patch.create_topic : Affects only when patching a Mercurial repository. Requires the topic extension to be enabled. If True moz-phab will create a topic (based on the last revision number) for the new DAG branch point.
  • patch.create_branch : Affects only when patching a Git repository. If True moz-phab will create a branch (based on the last revision number) for the new DAG branch point.
  • patch.always_full_stack : When False and the patched revision has successors, moz-phab will ask if the whole stack should be patched instead. If True moz-phab will do it without without asking.
  • patch.branch_name_template : The template string to use for naming the new branch, topic or bookmark. The string takes a single format string input, rev_id, which is the ID of the revision being patched.
  • patch.create_commit : If True (the default) a commit will be generated for the patch. Applies the changes with the patch command.
  • updater.self_last_check : Epoch timestamp (local timezone) indicating the last time an update check was performed for this script. set to -1 to disable this check.
  • self_auto_update : When True moz-phab will auto-update if a new version is available. If False moz-phab will only warn about the new version.
  • get_pre_releases : When True moz-phab auto-update will fetch pre-releases if they are available, otherwise pre-releases will be ignored (default: False).
  • error_reporting.report_to_sentry : When True moz-phab will submit exceptions to Sentry so moz-phab devs can see unreported errors.

Environment Variables

moz-phab can also be configured via the following environment variables:

  • DEBUG : Enabled debugging output (default: disabled).
  • MOZPHAB_NO_USER_CONFIG : Do not read from or write to ~/.moz-phab-config (default: disabled).
  • DISABLE_SPINNER : Set to any value in the environment to disable the spinner (default: the spinner is enabled).

Execution

To get information about all available commands run

moz-phab -h

All commands involving VCS (like submit and patch) might be used with a --safe-mode switch. It will run the VCS command with only chosen set of extensions.

Submitting commits to Phabricator

The simplest invocation is

moz-phab [start_rev] [end_rev]

If no positional arguments (start_rev/end_rev) are given, the range of commits is automatically determined, starting with the first non-public, non-obsolete changeset (for Mercurial) or first unpublished commit (for Git) and ending with the currently checked-out changeset. If at least one argument is given moz-phab is following the underlying VCS's log behavior. The first argument is interpreted differently in Mercurial (as inclusive) and Git (exclusive). If only one argument is given the end of range is again interpreted as the currently checked-out changeset. If both arguments are given - the second one is interpreted as inclusive.

Bug IDs and reviewers are parsed out of commit messages by default. You can set a reviewer as blocking by appending an exclamation mark to the reviewer's nick, e.g. r=foo!. If submit.always_blocking is set to true (see above), reviewers will always be set to blocking regardless.

A bug ID can also be set for every revision in the series with the --bug option, which overrides any bug IDs in commit messages. Similarly, reviewers can be set for every revision in the series with --reviewer (regular reviewers) and/or --blocker (blocking reviewers), which again overrides any reviewers in commit messages.

Use --ai to request an AI review for all revisions in the stack, including updates to existing revisions. Or enable the submit.ai_review config to request AI review automatically for new revisions.

Run moz-phab submit -h for more options for submitting revisions.

To submit updates to a commit series, run moz-phab in the same way with the same arguments, that is, specifying the full original range of commits. Note that, while inserting and amending commits should work fine, reordering commits is not yet supported, and deleting commits will leave the associated revisions open, which should be abandoned manually. See bug 1481539 for planned fixes. Also note that "fix-up" commits are not yet supported; see bug 1481542.

Downloading a patch from Phabricator

moz-phab patch allows patching an entire stack of revisions. The simplest invocation is

moz-phab patch revision_id

To patch a stack ending with the revision D123 run moz-phab patch D123. Diffs will be downloaded from Phabricator and applied using the underlying VCS (import for Mercurial or apply for Git). A commit for each revision will be created in a new bookmark or topic (Mercurial) or branch (Git).

This behavior can be modified with the following options:

  • --apply-to TARGET Define the commit to which apply the patch:

    • base (default) find the base commit in the first ancestor of the revision,
    • here use the current commit,
    • {NODE} use a commit identified by SHA1 or (in Mercurial) revision number
  • --raw Print out the diffs of each revision starting from the oldest ancestor instead of applying to the repository. It can be used to patch the working directory with an external tool: $ moz-phab patch D123 --raw | patch -p1. $ moz-phab patch D123 --raw | hg import. $ moz-phab patch D123 --raw | git am.

  • --no-commit Use the git apply command (also for Mercurial repos) to patch the diffs. No commit or branch is created.

  • --no-bookmark : used only when patching a Mercurial repository. If not provided - moz-phab will create a bookmark (based on the last revision number) for the new DAG branch point. The default behavior is configurable.

  • --no-topic : used only when patching a Mercurial repository. Requires the topic extension to be enabled. If not provided and enabled in the configuration - moz-phab will create a topic (based on the last revision number) for the new DAG branch point. The default behavior is configurable.

  • --no-branch: used only when patching a Git repository. If not provided - moz-phab will create a branch (based on the revision number). Otherwise commits will be added just on top of the base commit which might result in switching the repository to the 'detached HEAD' state.

  • --skip-dependencies : patch only one revision, ignore dependencies.

  • --diff-id DIFF_ID: used to specify a specific diff within a revision's history to pull

View on GitHub
GitHub Stars42
CategoryDevelopment
Updated1d ago
Forks47

Languages

Python

Security Score

90/100

Audited on Apr 9, 2026

No findings