Page MenuHomePhabricator

`arc diff` on windows not working because of char ♀ (Unparsable Mercurial status line)
Closed, ResolvedPublic

Description

Hi,

I cannot manage to get arc diff working on my windows computer. I could use some help!
My setup:

(by the way I've got a working phabricator installation, so I can manage a command line and some config file)

Has you can see in the following block, it says:
EXCEPTION: (Exception) Unparsable Mercurial status line '♀M Faxgate\Misc\LRE_CommandLine\Program.cs'. at [<arcanist>\src\repository\parser\ArcanistMercurialParser.php:37]

Please notice the weird character: ♀ (+/- visible according to your font and font-size)
Hoping this is not a sexist joke :-p

ArcanistMercurialParser.php:37 is checking the space between the flag M and the file path with the code if ($line[1] !== ' ') {
And it fails here because of the extra char...

But I have NO idea from where that ♀ is coming from!
If I do hg status > out.txt, everything's fine, no weird char.

I've tried to remove all [extensions] from my mercurial.ini but still the same.
At first I also thought it was because of CLINK but nope either.
Also tried --encoding with various values... still no success

If you guys have any idea...

C:\Users\TiTi\Desktop\OPI>hg status
M Faxgate\Misc\LRE_CommandLine\Program.cs

C:\Users\TiTi\Desktop\OPI>arc diff
Exception
Unparsable Mercurial status line '♀M Faxgate\Misc\LRE_CommandLine\Program.cs'.
(Run with --trace for a full exception trace.)

C:\Users\TiTi\Desktop\OPI>arc diff --trace
libphutil loaded from 'C:\Users\TiTi\Documents\GitHub\libphutil\src'.
arcanist loaded from 'C:\Users\TiTi\Documents\GitHub\arcanist\src'.
Config: Reading user configuration file "C:\Users\TiTi\AppData\Roaming/.arcrc"...
Config: Did not find system configuration at "C:\ProgramData\Phabricator/Arcanist/config".
Working Copy: Reading .arcconfig from "C:\Users\TiTi\Desktop\OPI/.arcconfig".
Working Copy: Path "C:\Users\TiTi\Desktop\OPI" is part of `hg` working copy "C:\Users\TiTi\Desktop\OPI".
Working Copy: Project root is at "C:\Users\TiTi\Desktop\OPI".
Config: Did not find local configuration at "C:\Users\TiTi\Desktop\OPI\.hg\arc/config".
>>> [0] <conduit> conduit.connect() <bytes = 457>
>>> [1] <http> http://192.168.56.1/api/conduit.connect
<<< [1] <http> 108,999 us
<<< [0] <conduit> 108,999 us
>>> [2] <exec> $ set HGPLAIN=1 & hg status
<<< [2] <exec> 319,999 us

[2014-11-24 23:07:12] EXCEPTION: (Exception) Unparsable Mercurial status line '♀M Faxgate\Misc\LRE_CommandLine\Program.cs'. at [<arcanist>\src\repository\parser\ArcanistMercurialParser.php:37]
  #0 ArcanistMercurialParser::parseMercurialStatusDetails(string) called at [<arcanist>\src\repository\parser\ArcanistMercurialParser.php:98]
  #1 ArcanistMercurialParser::parseMercurialStatus(string) called at [<arcanist>\src\repository\api\ArcanistMercurialAPI.php:351]
  #2 ArcanistMercurialAPI::buildUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:138]
  #3 ArcanistRepositoryAPI::getUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:199]
  #4 ArcanistRepositoryAPI::getUncommittedPathsWithMask(integer) called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:150]
  #5 ArcanistRepositoryAPI::getUntrackedChanges() called at [<arcanist>\src\workflow\ArcanistWorkflow.php:805]
  #6 ArcanistWorkflow::requireCleanWorkingCopy() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:642]
  #7 ArcanistDiffWorkflow::runDiffSetupBasics() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:431]
  #8 ArcanistDiffWorkflow::run() called at [<arcanist>\scripts\arcanist.php:338]

C:\Users\TiTi\Desktop\OPI>php -v
PHP 5.6.3 (cli) (built: Nov 12 2014 17:17:51)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies

C:\Users\TiTi\Desktop\OPI>

Same issue without any working directory modification (nothing to commit) :

C:\Users\TiTi\Desktop\OPI>arc diff
[2014-11-24 23:25:11] ERROR 8: Uninitialized string offset: 1 at [C:\Users\TiTi\Documents\GitHub\arcanist\src\repository\parser\ArcanistMercurialParser.php:36]
  #0 ArcanistMercurialParser::parseMercurialStatusDetails(string) called at [<arcanist>\src\repository\parser\ArcanistMercurialParser.php:98]
  #1 ArcanistMercurialParser::parseMercurialStatus(string) called at [<arcanist>\src\repository\api\ArcanistMercurialAPI.php:351]
  #2 ArcanistMercurialAPI::buildUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:138]
  #3 ArcanistRepositoryAPI::getUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:199]
  #4 ArcanistRepositoryAPI::getUncommittedPathsWithMask(integer) called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:150]
  #5 ArcanistRepositoryAPI::getUntrackedChanges() called at [<arcanist>\src\workflow\ArcanistWorkflow.php:805]
  #6 ArcanistWorkflow::requireCleanWorkingCopy() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:642]
  #7 ArcanistDiffWorkflow::runDiffSetupBasics() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:431]
  #8 ArcanistDiffWorkflow::run() called at [<arcanist>\scripts\arcanist.php:338]
Exception
Unparsable Mercurial status line '♀'.
(Run with --trace for a full exception trace.)

C:\Users\TiTi\Desktop\OPI>

Event Timeline

TiTi raised the priority of this task from to Needs Triage.
TiTi updated the task description. (Show Details)
TiTi added a project: Arcanist.
TiTi added a subscriber: TiTi.

Same error on another computer, but this time with several incorrect chars ♀♀?

D:\Dev\TestSeleniumFlexibleForm>arc diff
Exception
Unparsable Mercurial status line '♀♀? .arcconfig'.
(Run with --trace for a full exception trace.)

D:\Dev\TestSeleniumFlexibleForm>arc diff --trace
libphutil loaded from 'D:\GitHub\libphutil\src'.
arcanist loaded from 'D:\GitHub\arcanist\src'.
Config: Reading user configuration file "C:\Users\rohmer\AppData\Roaming/.arcrc"...
Config: Did not find system configuration at "C:\ProgramData\Phabricator/Arcanist/config".
Working Copy: Reading .arcconfig from "D:\Dev\TestSeleniumFlexibleForm/.arcconfig".
Working Copy: Path "D:\Dev\TestSeleniumFlexibleForm" is part of `hg` working copy "D:\Dev\TestSeleniumFlexibleForm".
Working Copy: Project root is at "D:\Dev\TestSeleniumFlexibleForm".
Config: Did not find local configuration at "D:\Dev\TestSeleniumFlexibleForm\.hg\arc/config".
>>> [0] <conduit> conduit.connect() <bytes = 424>
>>> [1] <http> http://10.1.65.226/api/conduit.connect
<<< [1] <http> 549,713 us
<<< [0] <conduit> 549,713 us
>>> [2] <exec> $ set HGPLAIN=1 & hg status
<<< [2] <exec> 1,053,366 us

[2014-11-26 12:16:17] EXCEPTION: (Exception) Unparsable Mercurial status line '♀♀? .arcconfig'. at [<arcanist>\src\repository
\parser\ArcanistMercurialParser.php:37]
  #0 ArcanistMercurialParser::parseMercurialStatusDetails(string) called at [<arcanist>\src\repository\parser\ArcanistMercuri
alParser.php:98]
  #1 ArcanistMercurialParser::parseMercurialStatus(string) called at [<arcanist>\src\repository\api\ArcanistMercurialAPI.php:
351]
  #2 ArcanistMercurialAPI::buildUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:138]
  #3 ArcanistRepositoryAPI::getUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:199]
  #4 ArcanistRepositoryAPI::getUncommittedPathsWithMask(integer) called at [<arcanist>\src\repository\api\ArcanistRepositoryA
