changeset 23350:e63941631a3f

merge with stable
author Matt Mackall <mpm@selenic.com>
date Tue, 18 Nov 2014 12:29:30 -0600
parents 7dd1870120b2 (current diff) 5ccced6eab0b (diff)
children 1cbc00ff2373
files tests/test-mq-header-date.t
diffstat 3 files changed, 25 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Sun Nov 16 22:03:57 2014 -0500
+++ b/hgext/mq.py	Tue Nov 18 12:29:30 2014 -0600
@@ -150,6 +150,12 @@
     lines.append(header + value)
     return lines
 
+def insertplainheader(lines, header, value):
+    if lines and lines[0] and ':' not in lines[0]:
+        lines.insert(0, '')
+    lines.insert(0, '%s: %s' % (header, value))
+    return lines
+
 class patchheader(object):
     def __init__(self, pf, plainmode=False):
         def eatdiff(lines):
@@ -260,7 +266,7 @@
                 inserthgheader(self.comments, '# User ', user)
             except ValueError:
                 if self.plainmode:
-                    self.comments = ['From: ' + user] + self.comments
+                    insertplainheader(self.comments, 'From', user)
                 else:
                     tmp = ['# HG changeset patch', '# User ' + user]
                     self.comments = tmp + self.comments
@@ -272,7 +278,7 @@
                 inserthgheader(self.comments, '# Date ', date)
             except ValueError:
                 if self.plainmode:
-                    self.comments = ['Date: ' + date] + self.comments
+                    insertplainheader(self.comments, 'Date', date)
                 else:
                     tmp = ['# HG changeset patch', '# Date ' + date]
                     self.comments = tmp + self.comments
@@ -293,7 +299,10 @@
         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.
--- a/tests/test-mq-header-date.t	Sun Nov 16 22:03:57 2014 -0500
+++ b/tests/test-mq-header-date.t	Tue Nov 18 12:29:30 2014 -0600
@@ -245,6 +245,7 @@
   now at: 1.patch
   ==== qnew -d -m
   Date: 6 0
+  
   Three
   
   1: Three - test - 6.00
@@ -252,6 +253,7 @@
   ==== qref
   adding 3
   Date: 6 0
+  
   Three
   
   diff -r ... 3
@@ -263,6 +265,7 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -m
   Date: 6 0
+  
   Drei
   
   diff -r ... 3
@@ -274,6 +277,7 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d
   Date: 7 0
+  
   Drei
   
   diff -r ... 3
@@ -285,6 +289,7 @@
   0: [mq]: 1.patch - test - 4.00
   ==== qref -d -m
   Date: 8 0
+  
   Three (again)
   
   diff -r ... 3
@@ -308,6 +313,7 @@
   0: [mq]: 1.patch - test
   ==== qref -d
   Date: 9 0
+  
   Four
   
   diff -r ... 4
@@ -491,6 +497,7 @@
   ==== qref -u -d
   Date: 15 0
   From: john
+  
   Nine
   
   diff -r ... 9
--- a/tests/test-mq-header-from.t	Sun Nov 16 22:03:57 2014 -0500
+++ b/tests/test-mq-header-from.t	Tue Nov 18 12:29:30 2014 -0600
@@ -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
@@ -245,6 +250,7 @@
   0: [mq]: 1.patch - mary
   ==== qref -u
   From: jane
+  
   Four
   
   diff -r ... 4of