--- a/hgext/patchbomb.py Wed Nov 12 19:12:32 2008 +0100
+++ b/hgext/patchbomb.py Thu Nov 13 10:11:32 2008 +0100
@@ -172,7 +172,7 @@
msg = mail.mimetextpatch(body, display=opts.get('test'))
subj = desc[0].strip().rstrip('. ')
- if total == 1:
+ if total == 1 and not opts.get('intro'):
subj = '[PATCH] ' + (opts.get('subject') or subj)
else:
tlen = len(str(total))
@@ -316,7 +316,7 @@
len(patches), name)
msgs.append(msg)
- if len(patches) > 1:
+ if len(patches) > 1 or opts.get('intro'):
tlen = len(str(len(patches)))
subj = '[PATCH %0*d of %d] %s' % (
@@ -481,6 +481,8 @@
_('run even when remote repository is unrelated (with -b)')),
('', 'base', [],
_('a base changeset to specify instead of a destination (with -b)')),
+ ('', 'intro', None,
+ _('send an introduction email for a single patch')),
] + emailopts + commands.remoteopts,
_('hg email [OPTION]... [DEST]...'))
}
--- a/tests/test-patchbomb Wed Nov 12 19:12:32 2008 +0100
+++ b/tests/test-patchbomb Thu Nov 13 10:11:32 2008 +0100
@@ -93,6 +93,14 @@
hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar -s test -a 0:1 | \
fixheaders
+echo "% test intro for single patch"
+hg email --date '1970-1-1 0:1' -n --intro -f quux -t foo -c bar -s test 2 | \
+ fixheaders
+
+echo "% test intro for multiple patches"
+hg email --date '1970-1-1 0:1' -n --intro -f quux -t foo -c bar -s test 0:1 | \
+ fixheaders
+
echo "% tagging csets"
hg tag -r0 zero zero.foo
hg tag -r1 one one.patch
--- a/tests/test-patchbomb.out Wed Nov 12 19:12:32 2008 +0100
+++ b/tests/test-patchbomb.out Thu Nov 13 10:11:32 2008 +0100
@@ -579,6 +579,122 @@
+b
--===
+% test intro for single patch
+This patch series consists of 1 patches.
+
+
+Write the introductory message for the patch series.
+
+
+Displaying [PATCH 0 of 1] test ...
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 0 of 1] test
+Message-Id: <patchbomb.60@
+Date: Thu, 01 Jan 1970 00:01:00 +0000
+From: quux
+To: foo
+Cc: bar
+
+
+Displaying [PATCH 1 of 1] c ...
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 1 of 1] c
+X-Mercurial-Node: ff2c9fa2018b15fa74b33363bda9527323e2a99f
+Message-Id: <ff2c9fa2018b15fa74b3.61@
+In-Reply-To: <patchbomb.60@
+Date: Thu, 01 Jan 1970 00:01:01 +0000
+From: quux
+To: foo
+Cc: bar
+
+# HG changeset patch
+# User test
+# Date 3 0
+# Node ID ff2c9fa2018b15fa74b33363bda9527323e2a99f
+# Parent 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+c
+
+diff -r 97d72e5f12c7 -r ff2c9fa2018b c
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/c Thu Jan 01 00:00:03 1970 +0000
+@@ -0,0 +1,1 @@
++c
+
+% test intro for multiple patches
+This patch series consists of 2 patches.
+
+
+Write the introductory message for the patch series.
+
+
+Displaying [PATCH 0 of 2] test ...
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 0 of 2] test
+Message-Id: <patchbomb.60@
+Date: Thu, 01 Jan 1970 00:01:00 +0000
+From: quux
+To: foo
+Cc: bar
+
+
+Displaying [PATCH 1 of 2] a ...
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 1 of 2] a
+X-Mercurial-Node: 8580ff50825a50c8f716709acdf8de0deddcd6ab
+Message-Id: <8580ff50825a50c8f716.61@
+In-Reply-To: <patchbomb.60@
+Date: Thu, 01 Jan 1970 00:01:01 +0000
+From: quux
+To: foo
+Cc: bar
+
+# HG changeset patch
+# User test
+# Date 1 0
+# Node ID 8580ff50825a50c8f716709acdf8de0deddcd6ab
+# Parent 0000000000000000000000000000000000000000
+a
+
+diff -r 000000000000 -r 8580ff50825a a
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/a Thu Jan 01 00:00:01 1970 +0000
+@@ -0,0 +1,1 @@
++a
+
+Displaying [PATCH 2 of 2] b ...
+Content-Type: text/plain; charset="us-ascii"
+MIME-Version: 1.0
+Content-Transfer-Encoding: 7bit
+Subject: [PATCH 2 of 2] b
+X-Mercurial-Node: 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+Message-Id: <97d72e5f12c7e84f8506.62@
+In-Reply-To: <patchbomb.60@
+Date: Thu, 01 Jan 1970 00:01:02 +0000
+From: quux
+To: foo
+Cc: bar
+
+# HG changeset patch
+# User test
+# Date 2 0
+# Node ID 97d72e5f12c7e84f85064aa72e5a297142c36ed9
+# Parent 8580ff50825a50c8f716709acdf8de0deddcd6ab
+b
+
+diff -r 8580ff50825a -r 97d72e5f12c7 b
+--- /dev/null Thu Jan 01 00:00:00 1970 +0000
++++ b/b Thu Jan 01 00:00:02 1970 +0000
+@@ -0,0 +1,1 @@
++b
+
% tagging csets
% test inline for single named patch
This patch series consists of 1 patches.