From ccdf9ae957f995154374a0dc344fb260b112ce2b Mon Sep 17 00:00:00 2001 From: epriestley Date: Mon, 21 May 2012 16:45:03 -0700 Subject: [PATCH] Bump Conduit client version Summary: Several related changes: - Add a "--conduit-version" flag, so you can actually diff conduit version bumps. Otherwise, the server rejects you. - Make "arc upgrade" upgrade both libphutil and arcanist, not just arcanist. - Bump the version number to 5. See D2527. Test Plan: - Ran "arc upgrade". - Ran "arc diff". Got told there was a version issue. - Ran "arc diff --conduit-version=4" to create this diff. Reviewers: indiefan, nh, vrana, btrahan, jungejason, Makinde Reviewed By: vrana CC: aran Differential Revision: https://secure.phabricator.com/D2528 --- scripts/arcanist.php | 8 +++ src/workflow/base/ArcanistBaseWorkflow.php | 11 +++- src/workflow/help/ArcanistHelpWorkflow.php | 5 ++ .../upgrade/ArcanistUpgradeWorkflow.php | 60 ++++++++++--------- 4 files changed, 56 insertions(+), 28 deletions(-) diff --git a/scripts/arcanist.php b/scripts/arcanist.php index 785f4f8a..058fdedf 100755 --- a/scripts/arcanist.php +++ b/scripts/arcanist.php @@ -42,6 +42,7 @@ $argv = $args->getUnconsumedArgumentVector(); $config_trace_mode = $args->getArg('trace'); $force_conduit = null; +$force_conduit_version = null; $args = $argv; $load = array(); $matches = null; @@ -54,6 +55,9 @@ foreach ($args as $key => $arg) { } else if (preg_match('/^--conduit-uri=(.*)$/', $arg, $matches)) { unset($args[$key]); $force_conduit = $matches[1]; + } else if (preg_match('/^--conduit-version=(.*)$/', $arg, $matches)) { + unset($args[$key]); + $force_conduit_version = $matches[1]; } } @@ -193,6 +197,10 @@ try { $workflow->setWorkingDirectory($working_directory); $workflow->parseArguments($args); + if ($force_conduit_version) { + $workflow->forceConduitVersion($force_conduit_version); + } + $need_working_copy = $workflow->requiresWorkingCopy(); $need_conduit = $workflow->requiresConduit(); $need_auth = $workflow->requiresAuthentication(); diff --git a/src/workflow/base/ArcanistBaseWorkflow.php b/src/workflow/base/ArcanistBaseWorkflow.php index e7cb4560..426631b1 100644 --- a/src/workflow/base/ArcanistBaseWorkflow.php +++ b/src/workflow/base/ArcanistBaseWorkflow.php @@ -56,6 +56,7 @@ abstract class ArcanistBaseWorkflow { private $conduitURI; private $conduitCredentials; private $conduitAuthenticated; + private $forcedConduitVersion; private $userPHID; private $userName; @@ -178,6 +179,14 @@ abstract class ArcanistBaseWorkflow { return $this; } + public function forceConduitVersion($version) { + $this->forcedConduitVersion = $version; + return $this; + } + + public function getConduitVersion() { + return nonempty($this->forcedConduitVersion, 5); + } /** * Open and authenticate a conduit connection to a Phabricator server using @@ -234,7 +243,7 @@ abstract class ArcanistBaseWorkflow { 'conduit.connect', array( 'client' => 'arc', - 'clientVersion' => 4, + 'clientVersion' => $this->getConduitVersion(), 'clientDescription' => php_uname('n').':'.$description, 'user' => $user, 'certificate' => $certificate, diff --git a/src/workflow/help/ArcanistHelpWorkflow.php b/src/workflow/help/ArcanistHelpWorkflow.php index 47de7394..a9c00b4c 100644 --- a/src/workflow/help/ArcanistHelpWorkflow.php +++ b/src/workflow/help/ArcanistHelpWorkflow.php @@ -199,6 +199,11 @@ EOTEXT Ignore configured Conduit URI and use an explicit one instead. Mostly useful for Arcanist development. + __--conduit-version=...__ + Ignore software version and claim to be running some other version + instead. Mostly useful for Arcanist development. May cause bad things + to happen. + EOTEXT ); diff --git a/src/workflow/upgrade/ArcanistUpgradeWorkflow.php b/src/workflow/upgrade/ArcanistUpgradeWorkflow.php index 58b51353..d2ced0e1 100644 --- a/src/workflow/upgrade/ArcanistUpgradeWorkflow.php +++ b/src/workflow/upgrade/ArcanistUpgradeWorkflow.php @@ -33,7 +33,7 @@ EOTEXT public function getCommandHelp() { return phutil_console_format(<< $root) { + echo "Upgrading {$lib}...\n"; - $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root); + if (!Filesystem::pathExists($root.'/.git')) { + throw new ArcanistUsageException( + "{$lib} must be in its git working copy to be automatically ". + "upgraded. This copy of {$lib} (in '{$root}') is not in a git ". + "working copy."); + } - $repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity( - $working_copy); - $this->setRepositoryAPI($repository_api); + $working_copy = ArcanistWorkingCopyIdentity::newFromPath($root); - // Require no local changes. - $this->requireCleanWorkingCopy(); + $repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity( + $working_copy); + $this->setRepositoryAPI($repository_api); - // Require arc be on master. - $branch_name = $repository_api->getBranchName(); - if ($branch_name != 'master') { - throw new ArcanistUsageException( - "arc must be on branch 'master' to be automatically upgraded. ". - "This copy of arc (in '{$root}') is on branch '{$branch_name}'."); - } + // Require no local changes. + $this->requireCleanWorkingCopy(); - chdir($root); - try { - phutil_passthru('git pull --rebase'); - } catch (Exception $ex) { - phutil_passthru('git rebase --abort'); - throw $ex; + // Require the library be on master. + $branch_name = $repository_api->getBranchName(); + if ($branch_name != 'master') { + throw new ArcanistUsageException( + "{$lib} must be on branch 'master' to be automatically upgraded. ". + "This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'."); + } + + chdir($root); + try { + phutil_passthru('git pull --rebase'); + } catch (Exception $ex) { + phutil_passthru('git rebase --abort'); + throw $ex; + } } echo phutil_console_wrap(