From caed8a2830bf0fe56b0851165a9869fe772346e7 Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 6 May 2011 12:08:57 -0700 Subject: [PATCH] Restore "arc patch D12345" syntax Summary: I only dropped this because it's slightly inconvient to accommodate, but empirically it's pretty confusing to users (who often use --diff 12345 when they mean --revision 12345). Test Plan: Ran "arc patch D45", "arc patch --revision 45", "arc help patch" Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen, jungejason, aran CC: aran, tuomaspelkonen Differential Revision: 241 --- src/workflow/patch/ArcanistPatchWorkflow.php | 48 ++++++++++++++------ 1 file changed, 34 insertions(+), 14 deletions(-) diff --git a/src/workflow/patch/ArcanistPatchWorkflow.php b/src/workflow/patch/ArcanistPatchWorkflow.php index f6ffa6f3..6a4e5e61 100644 --- a/src/workflow/patch/ArcanistPatchWorkflow.php +++ b/src/workflow/patch/ArcanistPatchWorkflow.php @@ -23,17 +23,21 @@ */ final class ArcanistPatchWorkflow extends ArcanistBaseWorkflow { - const SOURCE_BUNDLE = 'bundle'; - const SOURCE_PATCH = 'patch'; - const SOURCE_REVISION = 'revision'; - const SOURCE_DIFF = 'diff'; + const SOURCE_BUNDLE = 'bundle'; + const SOURCE_PATCH = 'patch'; + const SOURCE_REVISION = 'revision'; + const SOURCE_DIFF = 'diff'; private $source; private $sourceParam; public function getCommandHelp() { return phutil_console_format(<< 'complete', 'help' => "Apply changes from a Differential revision, using the most recent ". - "diff that has been attached to it.", + "diff that has been attached to it. You can run 'arc patch D12345' ". + "as a shorthand for this.", ), 'diff' => array( 'param' => 'diff_id', @@ -70,6 +75,7 @@ EOTEXT 'help' => "Apply changes from a git patchfile or unified patchfile.", ), + '*' => 'name', ); } @@ -93,21 +99,35 @@ EOTEXT $requested++; } + $use_revision_id = null; + if ($this->getArgument('name')) { + $namev = $this->getArgument('name'); + if (count($namev) > 1) { + throw new ArcanistUsageException("Specify at most one revision name."); + } + $source = self::SOURCE_REVISION; + $requested++; + + $use_revision_id = $this->normalizeRevisionID(head($namev)); + } + if ($requested === 0) { throw new ArcanistUsageException( - "Specify one of '--revision ' (to select the current ". - "changes attached to a Differential revision), '--diff ' ". - "(to select a specific, out-of-date diff or a diff which is not ". - "attached to a revision), '--arcbundle ' or '--patch ' ". - "to choose a patch source."); + "Specify one of 'D12345', '--revision ' (to select the ". + "current changes attached to a Differential revision), ". + "'--diff ' (to select a specific, out-of-date diff or a ". + "diff which is not attached to a revision), '--arcbundle ' ". + "or '--patch ' to choose a patch source."); } else if ($requested > 1) { throw new ArcanistUsageException( - "Options '--revision', '--diff', '--arcbundle' and '--patch' are ". - "not compatible. Choose exactly one patch source."); + "Options 'D12345', '--revision', '--diff', '--arcbundle' and ". + "'--patch' are not compatible. Choose exactly one patch source."); } $this->source = $source; - $this->sourceParam = $this->getArgument($source); + $this->sourceParam = nonempty( + $use_revision_id, + $this->getArgument($source)); } public function requiresConduit() {