# HG changeset patch # User Cédric Duval # Date 2010-03-15 21:37:38 # 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 --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -105,6 +105,10 @@ def cdiffstat(ui, summary, patchlines): 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 @@ def makepatch(ui, repo, patch, opts, _ch 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 @@ def patchbomb(ui, repo, *revs, **opts): 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 --git a/tests/test-patchbomb b/tests/test-patchbomb --- a/tests/test-patchbomb +++ b/tests/test-patchbomb @@ -126,6 +126,11 @@ echo "% test intro for single patch" 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 --git a/tests/test-patchbomb.out b/tests/test-patchbomb.out --- a/tests/test-patchbomb.out +++ b/tests/test-patchbomb.out @@ -940,6 +940,52 @@ diff -r 97d72e5f12c7 -r ff2c9fa2018b c @@ -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: