hgext/mq.py
changeset 10150 926c436964b4
parent 10114 3e7663b2f3fc
child 10187 fcc15ba18c03
child 10188 fd6e9c7cd98c
--- a/hgext/mq.py	Tue Dec 29 16:00:24 2009 +0100
+++ b/hgext/mq.py	Tue Dec 29 16:00:29 2009 +0100
@@ -1159,15 +1159,6 @@
             cparents = repo.changelog.parents(top)
             patchparent = self.qparents(repo, top)
             ph = patchheader(self.join(patchfn))
-
-            patchf = self.opener(patchfn, 'r')
-
-            # if the patch was a git patch, refresh it as a git patch
-            for line in patchf:
-                if line.startswith('diff --git'):
-                    self.diffopts().git = True
-                    break
-
             if msg:
                 ph.setmessage(msg)
             if newuser:
@@ -1175,12 +1166,17 @@
             if newdate:
                 ph.setdate(newdate)
 
+            # if the patch was a git patch, refresh it as a git patch
+            patchf = self.opener(patchfn, 'r')
+            for line in patchf:
+                if line.startswith('diff --git'):
+                    self.diffopts().git = True
+                    break
+            patchf.close()
+
             # only commit new patch when write is complete
             patchf = self.opener(patchfn, 'w', atomictemp=True)
 
-            patchf.seek(0)
-            patchf.truncate()
-
             comments = str(ph)
             if comments:
                 patchf.write(comments)