Closed Bug 1758777 Opened 2 years ago Closed 2 years ago

Nano is preferred over Mercurial's ui.editor setting because of HGEDITOR

Categories

(Firefox Build System :: MozillaBuild, task)

task

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: bryce, Assigned: mhentges)

References

Details

Attachments

(2 files)

I'm still getting nano as my Mercurial editor despite my mercurial.ini config specifying vim because the HGEDITOR env var is set to nano in the v4 prerelease.

STR:

  • Install the mozillabuild v4 prerelease.
  • Start a shell via the provided start-shell.bat
  • Run hg config -e and set editor = vim in the [ui] section.
  • Run hg config -e again (or another hg command).

Actual result:
The editor opened is nano.

Expected result:
The editor opened in vim.

Further info:

  • I can get vim selected by unsetting the HGEDITOR env var.
  • I think this is caused by this line and because HGEDITOR has high precedence than the config file.

Ah, thanks for the report, that aligns with the mercurial docs.
I'll shuffle it over to our packaged mercurial.ini file instead.

Assignee: nobody → mhentges

As documented in the mercurial docs [1], $HGEDITOR overrides the
user's mercurial.ini config. Since MozillaBuild's editor configuration
is supposed to be a convenient //fallback// setting, we should lean on
the "system" mercurial.ini config file instead, since it's more
override-able.

Unfortunately, though un-documented, $EDITOR overrides the system
ui.config setting. So, we have two options:

  1. Move the 72-char-limit nano config to $EDITOR: this is incorrect
    since $EDITOR may be used in non-VCS-commit contexts.
  2. Unset $EDITOR: this isn't ideal because we don't have any other
    mechanism for providing system-default git options.

Out of these options, option 1 seems more acceptable to avoid unexpected
behaviour in the future. Besides, using git in MozillaBuild is already
edge-case-y, so hopefully users opting in to it will also be comfortable
with setting their editor.

[1] https://www.mercurial-scm.org/wiki/editor

Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/mozilla-build/rev/f1f40d18531d
Move hg config to system mercurial.ini instead of env var r=ahochheiden

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED

When writing D140737, I missed a third option that gives us the best of
both worlds:

  • git should use nano.exe by default, but will honour user
    configuration
  • hg should use nano.exe with our custom configuration (-b -r 72)

The only way to influence git in an overridable way was via $EDITOR,
which would override our only mechanism for configuring hg.
However, if we set $EDITOR, but //unset it only when using hg//,
then everybody wins :)

Blocks: 1739443
Pushed by mhentges@mozilla.com:
https://hg.mozilla.org/mozilla-build/rev/2c7ad1ac65be
Workaround so Git uses "nano", retaining hg editor config r=ahochheiden
Product: mozilla.org → Firefox Build System
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: