mq: upgrade non-plain patches to HG format when setting parent in patchheader
authorMads Kiilerich <madski@unity3d.com>
Sat, 20 Sep 2014 17:06:57 +0200
changeset 22545 6a2cfa61acb0
parent 22544 0d75ce895adc
child 22546 aac5482db318
mq: upgrade non-plain patches to HG format when setting parent in patchheader Parent will now always be updated or added when qrefreshing HG patches. Plain patches will not be changed, but patches that neither are plain nor HG will be upgraded to HG patches on first refresh.
hgext/mq.py
tests/test-mq-eol.t
tests/test-mq-qpush-fail.t
--- a/hgext/mq.py	Sat Sep 20 17:06:56 2014 +0200
+++ b/hgext/mq.py	Sat Sep 20 17:06:57 2014 +0200
@@ -241,7 +241,9 @@
                 patchheaderat = self.comments.index('# HG changeset patch')
                 self.comments.insert(patchheaderat + 1, '# Parent  ' + parent)
             except ValueError:
-                pass
+                if not self.plainmode:
+                    tmp = ['# HG changeset patch', '# Parent  ' + parent]
+                    self.comments = tmp + self.comments
         self.parent = parent
 
     def setmessage(self, message):
--- a/tests/test-mq-eol.t	Sat Sep 20 17:06:56 2014 +0200
+++ b/tests/test-mq-eol.t	Sat Sep 20 17:06:57 2014 +0200
@@ -84,6 +84,8 @@
   now at: eol.diff
   $ hg qrefresh
   $ python ../cateol.py .hg/patches/eol.diff
+  # HG changeset patch<LF>
+  # Parent  0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0<LF>
   test message<LF>
   <LF>
   diff -r 0d0bf99a8b7a a<LF>
--- a/tests/test-mq-qpush-fail.t	Sat Sep 20 17:06:56 2014 +0200
+++ b/tests/test-mq-qpush-fail.t	Sat Sep 20 17:06:57 2014 +0200
@@ -23,7 +23,7 @@
   $ echo bar > bar
   $ hg add bar
   $ hg qrefresh -m 'patch 2'
-  $ hg qnew --config 'mq.plain=true' bad-patch
+  $ hg qnew --config 'mq.plain=true' -U bad-patch
   $ echo >> foo
   $ hg qrefresh
   $ hg qpop -a