PI.php:150]
  #5 ArcanistRepositoryAPI::getUntrackedChanges() called at [<arcanist>\src\workflow\ArcanistWorkflow.php:805]
  #6 ArcanistWorkflow::requireCleanWorkingCopy() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:642]
  #7 ArcanistDiffWorkflow::runDiffSetupBasics() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:431]
  #8 ArcanistDiffWorkflow::run() called at [<arcanist>\scripts\arcanist.php:338]

D:\Dev\TestSeleniumFlexibleForm>hg status
? .arcconfig

<hg commit here>

D:\Dev\TestSeleniumFlexibleForm>hg status

D:\Dev\TestSeleniumFlexibleForm>arc diff
Exception
Unparsable Mercurial status line '♀♀'.
(Run with --trace for a full exception trace.)

D:\Dev\TestSeleniumFlexibleForm>hg status

D:\Dev\TestSeleniumFlexibleForm>arc diff --trace
libphutil loaded from 'D:\GitHub\libphutil\src'.
arcanist loaded from 'D:\GitHub\arcanist\src'.
Config: Reading user configuration file "C:\Users\rohmer\AppData\Roaming/.arcrc"...
Config: Did not find system configuration at "C:\ProgramData\Phabricator/Arcanist/config".
Working Copy: Reading .arcconfig from "D:\Dev\TestSeleniumFlexibleForm/.arcconfig".
Working Copy: Path "D:\Dev\TestSeleniumFlexibleForm" is part of `hg` working copy "D:\Dev\TestSeleniumFlexibleForm".
Working Copy: Project root is at "D:\Dev\TestSeleniumFlexibleForm".
Config: Did not find local configuration at "D:\Dev\TestSeleniumFlexibleForm\.hg\arc/config".
>>> [0] <conduit> conduit.connect() <bytes = 424>
>>> [1] <http> http://10.1.65.226/api/conduit.connect
<<< [1] <http> 1,098,426 us
<<< [0] <conduit> 1,104,434 us
>>> [2] <exec> $ set HGPLAIN=1 & hg status
<<< [2] <exec> 1,005,305 us

