changeset 22547:3d616d27a422

mq: write headers of new patches using patchheader
author Mads Kiilerich <madski@unity3d.com>
date Sat, 20 Sep 2014 17:06:57 +0200
parents aac5482db318
children 8a1ae133770a
files hgext/mq.py
diffstat 1 files changed, 11 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Wed Sep 24 02:41:11 2014 +0200
+++ b/hgext/mq.py	Sat Sep 20 17:06:57 2014 +0200
@@ -1112,20 +1112,6 @@
                 raise util.Abort(_('cannot write patch "%s": %s')
                                  % (patchfn, e.strerror))
             try:
-                if self.plainmode:
-                    if user:
-                        p.write("From: " + user + "\n")
-                    if date:
-                        p.write("Date: %d %d\n" % date)
-                else:
-                    p.write("# HG changeset patch\n")
-                    if user:
-                        p.write("# User " + user + "\n")
-                    if date:
-                        p.write("# Date %s %s\n" % date)
-                    p.write("# Parent  "
-                            + hex(repo[None].p1().node()) + "\n")
-
                 defaultmsg = "[mq]: %s" % patchfn
                 editor = cmdutil.getcommiteditor(editform=editform)
                 if edit:
@@ -1154,11 +1140,17 @@
                     self.seriesdirty = True
                     self.applieddirty = True
                     nctx = repo[n]
-                    if nctx.description() != defaultmsg.rstrip():
-                        msg = nctx.description() + "\n\n"
-                        p.write(msg)
-                    elif not self.plainmode or date or user:
-                        p.write('\n')
+                    ph = patchheader(self.join(patchfn), self.plainmode)
+                    if user:
+                        ph.setuser(user)
+                    if date:
+                        ph.setdate('%s %s' % date)
+                    ph.setparent(hex(nctx.p1().node()))
+                    msg = nctx.description().strip()
+                    if msg == defaultmsg.strip():
+                        msg = ''
+                    ph.setmessage(msg)
+                    p.write(str(ph))
                     if commitfiles:
                         parent = self.qparents(repo, n)
                         if inclsubs: