1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-09-20 08:58:55 +02:00

Added local encoding parameter for arc diff workflow

Summary:
If any hunks is detected as non-utf8, and you've never submitted diffs
for a certain project before, you would get a ERR-BAD-ARCANIST-PROJECT
exception. This makes it possible to submit the patch properly, so you
can set the encoding in the interface afterwards. Further this fixes
cases where you don't supply a diff but will result in hunks getting
treated as binary, but that still beats the exception behaviour.

Test Plan:
Ran `arc diff` with and without the new --encoding param and
got the expected results. Also ensured the diff (with non utf-8 hunks)
would be properly created even when no encoding is specified.

Reviewers: epriestley

Reviewed By: epriestley

CC: aran, epriestley

Differential Revision: 1135
This commit is contained in:
David Reuss 2011-12-01 08:56:03 -08:00 committed by epriestley
parent 99717090ef
commit 1f69ab5fdb

View file

@ -138,6 +138,11 @@ EOTEXT
'message' => '--preview does not update any revision.',
),
),
'encoding' => array(
'param' => 'encoding',
'help' =>
"Attempt to convert non UTF-8 hunks into specified encoding.",
),
'allow-untracked' => array(
'help' =>
"Skip checks for untracked files in the working copy.",
@ -751,15 +756,28 @@ EOTEXT
// liberal about what they're willing to process.
$is_binary = ArcanistDiffUtils::isHeuristicBinaryFile($corpus);
if (!$is_binary) {
$try_encoding = nonempty($this->getArgument('encoding'), null);
if ($try_encoding === null) {
// Make a call to check if there's an encoding specified for this
// project.
try {
$project_info = $this->getConduit()->callMethodSynchronous(
'arcanist.projectinfo',
array(
'name' => $this->getWorkingCopy()->getProjectID(),
));
$try_encoding = nonempty($project_info['encoding'], false);
} catch (ConduitClientException $e) {
if ($e->getErrorCode() == 'ERR-BAD-ARCANIST-PROJECT') {
echo phutil_console_wrap(
"Lookup of encoding in arcanist project failed\n".
$e->getMessage()
);
$try_encoding = false;
} else {
throw $e;
}
}
}
if ($try_encoding) {
// NOTE: This feature is HIGHLY EXPERIMENTAL and will cause a lot