From patchwork Wed Sep 24 01:00:07 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [6, of, 8] mq: upgrade non-plain patches to HG format when setting parent in patchheader From: Mads Kiilerich X-Patchwork-Id: 5953 Message-Id: To: mercurial-devel@selenic.com Date: Wed, 24 Sep 2014 03:00:07 +0200 # HG changeset patch # User Mads Kiilerich # Date 1411225617 -7200 # Sat Sep 20 17:06:57 2014 +0200 # Node ID fd737e3bd2f55ef70f7c82914da1d1fb001c9936 # Parent 39cc9d328c6e61f631ae4f96b5bb0702f3145d39 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. diff --git a/hgext/mq.py b/hgext/mq.py --- a/hgext/mq.py +++ b/hgext/mq.py @@ -241,7 +241,9 @@ class patchheader(object): 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): diff --git a/tests/test-mq-eol.t b/tests/test-mq-eol.t --- a/tests/test-mq-eol.t +++ b/tests/test-mq-eol.t @@ -84,6 +84,8 @@ force LF now at: eol.diff $ hg qrefresh $ python ../cateol.py .hg/patches/eol.diff + # HG changeset patch + # Parent 0d0bf99a8b7a3842c6f8ef09e34f69156c4bd9d0 test message diff -r 0d0bf99a8b7a a diff --git a/tests/test-mq-qpush-fail.t b/tests/test-mq-qpush-fail.t --- a/tests/test-mq-qpush-fail.t +++ b/tests/test-mq-qpush-fail.t @@ -23,7 +23,7 @@ test qpush on empty series $ 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