Closed Bug 1185418 Opened 4 years ago Closed 3 years ago

%include directive is not supported by MercurialConfig

Categories

(Developer Services :: Mercurial: configwizard, defect)

x86_64
Linux
defect
Not set

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1277406

People

(Reporter: timdream, Unassigned)

References

Details

mercurial-setup is sad because there is an %include in my .hgrc


$ ./mach mercurial-setup
Error importing existing Mercurial config: /home/timdream/.hgrc

Line 24: %include directive is not supported by MercurialConfig
Flags: needinfo?(gps)
Duplicate of this bug: 1185561
This is a known problem, sadly. The config parser we're using doesn't support the %include directive because it is a Mercurial-specific extension to the ini file format.

Fortunately, failures in `mach mercurial-setup` unblock mach from complaining that you need to run `mach mercurial-setup`, so there is no infinite loop.

Out of curiosity, how are you using %include in your hgrc?
Component: Build Config → mach
Flags: needinfo?(gps)
(In reply to Gregory Szorc [:gps] from comment #2)
> Out of curiosity, how are you using %include in your hgrc?

I've given an answer to this in bug 1185561:

> I use them to modularize my
> mercurial configuration, separating common entries that I share between all
> my development environments from Mozilla-specific entries.
(In reply to Gregory Szorc [:gps] from comment #2)
> Out of curiosity, how are you using %include in your hgrc?

I am managing my .hgrc in a repo and it's shared between computers. There are some entries (e.g. Bugzilla cookieid for reviewboard) that can't be checked in, and some OS-specific entries that lives in ~/.rc/`uname -r`/hgrc, and some local specific configs.
Yeah, OK, that's a good use case.

We may have to reconsider our approach to how things are managed: it's doubtful our INI parser will ever be able to handle %include.
Can we use mercurial's parser?
We should probably be using the output of `hg config` to dump current config options so %include directives are honored.

Mercurial's parser does not support writing, at least not in a way that preserves formatting. We use configobj to parse and write hgrc files in `mach mercurial-setup` because it preserves comments and file order when writing things back out.
(In reply to Gregory Szorc [:gps] from comment #7)
> We should probably be using the output of `hg config`

Note sure what minimal version we support, but `hg config` was added in 3.0, so if we still support 2.x, `hg showconfig` is better.
This should have been addressed as part of rewriting the mercurial config wizard in bug 1277406.
Status: NEW → RESOLVED
Closed: 3 years ago
Component: mach → Mercurial: configwizard
Product: Core → Developer Services
Resolution: --- → DUPLICATE
Duplicate of bug: 1277406
You need to log in before you can comment on or make changes to this bug.