Mercurial > hg-stable
changeset 27153:3553e40d0770
ui: allow open editor with custom filename
By default, editor will use temp file named after hard-coded pattern
'hg-editor-XXX.txt' which makes it impossible for extensions to use
another filename if desired.
Now the middle part of the pattern ('editor') can be changed by
setting extra['prefix'].
author | Mykola Nikishov <mn@mn.com.ua> |
---|---|
date | Sat, 21 Nov 2015 22:04:09 +0200 |
parents | ac27b1b3be85 |
children | 3bc7919fb215 |
files | mercurial/ui.py |
diffstat | 1 files changed, 6 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Mon Nov 30 20:45:07 2015 +0000 +++ b/mercurial/ui.py Sat Nov 21 22:04:09 2015 +0200 @@ -846,10 +846,12 @@ self.write(*msg, **opts) def edit(self, text, user, extra=None, editform=None, pending=None): - if extra is None: - extra = {} - (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt", - text=True) + extra_defaults = { 'prefix': 'editor' } + if extra is not None: + extra_defaults.update(extra) + extra = extra_defaults + (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', + suffix=".txt", text=True) try: f = os.fdopen(fd, "w") f.write(text)