changeset 34054:3c82b14d2838

editor: file created for diff action should have .diff suffix This is a follow-up to https://phab.mercurial-scm.org/D464 (6e6452bc441d) that introduced the new file extension behavior. It erroneously changed `.diff` to `.diff.hg.txt`. Test Plan: Verified `make tests` passes, particularly `test-editor-filename.t`. Differential Revision: https://phab.mercurial-scm.org/D607
author Michael Bolin <mbolin@fb.com>
date Fri, 01 Sep 2017 20:28:26 +0000
parents 24ce7b0edaf9
children ae92e5c0441c
files mercurial/ui.py tests/test-editor-filename.t
diffstat 2 files changed, 31 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/ui.py	Fri Sep 01 11:13:55 2017 -0700
+++ b/mercurial/ui.py	Fri Sep 01 20:28:26 2017 +0000
@@ -1361,7 +1361,9 @@
             extra_defaults.update(extra)
         extra = extra_defaults
 
-        if action:
+        if action == 'diff':
+            suffix = '.diff'
+        elif action:
             suffix = '.%s.hg.txt' % action
         else:
             suffix = extra['suffix']
--- a/tests/test-editor-filename.t	Fri Sep 01 11:13:55 2017 -0700
+++ b/tests/test-editor-filename.t	Fri Sep 01 20:28:26 2017 +0000
@@ -33,3 +33,31 @@
   *.histedit.hg.txt (glob)
   abort: edit failed: editor.sh exited with status 1
   [255]
+
+Verify that when performing an action that has the side-effect of creating an
+editor for a diff, the file ends in .diff.
+
+  $ echo 1 > one
+  $ echo 2 > two
+  $ hg add
+  adding one
+  adding two
+  $ hg commit --interactive --config ui.interactive=true --config ui.interface=text << EOF
+  > y
+  > e
+  > q
+  > EOF
+  diff --git a/one b/one
+  new file mode 100644
+  examine changes to 'one'? [Ynesfdaq?] y
+  
+  @@ -0,0 +1,1 @@
+  +1
+  record change 1/2 to 'one'? [Ynesfdaq?] e
+  
+  *.diff (glob)
+  editor exited with exit code 1
+  record change 1/2 to 'one'? [Ynesfdaq?] q
+  
+  abort: user quit
+  [255]