[2014-11-26 12:17:17] EXCEPTION: (Exception) Unparsable Mercurial status line '♀♀'. at [<arcanist>\src\repository\parser\Arca
nistMercurialParser.php:37]
  #0 ArcanistMercurialParser::parseMercurialStatusDetails(string) called at [<arcanist>\src\repository\parser\ArcanistMercuri
alParser.php:98]
  #1 ArcanistMercurialParser::parseMercurialStatus(string) called at [<arcanist>\src\repository\api\ArcanistMercurialAPI.php:
351]
  #2 ArcanistMercurialAPI::buildUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:138]
  #3 ArcanistRepositoryAPI::getUncommittedStatus() called at [<arcanist>\src\repository\api\ArcanistRepositoryAPI.php:199]
  #4 ArcanistRepositoryAPI::getUncommittedPathsWithMask(integer) called at [<arcanist>\src\repository\api\ArcanistRepositoryA
PI.php:150]
  #5 ArcanistRepositoryAPI::getUntrackedChanges() called at [<arcanist>\src\workflow\ArcanistWorkflow.php:805]
  #6 ArcanistWorkflow::requireCleanWorkingCopy() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:642]
  #7 ArcanistDiffWorkflow::runDiffSetupBasics() called at [<arcanist>\src\workflow\ArcanistDiffWorkflow.php:431]
  #8 ArcanistDiffWorkflow::run() called at [<arcanist>\scripts\arcanist.php:338]

D:\Dev\TestSeleniumFlexibleForm>

Tried with a third and clean windows : working nicely.

Haven't found the root cause yet. But there is hope :D
I'll try to remove things to figure this out.

Found the root cause!

I dug into ArcanistRepositoryAPI.php, ArcanistMercurialAPI.php all the way to ExecFuture.php which calls @proc_open
The following comment (a few lines before @proc_open) led me to the solution :

if (phutil_is_windows()) {
       // See T4395. proc_open under Windows uses "cmd /C [cmd]"

So another cmd is spawned to launch hg status. This was my clue.

On my computer, I have setted the Autorun registery key under:

HKEY_CURRENT_USER\Software\Microsoft\Command Processor\

Which is defined to a custom .bat
This key allows me to "autorun" my .bat each time a cmd.exe is opened.

Which is really nice to define aliases. This was the content of my file:

@DOSKEY o=DIR
CLS

Guest what: the CLS command was the culprit.
I removed it, now arc diff is working has expected.

I guess I'll have to live with thoses 2 lines again:

Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

Info on regedit key: http://ss64.com/nt/syntax-autoexec.html

Another example where this can cause real trouble, from a microsoft guru blog:
http://blogs.msdn.com/b/oldnewthing/archive/2007/11/21/6447771.aspx

TiTi triaged this task as Normal priority.