From 69c64c1e83e23f11a594686d0abb3f1a74c8d4b1 Mon Sep 17 00:00:00 2001 From: Aviv Eyal Date: Thu, 31 Aug 2023 10:55:13 -0700 Subject: [PATCH] Teach Commit View about Encoding Summary: If the user specifies a text encoding via the "View Options" dropdown, respect this choice. Ref Q68. Test Plan: Play with the Encoding button in the view Reviewers: O1 Blessed Committers, valerio.bozzolan Reviewed By: O1 Blessed Committers, valerio.bozzolan Subscribers: tinloaf, speck, tobiaswiese, valerio.bozzolan, Matthew, Cigaryno Differential Revision: https://we.phorge.it/D25360 --- .../conduit/DiffusionDiffQueryConduitAPIMethod.php | 9 ++++++--- .../diffusion/controller/DiffusionDiffController.php | 1 + 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php b/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php index 694d4bc012..397ccefa86 100644 --- a/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php +++ b/src/applications/diffusion/conduit/DiffusionDiffQueryConduitAPIMethod.php @@ -23,6 +23,7 @@ final class DiffusionDiffQueryConduitAPIMethod return array( 'path' => 'required string', 'commit' => 'optional string', + 'encoding' => 'optional string', ); } @@ -212,18 +213,20 @@ final class DiffusionDiffQueryConduitAPIMethod return $this->getEmptyResult(); } - $parser = $this->getDefaultParser(); + $parser = $this->getDefaultParser($request); $changes = $parser->parseDiff($raw_diff); return $changes; } - private function getDefaultParser() { + private function getDefaultParser(ConduitAPIRequest $request) { $drequest = $this->getDiffusionRequest(); $repository = $drequest->getRepository(); $parser = new ArcanistDiffParser(); - $try_encoding = $repository->getDetail('encoding'); + $try_encoding = coalesce( + $request->getValue('encoding'), + $repository->getDetail('encoding')); if ($try_encoding) { $parser->setTryEncoding($try_encoding); } diff --git a/src/applications/diffusion/controller/DiffusionDiffController.php b/src/applications/diffusion/controller/DiffusionDiffController.php index 69a473dc91..a844dc23d2 100644 --- a/src/applications/diffusion/controller/DiffusionDiffController.php +++ b/src/applications/diffusion/controller/DiffusionDiffController.php @@ -48,6 +48,7 @@ final class DiffusionDiffController extends DiffusionController { array( 'commit' => $drequest->getCommit(), 'path' => $drequest->getPath(), + 'encoding' => $request->getStr('encoding'), )); $drequest->updateSymbolicCommit($data['effectiveCommit']); $raw_changes = ArcanistDiffChange::newFromConduit($data['changes']);