[PATCH RFC] ui: introduce sysdefault section for pager and editor configuration

Jun Wu quark at fb.com
Wed Mar 8 19:06:12 EST 2017


A "sysdefault" section sounds a bit weird. Usually files under "/etc" are
defining "system defaults". A new section also makes it harder to see what
configs they are overriding.

How about appending ":sysdefault" to normal configs? The idea was also
mentioned by Yuya at [1] and we use them in "[paths]":

  [ui]
  pager:sysdefault = sensible-pager
  editor:sysdefault = sensible-editor

This makes it easier to see what configs they are overriding, and makes the
section less crowded if we want the same thing for other sections.

[1]: https://patchwork.mercurial-scm.org/patch/16825/

Excerpts from Augie Fackler's message of 2017-03-08 18:48:55 -0500:
> # HG changeset patch
> # User Augie Fackler <augie at google.com>
> # Date 1489016567 18000
> #      Wed Mar 08 18:42:47 2017 -0500
> # Node ID 71fc64c48cfff1b7a2120c60e2b958da3263c0dc
> # Parent  92f7d6585c185e85763b3bad81b1304b8cdb5937
> ui: introduce sysdefault section for pager and editor configuration
> 
> The debian package currently has to patch Mercurial to move the
> default editor from `vi` to `sensible-editor`. Now that we're growing
> another suboptimal-on-most-platforms default program (`more` as the
> pager), let's do packagers a small favor and give them a place where
> they can specify the default program for their platform, rather than
> having to rely on patching code during the build process. I'd expect
> the configuration on OS X to be something like:
> 
> [sysdefault]
> editor = nano
> pager = LESS=FRX less
> 
> and on debian to be:
> 
> [sysdefault]
> editor = sensible-editor
> pager = sensible-pager
> 
> diff --git a/mercurial/ui.py b/mercurial/ui.py
> --- a/mercurial/ui.py
> +++ b/mercurial/ui.py
> @@ -907,13 +907,11 @@ class ui(object):
>              # HGPLAINEXCEPT=pager, and the user didn't specify --debug.
>              return
>  
> -        # TODO: add a "system defaults" config section so this default
> -        # of more(1) can be easily replaced with a global
> -        # configuration file. For example, on OS X the sane default is
> -        # less(1), not more(1), and on debian it's
> -        # sensible-pager(1). We should probably also give the system
> -        # default editor command similar treatment.
> -        envpager = encoding.environ.get('PAGER', 'more')
> +        # sysdefault.pager is available for packagers or system
> +        # administrators to specify a saner default pager for their
> +        # environment.
> +        defaultpager = self.config('sysdefault', 'pager', default='more')
> +        envpager = encoding.environ.get('PAGER', defaultpager)
>          pagercmd = self.config('pager', 'pager', envpager)
>          if not pagercmd:
>              return
> @@ -1348,6 +1346,10 @@ class ui(object):
>              editor = 'E'
>          else:
>              editor = 'vi'
> +        # sysdefault.editor is available for packagers or system
> +        # administrators to specify a saner default editor for their
> +        # environment.
> +        editor = self.config("sysdefault", "editor", default=editor)
>          return (encoding.environ.get("HGEDITOR") or
>                  self.config("ui", "editor") or
>                  encoding.environ.get("VISUAL") or


More information about the Mercurial-devel mailing list