changeset 22522:382c2be610dc

mq: simplify patchheader handling of the empty line before the diff Don't try to append empty lines to HG patch headers - instead, add them in str method. This minor change removes some apparently redundant code and makes the code more robust.
author Mads Kiilerich <madski@unity3d.com>
date Wed, 24 Sep 2014 01:39:25 +0200
parents 3f948469bac0
children 8cd91f481ffd
files hgext/mq.py
diffstat 1 files changed, 5 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Sep 24 01:36:44 2014 +0200
+++ b/hgext/mq.py	Wed Sep 24 01:39:25 2014 +0200
@@ -191,7 +191,6 @@
 
         # make sure message isn't empty
         if format and format.startswith("tag") and subject:
-            message.insert(0, "")
             message.insert(0, subject)
 
         self.message = message
@@ -214,7 +213,7 @@
                 if self.plainmode or self._hasheader(['Date: ']):
                     self.comments = ['From: ' + user] + self.comments
                 else:
-                    tmp = ['# HG changeset patch', '# User ' + user, '']
+                    tmp = ['# HG changeset patch', '# User ' + user]
                     self.comments = tmp + self.comments
         self.user = user
 
@@ -227,7 +226,7 @@
                 if self.plainmode or self._hasheader(['From: ']):
                     self.comments = ['Date: ' + date] + self.comments
                 else:
-                    tmp = ['# HG changeset patch', '# Date ' + date, '']
+                    tmp = ['# HG changeset patch', '# Date ' + date]
                     self.comments = tmp + self.comments
         self.date = date
 
@@ -268,9 +267,10 @@
         return False
 
     def __str__(self):
-        if not self.comments:
+        s = '\n'.join(self.comments).rstrip()
+        if not s:
             return ''
-        return '\n'.join(self.comments) + '\n\n'
+        return s + '\n\n'
 
     def _delmsg(self):
         '''Remove existing message, keeping the rest of the comments fields.