Skip to content

Commit

Permalink
Bump Conduit client version
Browse files Browse the repository at this point in the history
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
  • Loading branch information
epriestley committed May 21, 2012
1 parent 3e655e7 commit ccdf9ae
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 28 deletions.
8 changes: 8 additions & 0 deletions scripts/arcanist.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
$config_trace_mode = $args->getArg('trace'); $config_trace_mode = $args->getArg('trace');


$force_conduit = null; $force_conduit = null;
$force_conduit_version = null;
$args = $argv; $args = $argv;
$load = array(); $load = array();
$matches = null; $matches = null;
Expand All @@ -54,6 +55,9 @@
} else if (preg_match('/^--conduit-uri=(.*)$/', $arg, $matches)) { } else if (preg_match('/^--conduit-uri=(.*)$/', $arg, $matches)) {
unset($args[$key]); unset($args[$key]);
$force_conduit = $matches[1]; $force_conduit = $matches[1];
} else if (preg_match('/^--conduit-version=(.*)$/', $arg, $matches)) {
unset($args[$key]);
$force_conduit_version = $matches[1];
} }
} }


Expand Down Expand Up @@ -193,6 +197,10 @@
$workflow->setWorkingDirectory($working_directory); $workflow->setWorkingDirectory($working_directory);
$workflow->parseArguments($args); $workflow->parseArguments($args);


if ($force_conduit_version) {
$workflow->forceConduitVersion($force_conduit_version);
}

$need_working_copy = $workflow->requiresWorkingCopy(); $need_working_copy = $workflow->requiresWorkingCopy();
$need_conduit = $workflow->requiresConduit(); $need_conduit = $workflow->requiresConduit();
$need_auth = $workflow->requiresAuthentication(); $need_auth = $workflow->requiresAuthentication();
Expand Down
11 changes: 10 additions & 1 deletion src/workflow/base/ArcanistBaseWorkflow.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ abstract class ArcanistBaseWorkflow {
private $conduitURI; private $conduitURI;
private $conduitCredentials; private $conduitCredentials;
private $conduitAuthenticated; private $conduitAuthenticated;
private $forcedConduitVersion;


private $userPHID; private $userPHID;
private $userName; private $userName;
Expand Down Expand Up @@ -178,6 +179,14 @@ final public function setConduitCredentials(array $credentials) {
return $this; 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 * Open and authenticate a conduit connection to a Phabricator server using
Expand Down Expand Up @@ -234,7 +243,7 @@ final public function authenticateConduit() {
'conduit.connect', 'conduit.connect',
array( array(
'client' => 'arc', 'client' => 'arc',
'clientVersion' => 4, 'clientVersion' => $this->getConduitVersion(),
'clientDescription' => php_uname('n').':'.$description, 'clientDescription' => php_uname('n').':'.$description,
'user' => $user, 'user' => $user,
'certificate' => $certificate, 'certificate' => $certificate,
Expand Down
5 changes: 5 additions & 0 deletions src/workflow/help/ArcanistHelpWorkflow.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ public function run() {
Ignore configured Conduit URI and use an explicit one instead. Mostly Ignore configured Conduit URI and use an explicit one instead. Mostly
useful for Arcanist development. 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 EOTEXT
); );
Expand Down
60 changes: 33 additions & 27 deletions src/workflow/upgrade/ArcanistUpgradeWorkflow.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function getCommandSynopses() {
public function getCommandHelp() { public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT return phutil_console_format(<<<EOTEXT
Supports: cli Supports: cli
Upgrade arc to the latest version. Upgrade arcanist and libphutil to the latest versions.
EOTEXT EOTEXT
); );
} }
Expand All @@ -43,38 +43,44 @@ public function getArguments() {
} }


public function run() { public function run() {
echo "Upgrading arc...\n"; $roots = array();
$root = dirname(phutil_get_library_root('arcanist')); $roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));


if (!Filesystem::pathExists($root.'/.git')) { foreach ($roots as $lib => $root) {
throw new ArcanistUsageException( echo "Upgrading {$lib}...\n";
"arc must be in its git working copy to be automatically upgraded. ".
"This copy of arc (in '{$root}') is not in a git working copy.");
}


$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 = ArcanistWorkingCopyIdentity::newFromPath($root);
$working_copy);
$this->setRepositoryAPI($repository_api);


// Require no local changes. $repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
$this->requireCleanWorkingCopy(); $working_copy);
$this->setRepositoryAPI($repository_api);


// Require arc be on master. // Require no local changes.
$branch_name = $repository_api->getBranchName(); $this->requireCleanWorkingCopy();
if ($branch_name != 'master') {
throw new ArcanistUsageException( // Require the library be on master.
"arc must be on branch 'master' to be automatically upgraded. ". $branch_name = $repository_api->getBranchName();
"This copy of arc (in '{$root}') is on branch '{$branch_name}'."); 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); chdir($root);
try { try {
phutil_passthru('git pull --rebase'); phutil_passthru('git pull --rebase');
} catch (Exception $ex) { } catch (Exception $ex) {
phutil_passthru('git rebase --abort'); phutil_passthru('git rebase --abort');
throw $ex; throw $ex;
}
} }


echo phutil_console_wrap( echo phutil_console_wrap(
Expand Down

0 comments on commit ccdf9ae

Please sign in to comment.