changeset 22545:6a2cfa61acb0

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.
author Mads Kiilerich <madski@unity3d.com>
date Sat, 20 Sep 2014 17:06:57 +0200
parents 0d75ce895adc
children aac5482db318
files hgext/mq.py tests/test-mq-eol.t tests/test-mq-qpush-fail.t
diffstat 3 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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