1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 06:42:41 +01:00

Don't fatal without Conduit for "--patch" and "--bundle"

Summary:
In some workflows, we don't have Conduit at all, so we'll fail with a raw exception. Test for conduit presence before trying to make the encoding call.

Also move some "instanceof" logic for updates into RepositoryAPI (factoring, windows compat).

Test Plan: Ran "arc patch --patch some.patch".

Reviewers: 20after4, davidreuss, nh, btrahan

Reviewed By: 20after4

CC: aran, epriestley

Differential Revision: https://secure.phabricator.com/D1935
This commit is contained in:
epriestley 2012-03-16 13:40:33 -07:00
parent f15479c832
commit 89753d5d49
5 changed files with 22 additions and 25 deletions

View file

@ -160,6 +160,7 @@ abstract class ArcanistRepositoryAPI {
abstract public function getCanonicalRevisionName($string);
abstract public function supportsRelativeLocalCommits();
abstract public function getWorkingCopyRevision();
abstract public function updateWorkingCopy();
abstract public function loadWorkingCopyDifferentialRevisions(
ConduitClient $conduit,
array $query);

View file

@ -672,4 +672,8 @@ final class ArcanistGitAPI extends ArcanistRepositoryAPI {
return $results;
}
public function updateWorkingCopy() {
$this->execxLocal('pull');
}
}

View file

@ -430,4 +430,8 @@ final class ArcanistMercurialAPI extends ArcanistRepositoryAPI {
return $results;
}
public function updateWorkingCopy() {
$this->execxLocal('up');
}
}

View file

@ -549,4 +549,8 @@ EODIFF;
return $results;
}
public function updateWorkingCopy() {
$this->execxLocal('up');
}
}

View file

@ -298,27 +298,9 @@ EOTEXT
}
private function updateWorkingCopy() {
$repository_api = $this->getRepositoryAPI();
if ($repository_api instanceof ArcanistSubversionAPI) {
execx(
'(cd %s; svn up)',
$repository_api->getPath());
$message = "Updated to HEAD. ";
} else if ($repository_api instanceof ArcanistGitAPI) {
execx(
'(cd %s; git pull)',
$repository_api->getPath());
$message = "Updated to HEAD. ";
} else if ($repository_api instanceof ArcanistMercurialAPI) {
execx(
'(cd %s; hg up)',
$repository_api->getPath());
$message = "Updated to tip. ";
} else {
throw new Exception('Unknown version control system.');
}
echo phutil_console_format($message."\n");
echo "Updating working copy...\n";
$this->getRepositoryAPI()->updateWorkingCopy();
echo "Done.\n";
}
public function run() {
@ -367,12 +349,14 @@ EOTEXT
$try_encoding = nonempty($this->getArgument('encoding'), null);
if (!$try_encoding) {
if ($this->requiresConduit()) {
try {
$try_encoding = $this->getRepositoryEncoding();
} catch (ConduitClientException $e) {
$try_encoding = null;
}
}
}
if ($try_encoding) {
$bundle->setEncoding($try_encoding);