Mercurial > hg-stable
changeset 10734:7a0502a6f9a1
patchbomb: --desc implies --intro
For a single patch, an introductory text should not remain unsent
if --intro has been omitted, as the intent of --desc is clear.
author | Cédric Duval <cedricduval@free.fr> |
---|---|
date | Mon, 15 Mar 2010 22:37:38 +0100 |
parents | 71cf11f03b3d |
children | 054652eeeaf1 |
files | hgext/patchbomb.py tests/test-patchbomb tests/test-patchbomb.out |
diffstat | 3 files changed, 57 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/patchbomb.py Thu Mar 18 14:36:24 2010 -0700 +++ b/hgext/patchbomb.py Mon Mar 15 22:37:38 2010 +0100 @@ -105,6 +105,10 @@ raise util.Abort(_('diffstat rejected')) return s +def introneeded(opts, number): + '''is an introductory message required?''' + return number > 1 or opts.get('intro') or opts.get('desc') + def makepatch(ui, repo, patch, opts, _charsets, idx, total, patchname=None): desc = [] @@ -170,7 +174,7 @@ flag = ' ' + flag subj = desc[0].strip().rstrip('. ') - if total == 1 and not opts.get('intro'): + if not introneeded(opts, total): subj = '[PATCH%s] %s' % (flag, opts.get('subject') or subj) else: tlen = len(str(total)) @@ -329,7 +333,7 @@ len(patches), name) msgs.append(msg) - if len(patches) > 1 or opts.get('intro'): + if introneeded(opts, len(patches)): tlen = len(str(len(patches))) flag = ' '.join(opts.get('flag'))
--- a/tests/test-patchbomb Thu Mar 18 14:36:24 2010 -0700 +++ b/tests/test-patchbomb Mon Mar 15 22:37:38 2010 +0100 @@ -126,6 +126,11 @@ hg email --date '1970-1-1 0:1' -n --intro -f quux -t foo -c bar -s test \ -r 2 | fixheaders +echo "% test --desc without --intro for a single patch" +echo foo > intro.text +hg email --date '1970-1-1 0:1' -n --desc intro.text -f quux -t foo -c bar \ + -s test -r 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 \ -r 0:1 | fixheaders
--- a/tests/test-patchbomb.out Thu Mar 18 14:36:24 2010 -0700 +++ b/tests/test-patchbomb.out Mon Mar 15 22:37:38 2010 +0100 @@ -940,6 +940,52 @@ @@ -0,0 +1,1 @@ +c +% test --desc without --intro for a single patch +This patch series consists of 1 patches. + + +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@ +User-Agent: Mercurial-patchbomb +Date: Thu, 01 Jan 1970 00:01:00 +0000 +From: quux +To: foo +Cc: bar + +foo + +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@ +References: <patchbomb.60@ +User-Agent: Mercurial-patchbomb +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.