mq: introduce insertplainheader - same naive implementation as before stable
authorMads Kiilerich <madski@unity3d.com>
Mon, 17 Nov 2014 01:48:19 +0100
branchstable
changeset 23345 83cbf556babf
parent 23344 6333412245ec
child 23346 5ccced6eab0b
mq: introduce insertplainheader - same naive implementation as before
hgext/mq.py
--- a/hgext/mq.py	Sun Nov 16 19:57:40 2014 +0100
+++ b/hgext/mq.py	Mon Nov 17 01:48:19 2014 +0100
@@ -150,6 +150,10 @@
     lines.append(header + value)
     return lines
 
+def insertplainheader(lines, header, value):
+    lines.insert(0, '%s: %s' % (header, value))
+    return lines
+
 class patchheader(object):
     def __init__(self, pf, plainmode=False):
         def eatdiff(lines):
@@ -260,7 +264,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 +276,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