phacility/phabricator · warning · PhutilArgumentUsageException

Options "--all" (to migrate all hunks) and "--id" (to migrat

Error message

Options "--all" (to migrate all hunks) and "--id" (to migrate a specific hunk) are mutually exclusive.

What it means

./bin/differential migrate-hunk must select a scope: --id <id> migrates one hunk, --all migrates every hunk. Supplying both at once is contradictory, so the workflow throws this usage exception before reading anything. It is a mutually-exclusive-flag check on the 'all' and 'id' arguments.

Source

Thrown at src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php:47

          array(
            'name' => 'auto',
            'help' => pht('Select storage format automatically.'),
          ),
          array(
            'name' => 'dry-run',
            'help' => pht('Show planned writes but do not perform them.'),
          ),
        ));
  }

  public function execute(PhutilArgumentParser $args) {
    $is_dry_run = $args->getArg('dry-run');

    $id = $args->getArg('id');
    $is_all = $args->getArg('all');

    if ($is_all && $id) {
      throw new PhutilArgumentUsageException(
        pht(
          'Options "--all" (to migrate all hunks) and "--id" (to migrate a '.
          'specific hunk) are mutually exclusive.'));
    } else if (!$is_all && !$id) {
      throw new PhutilArgumentUsageException(
        pht(
          'Specify a hunk to migrate with "--id", or migrate all hunks '.
          'with "--all".'));
    }

    $is_auto = $args->getArg('auto');
    $storage = $args->getArg('to');
    if ($is_auto && $storage) {
      throw new PhutilArgumentUsageException(
        pht(
          'Options "--to" (to choose a specific storage format) and "--auto" '.
          '(to select a storage format automatically) are mutually '.
          'exclusive.'));

View on GitHub (pinned to 5720a38cfe)

Solutions

  1. Drop one flag: either --id <id> for a single hunk or --all for every hunk
  2. In scripts, build the flag list from one variable, e.g., one of ($SCOPE_FLAG), never both
  3. Use --dry-run with the corrected single scope to preview before real migration

Example fix

# before
phabricator/ $ ./bin/differential migrate-hunk --all --id 42 --auto
Usage Exception: Options "--all" ... and "--id" ... are mutually exclusive.

# after
phabricator/ $ ./bin/differential migrate-hunk --id 42 --auto
Defensive patterns

Strategy: validation

Validate before calling

# Emit exactly one scope flag
if [ -n "$HUNK_ID" ] && [ "$ALL" = "1" ]; then
  echo "pick either --id or --all, not both" >&2; exit 64
fi
phabricator/bin/differential migrate-hunk ${ALL:+--all} ${HUNK_ID:+--id "$HUNK_ID"} --auto

Try / catch

try {
  $workflow->execute($args);
} catch (PhutilArgumentUsageException $ex) {
  // Flag conflict: rebuild argv with a single scope flag and re-run.
}

Prevention

When it happens

Trigger: Running './bin/differential migrate-hunk --all --id 42 ...'; scripts templating both flags unconditionally (e.g., always passing --all and --id $LAST_ID); combining flags from two documented examples.

Common situations: Copy-pasted commands from migration runbooks; cron scripts that grew both flags over time; operators assuming --id acts as a 'start from' marker alongside --all.

Related errors


AI-assisted analysis of phacility/phabricator@5720a38cfe (2026-08-21). Data as JSON: /api/errors/c59a91d0178aece8. Report an issue: GitHub.