Patchwork [1,of,4,V2] edit: allow to configure the suffix of the temporary filename

login
register
mail settings
Submitter Jordi Gutiérrez Hermoso
Date March 21, 2016, 1:09 a.m.
Message ID <c5bd96cb2fabf014db93.1458522578@Iris>
Download mbox | patch
Permalink /patch/14001/
State Accepted
Headers show

Comments

Jordi Gutiérrez Hermoso - March 21, 2016, 1:09 a.m.
# HG changeset patch
# User Jordi Gutiérrez Hermoso <jordigh@octave.org>
# Date 1458496541 14400
#      Sun Mar 20 13:55:41 2016 -0400
# Node ID c5bd96cb2fabf014db931430d266627633117dfd
# Parent  dfd5a6830ea7cd56909b6667c78ae122cc3a5aa1
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.
Jordi Gutiérrez Hermoso - March 26, 2016, 9:33 p.m.
On Sun, 2016-03-20 at 21:09 -0400, Jordi Gutiérrez Hermoso wrote:
> # HG changeset patch
> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
> # Date 1458496541 14400
> #      Sun Mar 20 13:55:41 2016 -0400
> # Node ID c5bd96cb2fabf014db931430d266627633117dfd
> # Parent  dfd5a6830ea7cd56909b6667c78ae122cc3a5aa1
> edit: allow to configure the suffix of the temporary filename

Ping on this series. Ryan, I'm particularly interested in knowing if
you want the review operation enabled, since I re-enabled due to your
commit that completely removed the UI for it.
Pierre-Yves David - March 27, 2016, 7:27 p.m.
On 03/26/2016 02:33 PM, Jordi Gutiérrez Hermoso wrote:
> On Sun, 2016-03-20 at 21:09 -0400, Jordi Gutiérrez Hermoso wrote:
>> # HG changeset patch
>> # User Jordi Gutiérrez Hermoso <jordigh@octave.org>
>> # Date 1458496541 14400
>> #      Sun Mar 20 13:55:41 2016 -0400
>> # Node ID c5bd96cb2fabf014db931430d266627633117dfd
>> # Parent  dfd5a6830ea7cd56909b6667c78ae122cc3a5aa1
>> edit: allow to configure the suffix of the temporary filename
>
> Ping on this series. Ryan, I'm particularly interested in knowing if
> you want the review operation enabled, since I re-enabled due to your
> commit that completely removed the UI for it.

Given that this patches have been on the list for a week without anyone 
complaining about it and that it fixes a currently broken I've pushed it 
after review.

Thanks.

Patch

diff --git a/mercurial/ui.py b/mercurial/ui.py
--- a/mercurial/ui.py
+++ b/mercurial/ui.py
@@ -900,12 +900,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)