$config_trace_mode = $args->getArg('trace');
$force_conduit = null;
+$force_conduit_version = null;
$args = $argv;
$load = array();
$matches = null;
} 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];
}
}
$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();
private $conduitURI;
private $conduitCredentials;
private $conduitAuthenticated;
+ private $forcedConduitVersion;
private $userPHID;
private $userName;
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
'conduit.connect',
array(
'client' => 'arc',
- 'clientVersion' => 4,
+ 'clientVersion' => $this->getConduitVersion(),
'clientDescription' => php_uname('n').':'.$description,
'user' => $user,
'certificate' => $certificate,
public function getCommandHelp() {
return phutil_console_format(<<<EOTEXT
Supports: cli
- Upgrade arc to the latest version.
+ Upgrade arcanist and libphutil to the latest versions.
EOTEXT
);
}
}
public function run() {
- echo "Upgrading arc...\n";
- $root = dirname(phutil_get_library_root('arcanist'));
+ $roots = array();
+ $roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
+ $roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
- if (!Filesystem::pathExists($root.'/.git')) {
- throw new ArcanistUsageException(
- "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.");
- }
+ foreach ($roots as $lib => $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();
+
+ // 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;
+ chdir($root);
+ try {
+ phutil_passthru('git pull --rebase');
+ } catch (Exception $ex) {
+ phutil_passthru('git rebase --abort');
+ throw $ex;
+ }
}
echo phutil_console_wrap(