# HG changeset patch # User Mykola Nikishov # Date 1448136249 -7200 # Node ID 3553e40d077085b43cf5cddac1b9aa95e41445f0 # Parent ac27b1b3be857271af03f21e6d5e69611aa30a3a 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']. diff -r ac27b1b3be85 -r 3553e40d0770 mercurial/ui.py --- 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)