Skip to content
This repository was archived by the owner on Jan 29, 2025. It is now read-only.

Commit ccdf9ae

Browse files
author
epriestley
committedMay 21, 2012
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
1 parent 3e655e7 commit ccdf9ae

File tree

4 files changed

+56
-28
lines changed

4 files changed

+56
-28
lines changed
 

‎scripts/arcanist.php

+8
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
$config_trace_mode = $args->getArg('trace');
4343

4444
$force_conduit = null;
45+
$force_conduit_version = null;
4546
$args = $argv;
4647
$load = array();
4748
$matches = null;
@@ -54,6 +55,9 @@
5455
} else if (preg_match('/^--conduit-uri=(.*)$/', $arg, $matches)) {
5556
unset($args[$key]);
5657
$force_conduit = $matches[1];
58+
} else if (preg_match('/^--conduit-version=(.*)$/', $arg, $matches)) {
59+
unset($args[$key]);
60+
$force_conduit_version = $matches[1];
5761
}
5862
}
5963

@@ -193,6 +197,10 @@
193197
$workflow->setWorkingDirectory($working_directory);
194198
$workflow->parseArguments($args);
195199

200+
if ($force_conduit_version) {
201+
$workflow->forceConduitVersion($force_conduit_version);
202+
}
203+
196204
$need_working_copy = $workflow->requiresWorkingCopy();
197205
$need_conduit = $workflow->requiresConduit();
198206
$need_auth = $workflow->requiresAuthentication();

‎src/workflow/base/ArcanistBaseWorkflow.php

+10-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ abstract class ArcanistBaseWorkflow {
5656
private $conduitURI;
5757
private $conduitCredentials;
5858
private $conduitAuthenticated;
59+
private $forcedConduitVersion;
5960

6061
private $userPHID;
6162
private $userName;
@@ -178,6 +179,14 @@ final public function setConduitCredentials(array $credentials) {
178179
return $this;
179180
}
180181

182+
public function forceConduitVersion($version) {
183+
$this->forcedConduitVersion = $version;
184+
return $this;
185+
}
186+
187+
public function getConduitVersion() {
188+
return nonempty($this->forcedConduitVersion, 5);
189+
}
181190

182191
/**
183192
* Open and authenticate a conduit connection to a Phabricator server using
@@ -234,7 +243,7 @@ final public function authenticateConduit() {
234243
'conduit.connect',
235244
array(
236245
'client' => 'arc',
237-
'clientVersion' => 4,
246+
'clientVersion' => $this->getConduitVersion(),
238247
'clientDescription' => php_uname('n').':'.$description,
239248
'user' => $user,
240249
'certificate' => $certificate,

‎src/workflow/help/ArcanistHelpWorkflow.php

+5
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,11 @@ public function run() {
199199
Ignore configured Conduit URI and use an explicit one instead. Mostly
200200
useful for Arcanist development.
201201
202+
__--conduit-version=...__
203+
Ignore software version and claim to be running some other version
204+
instead. Mostly useful for Arcanist development. May cause bad things
205+
to happen.
206+
202207
203208
EOTEXT
204209
);

‎src/workflow/upgrade/ArcanistUpgradeWorkflow.php

+33-27
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getCommandSynopses() {
3333
public function getCommandHelp() {
3434
return phutil_console_format(<<<EOTEXT
3535
Supports: cli
36-
Upgrade arc to the latest version.
36+
Upgrade arcanist and libphutil to the latest versions.
3737
EOTEXT
3838
);
3939
}
@@ -43,38 +43,44 @@ public function getArguments() {
4343
}
4444

4545
public function run() {
46-
echo "Upgrading arc...\n";
47-
$root = dirname(phutil_get_library_root('arcanist'));
46+
$roots = array();
47+
$roots['libphutil'] = dirname(phutil_get_library_root('phutil'));
48+
$roots['arcanist'] = dirname(phutil_get_library_root('arcanist'));
4849

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

55-
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
53+
if (!Filesystem::pathExists($root.'/.git')) {
54+
throw new ArcanistUsageException(
55+
"{$lib} must be in its git working copy to be automatically ".
56+
"upgraded. This copy of {$lib} (in '{$root}') is not in a git ".
57+
"working copy.");
58+
}
5659

57-
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
58-
$working_copy);
59-
$this->setRepositoryAPI($repository_api);
60+
$working_copy = ArcanistWorkingCopyIdentity::newFromPath($root);
6061

61-
// Require no local changes.
62-
$this->requireCleanWorkingCopy();
62+
$repository_api = ArcanistRepositoryAPI::newAPIFromWorkingCopyIdentity(
63+
$working_copy);
64+
$this->setRepositoryAPI($repository_api);
6365

64-
// Require arc be on master.
65-
$branch_name = $repository_api->getBranchName();
66-
if ($branch_name != 'master') {
67-
throw new ArcanistUsageException(
68-
"arc must be on branch 'master' to be automatically upgraded. ".
69-
"This copy of arc (in '{$root}') is on branch '{$branch_name}'.");
70-
}
66+
// Require no local changes.
67+
$this->requireCleanWorkingCopy();
68+
69+
// Require the library be on master.
70+
$branch_name = $repository_api->getBranchName();
71+
if ($branch_name != 'master') {
72+
throw new ArcanistUsageException(
73+
"{$lib} must be on branch 'master' to be automatically upgraded. ".
74+
"This copy of {$lib} (in '{$root}') is on branch '{$branch_name}'.");
75+
}
7176

72-
chdir($root);
73-
try {
74-
phutil_passthru('git pull --rebase');
75-
} catch (Exception $ex) {
76-
phutil_passthru('git rebase --abort');
77-
throw $ex;
77+
chdir($root);
78+
try {
79+
phutil_passthru('git pull --rebase');
80+
} catch (Exception $ex) {
81+
phutil_passthru('git rebase --abort');
82+
throw $ex;
83+
}
7884
}
7985

8086
echo phutil_console_wrap(

0 commit comments

Comments
 (0)
Failed to load comments.