# HG changeset patch # User David Soria Parra # Date 1248788188 -7200 # Node ID 53fdf18fd63b2318535e6a3aac95da0f8b823b6a # Parent 4a1b24dbf753ae7aa254f9ed7b8ac278fd91d4ad mq: Parse commit message after we find start of changeset patch patch.extract extracts just the message below HG changeset patch. So to not parse comments above the patch, we reset the message if we find a changeset patch as we know the commit message comes after the changeset patch data. This is similar to the behavior of patch.extract. The drawback of this approach, after a qref -e the comment above HG changeset patch is gone. Without this patch the message would become part of the commit message in the HG changset patch part. diff -r 4a1b24dbf753 -r 53fdf18fd63b hgext/mq.py --- a/hgext/mq.py Wed Jul 29 22:14:46 2009 +0200 +++ b/hgext/mq.py Tue Jul 28 15:36:28 2009 +0200 @@ -105,6 +105,7 @@ message.append(line) format = None elif line == '# HG changeset patch': + message = [] format = "hgpatch" elif (format != "tagdone" and (line.startswith("Subject: ") or line.startswith("subject: "))): diff -r 4a1b24dbf753 -r 53fdf18fd63b tests/test-mq-qimport --- a/tests/test-mq-qimport Wed Jul 29 22:14:46 2009 +0200 +++ b/tests/test-mq-qimport Tue Jul 28 15:36:28 2009 +0200 @@ -27,6 +27,38 @@ echo % qimport non-existing-file hg qimport non-existing-file +echo % import email +hg qimport --push -n email - < +Subject: [PATCH] Message in email +Date: Fri, 02 Jan 1970 00:00:00 +0000 + +Text before patch. + +# HG changeset patch +# User Username in patch +# Date 0 0 +# Node ID 1a706973a7d84cb549823634a821d9bdf21c6220 +# Parent 0000000000000000000000000000000000000000 +First line of commit message. + +More text in commit message. + +diff --git a/x b/x +new file mode 100644 +--- /dev/null ++++ b/x +@@ -0,0 +1,1 @@ ++new file +Text after patch. + +EOF + +echo % hg tip -v +hg tip -v +hg qpop +hg qdelete email + echo % import URL echo foo >> foo hg add foo diff -r 4a1b24dbf753 -r 53fdf18fd63b tests/test-mq-qimport.out --- a/tests/test-mq-qimport.out Wed Jul 29 22:14:46 2009 +0200 +++ b/tests/test-mq-qimport.out Tue Jul 28 15:36:28 2009 +0200 @@ -1,5 +1,25 @@ % qimport non-existing-file abort: unable to read non-existing-file +% import email +adding email to series file +applying email +now at: email +% hg tip -v +changeset: 0:1a706973a7d8 +tag: qtip +tag: tip +tag: email +tag: qbase +user: Username in patch +date: Thu Jan 01 00:00:00 1970 +0000 +files: x +description: +First line of commit message. + +More text in commit message. + + +patch queue now empty % import URL adding url.diff to series file url.diff