# HG changeset patch # User Jordi GutiƩrrez Hermoso # Date 2016-03-20 17:55:41 # Node ID 87f92d6f0bc358d64991292f461deed157f3168f # Parent 3ceac01bc29fe79458301296577b8a07445bd02d 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. diff --git a/mercurial/ui.py b/mercurial/ui.py --- a/mercurial/ui.py +++ b/mercurial/ui.py @@ -971,12 +971,15 @@ class ui(object): 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)