[PATCH 2 of 3 stable] ui: allow open editor with custom filename
Mykola Nikishov
mn at mn.com.ua
Mon Nov 30 21:15:15 UTC 2015
# HG changeset patch
# User Mykola Nikishov <mn at mn.com.ua>
# Date 1448136249 -7200
# Sat Nov 21 22:04:09 2015 +0200
# Branch stable
# Node ID 77ef59533d3f8b491fff8cedd1f289f60a1dee89
# Parent 92357a5c8717783d82e9197cf8d095687243d22d
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 92357a5c8717 -r 77ef59533d3f mercurial/ui.py
--- a/mercurial/ui.py Tue Sep 22 16:56:34 2015 -0700
+++ b/mercurial/ui.py Sat Nov 21 22:04:09 2015 +0200
@@ -809,10 +809,12 @@
opts['label'] = opts.get('label', '') + ' ui.debug'
self.write(*msg, **opts)
def edit(self, text, user, extra=None, editform=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)
More information about the Mercurial-devel
mailing list