[PATCH 2 of 3 stable] mq: introduce insertplainheader - same naive implementation as before

Mads Kiilerich mads at kiilerich.com
Mon Nov 17 00:52:30 UTC 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1416185299 -3600
#      Mon Nov 17 01:48:19 2014 +0100
# Branch stable
# Node ID f8909f21ae9f3589cc60ab4f2629a446df921c31
# Parent  69da71d3e1f73391492f90b36cf6ea855af184bf
mq: introduce insertplainheader - same naive implementation as before

diff --git a/hgext/mq.py b/hgext/mq.py
--- a/hgext/mq.py
+++ b/hgext/mq.py
@@ -150,6 +150,10 @@ def inserthgheader(lines, header, value)
     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 @@ class patchheader(object):
                 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 @@ class patchheader(object):
                 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



More information about the Mercurial-devel mailing list