{"record":{"id":"c59a91d0178aece8","repo":"phacility/phabricator","slug":"options-all-to-migrate-all-hunks-and-id","errorCode":null,"errorMessage":"Options \"--all\" (to migrate all hunks) and \"--id\" (to migrate a specific hunk) are mutually exclusive.","messagePattern":"Options \"--all\" \\(to migrate all hunks\\) and \"--id\" \\(to migrate a specific hunk\\) are mutually exclusive\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php","lineNumber":47,"sourceCode":"          array(\n            'name' => 'auto',\n            'help' => pht('Select storage format automatically.'),\n          ),\n          array(\n            'name' => 'dry-run',\n            'help' => pht('Show planned writes but do not perform them.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $is_dry_run = $args->getArg('dry-run');\n\n    $id = $args->getArg('id');\n    $is_all = $args->getArg('all');\n\n    if ($is_all && $id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Options \"--all\" (to migrate all hunks) and \"--id\" (to migrate a '.\n          'specific hunk) are mutually exclusive.'));\n    } else if (!$is_all && !$id) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Specify a hunk to migrate with \"--id\", or migrate all hunks '.\n          'with \"--all\".'));\n    }\n\n    $is_auto = $args->getArg('auto');\n    $storage = $args->getArg('to');\n    if ($is_auto && $storage) {\n      throw new PhutilArgumentUsageException(\n        pht(\n          'Options \"--to\" (to choose a specific storage format) and \"--auto\" '.\n          '(to select a storage format automatically) are mutually '.\n          'exclusive.'));","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialMigrateHunkWorkflow.php#L29-L65","documentation":"./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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Drop one flag: either --id <id> for a single hunk or --all for every hunk","In scripts, build the flag list from one variable, e.g., one of ($SCOPE_FLAG), never both","Use --dry-run with the corrected single scope to preview before real migration"],"exampleFix":"# before\nphabricator/ $ ./bin/differential migrate-hunk --all --id 42 --auto\nUsage Exception: Options \"--all\" ... and \"--id\" ... are mutually exclusive.\n\n# after\nphabricator/ $ ./bin/differential migrate-hunk --id 42 --auto","handlingStrategy":"validation","validationCode":"# Emit exactly one scope flag\nif [ -n \"$HUNK_ID\" ] && [ \"$ALL\" = \"1\" ]; then\n  echo \"pick either --id or --all, not both\" >&2; exit 64\nfi\nphabricator/bin/differential migrate-hunk ${ALL:+--all} ${HUNK_ID:+--id \"$HUNK_ID\"} --auto","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Flag conflict: rebuild argv with a single scope flag and re-run.\n}","preventionTips":["Model --all/--id as one mutually exclusive option in wrapper scripts (a single SCOPE variable)","Always pair the first run of a migration with --dry-run"],"tags":["phabricator","differential","cli","migrate-hunk","mutually-exclusive-flags","usage-error"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}