Closed Bug 909937 Opened 11 years ago Closed 11 years ago

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

Categories

(Firefox Build System :: Mach Core, enhancement)

x86_64
Windows 8
enhancement
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED
mozilla27

People

(Reporter: emorley, Assigned: emorley)

References

Details

Attachments

(1 file)

$ 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
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 :-(
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.
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: nobody → emorley
Status: NEW → ASSIGNED
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
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla27
Product: Core → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: