Page MenuHomePhorge

Fix "arc diff" in Subversion for non-English languages
Closed, ResolvedPublic

Description

The arc diff command does not work correctly in Arcanist when the LANGUAGE environment variable is set to stuff like en_US:it_IT.

When it happens, you may get this exception:

Undefined array key "Repository UUID"

Example using --trace to show full stack trace and --only to run a test that has little impact on already-existing revisions:

$ export LANGUAGE=en_US:it_IT
$ arc diff --only --trace
arc diff --only --trace
 ARGV  /home/boz/.local/bin/arc diff --only --trace
>>> [1] (+0) <exec> $ php -f /home/boz/repos/arcanist/scripts/arcanist.php -- diff --only --trace
 ARGV  /home/boz/repos/arcanist/scripts/arcanist.php diff --only --trace
 LOAD  Loaded "arcanist" from "/home/boz/repos/arcanist/src".
Config: Reading user configuration file "/home/boz/.arcrc"...
Config: Did not find system configuration at "/etc/arcconfig".
Working Copy: Reading .arcconfig from "/home/boz/svn_example_repo/.arcconfig".
Working Copy: Path "/home/boz/svn_example_repo" is part of `svn` working copy "/home/boz/svn_example_repo".
Working Copy: Project root is at "/home/boz/svn_example_repo".
Config: Did not find local configuration at "/home/boz/svn_example_repo/.svn/arc/config".
>>> [1] (+0) <http> https://phorge.example.com/api/user.whoami
<<< [1] (+166) <http> 166,711 us
>>> [2] (+170) <exec> $ svn --xml status
<<< [2] (+210) <exec> 39,841 us
>>> [3] (+1,862) <event> diff.didCollectChanges <listeners = 0>
<<< [3] (+1,862) <event> 123 us
>>> [4] (+1,862) <event> diff.didBuildMessage <listeners = 0>
<<< [4] (+1,862) <event> 23 us
Linting...
No lint engine configured for this project.
Running unit tests...
No unit test engine is configured for this project.
[2024-06-21 14:37:20] ERROR 8192: strlen(): Passing null to parameter #1 ($string) of type string is deprecated at [/home/boz/repos/arcanist/src/repository/api/ArcanistSubversionAPI.php:243]
arcanist(head=master, ref.master=f7fcf31c7e23)
  #0 ArcanistSubversionAPI::getBranchName() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:2234]
  #1 ArcanistDiffWorkflow::buildDiffSpecification() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:380]
  #2 ArcanistDiffWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]

[2024-06-21 14:37:20] EXCEPTION: (RuntimeException) Undefined array key "Repository UUID" at [<arcanist>/src/error/PhutilErrorHandler.php:273]
arcanist(head=master, ref.master=f7fcf31c7e23)
  #0 PhutilErrorHandler::handleError(integer, string, string, integer) called at [<arcanist>/src/repository/api/ArcanistSubversionAPI.php:606]
  #1 ArcanistSubversionAPI::getRepositoryUUID() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:2235]
  #2 ArcanistDiffWorkflow::buildDiffSpecification() called at [<arcanist>/src/workflow/ArcanistDiffWorkflow.php:380]
  #3 ArcanistDiffWorkflow::run() called at [<arcanist>/scripts/arcanist.php:427]
<<< [1] (+1,979) <exec> 1,979,677 us

This probably happens because svn info is affected by the LANGUAGE / LC_MESSAGES (and more) environment variable. So, defusing localization fixes the issue.

NOTE: The error message strlen(): Passing null to parameter #1 ($string) of type string is deprecated from ArcanistSubversionAPI.php:243 is very probably not the root cause, but just a consequence.

Look the localized result of svn info:

$ export LC_TIME=it_IT.UTF-8
$ export LANGUAGE=en_US:it_IT
$ svn info
Percorso: .
Working Copy Root Path: /home/boz/svn_example_repo
URL: svn+ssh://phab@phorge.example.com/source/svn_example_repo/trunk
Relative URL: ^/trunk
Repository: svn+ssh://phab@phorge.example.com/source/svn_example_repo
UUID del Repository: 384bb524-2d96-4f3e-9ad6-60c0b842faff
Revisione: 1922
Tipo di nodo: directory
Azione: normale
Autore dell'ultima modifica: valerio.bozzolan
Revisione dell'ultima modifica: 1922
Data dell'ultima modifica: 2024-06-10 15:06:40 +0200(lun, 10 giu 2024)

Expected output to be able to parse it, resetting LC_ALL=C:

$ export LC_TIME=it_IT.UTF-8
$ export LANGUAGE=en_US:it_IT
$ export LC_ALL=C
$ svn info
Path: .
Working Copy Root Path: /home/boz/er/fe_data_imprt
URL: svn+ssh://phab@phorge.example.com/source/svn_example_repo/trunk
Relative URL: ^/trunk
Repository Root: svn+ssh://phab@phorge.example.com/source/svn_example_repo
Repository UUID: 384bb524-2d96-4f3e-9ad6-60c0b842f5ff
Revision: 1922
Node Kind: directory
Schedule: normal
Last Changed Author: valerio.bozzolan
Last Changed Rev: 1922
Last Changed Date: 2024-06-10 15:06:40 +0200 (Mon, 10 Jun 2024)

Counter example, see the wrong Italian dates (10 giu) resetting just LANGUAGE:

$ export LC_TIME=it_IT.UTF-8
$ export LANGUAGE=C
$ svn info
Path: .
Working Copy Root Path: /home/boz/svn_example_repo
URL: svn+ssh://phab@phorge.example.com/source/svn_example_repo/trunk
Relative URL: ^/trunk
Repository Root: svn+ssh://phab@phorge.example.com/source/svn_example_repo
Repository UUID: 384bb524-2d96-4f3e-9ad6-60c0b842faff
Revision: 1922
Node Kind: directory
Schedule: normal
Last Changed Author: valerio.bozzolan
Last Changed Rev: 1922
Last Changed Date: 2024-06-10 15:06:40 +0200 (lun, 10 giu 2024)