sapling/hgext
Michael Bolin 094c271fff editor: use an unambiguous path suffix for editor files
Changes the API of `ui.edit()` to take an optional `action` argument,
which is used when constructing the suffix of the temp file.
Previously, it was possible to set the suffix by specifying a `suffix` to the
optional `extra` dict that was passed to `ui.edit()`, but the goal is to
drop support for `extra.suffix` and make `action` a required argument.
To this end, `ui.edit()` now yields a `develwarn()` if `action` is not set
or if `extra.suffix` is set.

I updated all calls to `ui.edit()` I could find in `hg-crew` to specify the
appropriate `action`. This means that when creating a commit, instead
of the path to the editor file being something like:

`/tmp/hg-editor-XXXXXX.txt`

it is now something like:

`/tmp/hg-editor-XXXXXX.commit.hg.txt`

Some editors (such as Atom) make it possible to statically define a [TextMate]
grammar for files with a particular suffix. For example, because Git reliably
uses `.git/COMMIT_EDITMSG` and `.git/MERGE_MSG` as the paths for commit-type
messages, it is trivial to define a grammar that is applied when files of
either name are opened in Atom:

https://github.com/atom/language-git/blob/v0.19.1/grammars/git%20commit%20message.cson#L4-L5

Because Hg historically used a generic `.txt` suffix, it was much harder to
disambiguate whether a file was an arbitrary text file as opposed to one
created for the specific purpose of authoring an Hg commit message.

This also makes it easier to add special support for `histedit`, as it has its own
suffix that is distinct from a commit:

`/tmp/hg-histedit-XXXXXX.histedit.hg.txt`

Test Plan:
Added an integration test: `test-editor-filename.t`.

Manually tested: ran `hg ci --amend` for this change and saw that it
used `/tmp/hg-editor-ZZjcz0.commit.hg.txt` as the path instead of
`/tmp/hg-editor-ZZjcz0.txt` as the path.

Verified `make tests` passes.

Differential Revision: https://phab.mercurial-scm.org/D464
2017-08-30 20:25:56 +00:00
..
convert python3: wrap all uses of <exception>.strerror with strtolocal 2017-08-22 20:03:07 -04:00
fsmonitor fsmonitor: correct an error message 2017-08-10 09:37:50 -07:00
highlight highlight: put pygments import inside demandimport.deactivated 2017-06-18 23:05:54 -04:00
largefiles largefiles: fix help text to avoid warning at "make update-pot" 2017-08-02 01:15:07 +09:00
zeroconf zeroconf: blindly forward extra argument to the core config method 2017-07-01 21:57:17 +02:00
__init__.py hgext: officially turn 'hgext' into a namespace package 2016-02-27 12:56:26 +01:00
acl.py configitem: create a new list of each 'acl.sources' access 2017-07-02 23:10:33 +02:00
amend.py amend: new extension providing the amend command 2017-07-11 20:53:55 -07:00
automv.py configitems: register the 'automv.similarity' config 2017-06-30 03:27:24 +02:00
blackbox.py repovfs: add a ward to check if locks are properly taken 2017-07-11 12:38:17 +02:00
bugzilla.py bugzilla: move the default regexp for fix in the config declaration 2017-07-14 16:17:37 +02:00
censor.py revlog: rename constants (API) 2017-05-17 19:52:18 -07:00
children.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
churn.py churn: use the non-deprecated template option in the examples 2017-05-08 23:05:01 -04:00
clonebundles.py clonebundles: fix missing newline character 2017-05-24 22:59:59 -04:00
commitextras.py commitextras: make sure keys are not empty 2017-07-30 12:19:46 +05:30
eol.py eol: import 'error' as 'errormod' 2017-06-23 13:24:45 +02:00
extdiff.py cmdutil: rename template param to export to fntemplate 2017-05-20 20:15:05 -04:00
factotum.py configitems: register the 'factotum.service' config 2017-06-30 03:42:15 +02:00
fetch.py fetch: remove shorthand of --edit colliding against -e/-ssh in remoteopts (BC) 2017-06-24 02:39:13 +09:00
gpg.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
graphlog.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
hgk.py py3: introduce a wrapper for __builtins__.{raw_,}input() 2017-07-24 14:38:40 -04:00
histedit.py editor: use an unambiguous path suffix for editor files 2017-08-30 20:25:56 +00:00
journal.py journal: do not use atomictemp (issue5338) 2017-08-24 21:43:54 -07:00
keyword.py keyword: wrap functions only once at loading keyword extension 2017-06-26 03:47:11 +09:00
logtoprocess.py logtoprocess: use lowercase for docstring title 2017-03-23 21:16:55 -07:00
mq.py python3: wrap all uses of <exception>.strerror with strtolocal 2017-08-22 20:03:07 -04:00
notify.py configitems: register the 'notify.test' config 2017-06-30 03:43:31 +02:00
pager.py pager: if old pager extensions is enabled, respect pager.attend 2017-03-13 21:43:17 -07:00
patchbomb.py editor: use an unambiguous path suffix for editor files 2017-08-30 20:25:56 +00:00
purge.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
rebase.py rebase: use _ctxdesc in one more place 2017-08-29 17:51:54 -07:00
record.py commands: move templates of common command options to cmdutil (API) 2017-05-14 16:19:47 +09:00
releasenotes.py releasenotes: view admonition titles using -l flag 2017-08-28 04:11:58 +05:30
relink.py extensions: change magic "shipped with hg" string 2016-08-23 11:26:08 -04:00
schemes.py schemes: use br'' literal to define bytes regexp 2017-03-09 19:41:40 -08:00
share.py bookmark: deprecate 'recordchange' in favor of 'applychanges' 2017-07-10 20:10:03 +02:00
shelve.py dirstate: update backup functions to take full backup filename 2017-07-12 15:24:07 -07:00
show.py show: document why accidentally quadratic is (probably) acceptable 2017-07-03 21:26:39 -07:00
sparse.py sparse: treat paths as cwd-relative 2017-08-04 05:38:22 -07:00
strip.py bookmark: use 'applychanges' when stripping 2017-07-10 17:37:48 +02:00
transplant.py transplant: directly use repo.vfs.join 2017-03-08 16:52:49 -08:00
win32mbcs.py win32mbcs: avoid unintentional failure at colorization 2017-05-31 23:44:33 +09:00
win32text.py win32text: directly use repo.vfs.join 2017-03-08 16:52:57 -08:00