Mercurial > hg-stable
changeset 28635:87f92d6f0bc3
edit: allow to configure the suffix of the temporary filename
Sometimes, we can pick a more appropriate default suffix than ".txt",
for example, diffs could have a ".diff" suffix.
author | Jordi Gutiérrez Hermoso <jordigh@octave.org> |
---|---|
date | Sun, 20 Mar 2016 13:55:41 -0400 |
parents | 3ceac01bc29f |
children | de64020bb4ec |
files | mercurial/ui.py |
diffstat | 1 files changed, 5 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Sat Mar 19 18:37:10 2016 -0700 +++ b/mercurial/ui.py Sun Mar 20 13:55:41 2016 -0400 @@ -971,12 +971,15 @@ self.write(*msg, **opts) def edit(self, text, user, extra=None, editform=None, pending=None): - extra_defaults = { 'prefix': 'editor' } + extra_defaults = { + 'prefix': 'editor', + 'suffix': '.txt', + } if extra is not None: extra_defaults.update(extra) extra = extra_defaults (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', - suffix=".txt", text=True) + suffix=extra['suffix'], text=True) try: f = os.fdopen(fd, "w") f.write(text)