hgext/mq.py
changeset 21235 51069bf6366b
parent 21234 b9a16ed5acec
child 21236 49148d7868df
--- a/hgext/mq.py	Mon May 05 21:26:40 2014 +0900
+++ b/hgext/mq.py	Mon May 05 21:26:40 2014 +0900
@@ -1508,8 +1508,6 @@
 
             ph = patchheader(self.join(patchfn), self.plainmode)
             diffopts = self.diffopts({'git': opts.get('git')}, patchfn)
-            if msg:
-                ph.setmessage(msg)
             if newuser:
                 ph.setuser(newuser)
             if newdate:
@@ -1519,10 +1517,6 @@
             # only commit new patch when write is complete
             patchf = self.opener(patchfn, 'w', atomictemp=True)
 
-            comments = str(ph)
-            if comments:
-                patchf.write(comments)
-
             # update the dirstate in place, strip off the qtip commit
             # and then commit.
             #
@@ -1642,14 +1636,6 @@
                 for f in forget:
                     repo.dirstate.drop(f)
 
-                if not msg:
-                    if not ph.message:
-                        message = "[mq]: %s\n" % patchfn
-                    else:
-                        message = "\n".join(ph.message)
-                else:
-                    message = msg
-
                 user = ph.user or changes[1]
 
                 oldphase = repo[top].phase()
@@ -1666,6 +1652,15 @@
             try:
                 # might be nice to attempt to roll back strip after this
 
+                if not msg:
+                    if not ph.message:
+                        message = "[mq]: %s\n" % patchfn
+                    else:
+                        message = "\n".join(ph.message)
+                else:
+                    message = msg
+                    ph.setmessage(msg)
+
                 # Ensure we create a new changeset in the same phase than
                 # the old one.
                 n = newcommit(repo, oldphase, message, user, ph.date,
@@ -1676,6 +1671,9 @@
                     self.putsubstate2changes(substatestate, c)
                 chunks = patchmod.diff(repo, patchparent,
                                        changes=c, opts=diffopts)
+                comments = str(ph)
+                if comments:
+                    patchf.write(comments)
                 for chunk in chunks:
                     patchf.write(chunk)
                 patchf.close()