mach mercurial-setup fails with "ConfigObjError: Parsing failed with several errors."

RESOLVED FIXED in mozilla27

Status

Firefox Build System
Mach Core
RESOLVED FIXED
5 years ago
3 months ago

People

(Reporter: emorley, Assigned: emorley)

Tracking

Trunk
mozilla27
x86_64
Windows 8

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(1 attachment)

(Assignee)

Description

5 years ago
$ mach mercurial-setup
Error running mach:

    ['mercurial-setup']

The error occurred in code that was called by the mach command. This is either
a bug in the called code itself or in the way that mach is calling it.

You should consider filing a bug for this issue.

If filing a bug, please include the full output of mach, including this error
message.

The details of the failure are as follows:

ConfigObjError: Parsing failed with several errors.
First error at line 3.

  File "c:\src-gecko\mozilla-central\tools/mercurial/mach_commands.py", line 29, in mercurial_bootstrap
    result = wizard.run(os.path.expanduser('~/.hgrc'))
  File "c:\src-gecko\mozilla-central\tools/mercurial\hgsetup\wizard.py", line 102, in run
    c = MercurialConfig(config_path)
  File "c:\src-gecko\mozilla-central\tools/mercurial\hgsetup\config.py", line 25, in __init__
    write_empty_values=True, list_values=False)
  File "c:\src-gecko\mozilla-central\python/configobj\configobj.py", line 1242, in __init__
    self._load(infile, configspec)
  File "c:\src-gecko\mozilla-central\python/configobj\configobj.py", line 1332, in _load
    raise error


$ head ~/mercurial.ini
[ui]
username = Ed Morley <emorley@mozilla-foo.com>
ssh = "C:\Program Files\TortoiseHg\tortoiseplink.exe" -l emorley@mozilla-foo.com -i C:\Users\Ed\.ssh\putty-rsa.ppk -C
merge = diffmerge3
editor = "C:\Program Files (x86)\Notepad++\notepad++.exe" -multiInst
slash = True

[diff]
git = True
showfunc = True
(Assignee)

Comment 1

5 years ago
If I remove the quotes on line 3 (the |ssh=| line), it doesn't fail on that line (same for line 5).

The spec used by configobj (http://www.voidspace.org.uk/python/configobj.html#the-config-file-format) doesn't match what it actually permitted by Mercurial :-(

Comment 2

5 years ago
Unfortunately we can't use the Mercurial API for reading config files because:

1) The Mercurial Python API isn't always available on machines. I mean it is there, but doing an |import mercurial.foo| isn't always reliable.
2) The API doesn't support writing values.
3) The Python code is GPL and this would make the mach command and possible the mach core be GPL. This is highly undesirable.

I think we'll need to trap parsing failures in the setup wizard and exit gracefully. Hopefully we can print a list of suggestions for making parsing work.

Best effort is sadly the best we can do.
(Assignee)

Comment 3

5 years ago
Created attachment 810240 [details] [diff] [review]
Output more useful error messages for parsing exceptions

eg:

[/c/src-gecko/inbound]$ mach mercurial-setup
Error importing existing mercurial config!
Parse error in value at line 5.
If using quotes, they must wrap the entire string.
Attachment #810240 - Flags: review?(gps)
(Assignee)

Updated

5 years ago
Assignee: nobody → emorley
Status: NEW → ASSIGNED

Comment 4

5 years ago
Comment on attachment 810240 [details] [diff] [review]
Output more useful error messages for parsing exceptions

Review of attachment 810240 [details] [diff] [review]:
-----------------------------------------------------------------

\o/
Attachment #810240 - Flags: review?(gps) → review+
https://hg.mozilla.org/mozilla-central/rev/37266243cead
Status: ASSIGNED → RESOLVED
Last Resolved: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27

Updated

3 months ago
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.