# HG changeset patch # User Cédric Duval # Date 1268689058 -3600 # Node ID 7a0502a6f9a111d3b0e6937b7a676ee7600bae34 # Parent 71cf11f03b3d671893dd859fd62e3811a1866726 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. diff -r 71cf11f03b3d -r 7a0502a6f9a1 hgext/patchbomb.py --- 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')) diff -r 71cf11f03b3d -r 7a0502a6f9a1 tests/test-patchbomb --- 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 diff -r 71cf11f03b3d -r 7a0502a6f9a1 tests/test-patchbomb.out --- 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: