When lines in hgrc start with spaces, you get a parse error. This happens both for global hgrc and repo hgrc. Example hgrc (note the leading space): [ui] username=daniel
I don't think that's a bug (and the message is quite detailed).
This is the error message I get: hg: parse error at .../.hg/hgrc:1: [ui] I don't think people will notice the space as being the problem.
I guess we can wrap the erroneous line in ''...
Why should a line starting with whitespace result in an error? I don't understand that. I certainly was surprised when I realized that this really was the source of the error; I almost didn't try to remove the whitespace because I didn't expect this to be the problem. And its really easy to fix: just add a l = l.lstrip() to the parse method.
You can use leading white space for continuation, as in [foo] bar = this is a value with embedded newlines That might help to explain why the whitespace is significant.
OK, I understand that ;-) Then the error message should be much better, like "Unexpected leading whitespace", not just "parse error ..". There are many people unfamiliar with the exact syntax of the rc file, after all.
--- Bug imported by bugzilla@serpentine.com 2012-05-12 09:27 EDT --- This bug was previously known as _bug_ 3213 at http://mercurial.selenic.com/bts/issue3213
Bulk close: no activity for >2 years -> WONTFIX
Bulk change recent WONTFIX -> new, more descriptive ARCHIVED state (sorry for the spam)
Fixed by http://selenic.com/repo/hg/rev/b13b99d39a46 Razvan Cojocaru <razvan.cojocaru93@gmail.com> config: highlight parse error caused by leading spaces (issue3214) Added "unexpected leading whitespace" message to parse error when .hgrc has a line that starts with whitespace. Helps new users unfamiliar with syntax of rc file. (please test the fix)
Fixed by https://mercurial-scm.org/repo/hg/rev/0883413e09bc Martin von Zweigbergk <martinvonz@google.com> config: move message about leading spaces in config to config.py When the config parser raises a ParseError, it uses the line that failed to parse as the error message. It doesn't currently tell the user anything about why it failed to parse. b13b99d39a46 (config: highlight parse error caused by leading spaces (issue3214), 2014-03-16) added a checked based on the error *message* having leading spaces. That has worked fine because only the config parser uses the line itself as error message (I think the revset and fileset parsers use more user-friendly proper messages). It still feels like a hack. Let's make the config parser give a useful message about leading whitespace instead. We should ideally follow up with more useful messages for other parse errors in config files. Differential Revision: https://phab.mercurial-scm.org/D9241 (please test the fix)
Bug was set to TESTING for 8 days, resolving