cli config only adding not yet defined values?

Arne Babenhauserheide arne_bab at web.de
Fri Oct 19 14:05:43 CDT 2012


Hi,

A few years ago I asked about the possibility to have a config editor
on the commandline. In the discussion it became clear, that this could
have severe sideeffects, so the full featured config-command should
not be added to core.

So I would like to ask, if a config command which is restricted to a
safe set of operations would be acceptable.

Explicitely those operations would be:

* adding values which are not yet defined
* opening the config file in an editor


For the command this would mean, that it would have the following options:


$ hg config # in a repo
(editor pops up with the .hg/hgrc)

$ hg config # not in a repo
Error: Config without options must be used in a repo. Use --user or
--system.

$ hg config --user
(editor pops up with the users hgrc file)

$ hg config --system
(editor pops up with the systemwide hgrc)

$ hg config --define ui.username "user <user at bla>" # not yet defined
(.hg/hgrc gets appended \n[ui]\nusername = user <user at bla>)

$ hg config --define ui.username "user <user at bla>" # already defined
Error: ui.username exists in .hg/hgrc. Use hg config to edit manually

$ hg config ui.username
user <user at bla>

same for user and system, with one special case:

$ hg config --system --define ui.username "user <user at bla>" # no write access
Error: You do not have write access to {systemwide rc file}.


@matt: Would you accept such a command into core (after enough testing)?


The reason for my question is that this would remove the *major*
stumbling block of having to find the hgrc file and add the username
for every new installation - and especially for every new user.

Also it would ease paths handling a lot:

$ hg config --define paths.alice http://hg.alice.net

And activating extensions would be much quicker, too:

$ hg config --define --user extensions.record


Best wishes,
Arne

PS: I used --define instead of --set to avoid a short parameter clash with --system:

$ hg config -sd ui.username "user <user at bla>"

An alternative would be to use --global for systemwide settings and
--set to define a setting. I am undecided between the two...


More information about the Mercurial-devel mailing list