Patchwork [1,of,3,stable] mq: when setting message in plain mode, separate it from header (issue4453)

login
register
mail settings
Submitter Mads Kiilerich
Date Nov. 17, 2014, 12:52 a.m.
Message ID <69da71d3e1f73391492f.1416185549@localhost.localdomain>
Download mbox | patch
Permalink /patch/6764/
State Accepted
Commit 6333412245ec7d4eafc928d933ca7a03884b918c
Headers show

Comments

Mads Kiilerich - Nov. 17, 2014, 12:52 a.m.
# HG changeset patch
# User Mads Kiilerich <madski@unity3d.com>
# Date 1416164260 -3600
#      Sun Nov 16 19:57:40 2014 +0100
# Branch stable
# Node ID 69da71d3e1f73391492f90b36cf6ea855af184bf
# Parent  3246801ff3135322544f804c2b081f4da2e39646
mq: when setting message in plain mode, separate it from header (issue4453)

Fix inconsistant handling plain header separation in mq patcheader - and
contrary to c87f2a5a6e49, do it in the direction of having an empty line
between header and description. Plain patches are like mails and should thus
have an empty line between headers and body in compliance with RFC 822 3.1.

Patch

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -293,7 +293,10 @@  class patchheader(object):
         if self.comments:
             self._delmsg()
         self.message = [message]
-        self.comments += self.message
+        if message:
+            if self.plainmode and self.comments and self.comments[-1]:
+                self.comments.append('')
+            self.comments.append(message)
 
     def updateheader(self, prefixes, new):
         '''Update all references to a field in the patch header.
diff --git a/tests/test-mq-header-date.t b/tests/test-mq-header-date.t
--- a/tests/test-mq-header-date.t
+++ b/tests/test-mq-header-date.t
@@ -243,6 +243,7 @@ 
   now at: 1.patch
   ==== qnew -d -m
   Date: 6 0
+  
   Three
   
   1: Three - test - 6.00
@@ -250,6 +251,7 @@ 
   ==== qref
   adding 3
   Date: 6 0
+  
   Three
   
   diff -r ... 3
@@ -261,6 +263,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -m
   Date: 6 0
+  
   Drei
   
   diff -r ... 3
@@ -272,6 +275,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d
   Date: 7 0
+  
   Drei
   
   diff -r ... 3
@@ -283,6 +287,7 @@ 
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   Date: 8 0
+  
   Three (again)
   
   diff -r ... 3
diff --git a/tests/test-mq-header-from.t b/tests/test-mq-header-from.t
--- a/tests/test-mq-header-from.t
+++ b/tests/test-mq-header-from.t
@@ -176,6 +176,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qnew -U -m
   From: test
+  
   Three
   
   2: Three - test
@@ -184,6 +185,7 @@ 
   ==== qref
   adding 3
   From: test
+  
   Three
   
   diff -r ... 3
@@ -196,6 +198,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -m
   From: test
+  
   Drei
   
   diff -r ... 3
@@ -208,6 +211,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u
   From: mary
+  
   Drei
   
   diff -r ... 3
@@ -220,6 +224,7 @@ 
   0: [mq]: 1.patch - mary
   ==== qref -u -m
   From: maria
+  
   Three (again)
   
   diff -r ... 3