# HG changeset patch # User Alexander Solovyov # Date 2009-10-19 20:27:20 # Node ID d051db8e9e4402a4d198aa817e5873df02d16bea # Parent a3d73b3e1f8a349b7946968bb2daa44115cbe749 fix patchbomb prompt when sending series of patches diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py --- a/hgext/patchbomb.py +++ b/hgext/patchbomb.py @@ -76,9 +76,11 @@ from mercurial import cmdutil, commands, from mercurial.i18n import _ from mercurial.node import bin -def prompt(ui, prompt, default=None, rest=': ', empty_ok=False): +def prompt(ui, prompt, default='', rest=': ', empty_ok=False): if not ui.interactive(): - return default + if default or empty_ok: + return default + raise util.Abort(_("%sPlease enter a valid value" % (prompt+rest))) if default: prompt += ' [%s]' % default prompt += rest @@ -331,8 +333,7 @@ def patchbomb(ui, repo, *revs, **opts): subj = '[PATCH %0*d of %d %s] ' % (tlen, 0, len(patches), flag) else: subj = '[PATCH %0*d of %d] ' % (tlen, 0, len(patches)) - subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj, - default='None') + subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj) body = '' if opts.get('diffstat'): diff --git a/tests/test-patchbomb b/tests/test-patchbomb --- a/tests/test-patchbomb +++ b/tests/test-patchbomb @@ -152,6 +152,9 @@ hg email --date '1970-1-1 0:1' -n -f quu hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar --in-reply-to baz \ -r 0:1 | fixheaders +hg email --date '1970-1-1 0:1' -n -f quux -t foo -c bar --in-reply-to baz \ + -s test -r 0:1 | fixheaders + echo "% test single flag for single patch" hg email --date '1970-1-1 0:1' -n --flag fooFlag -f quux -t foo -c bar -s test \ -r 2 | fixheaders diff --git a/tests/test-patchbomb.out b/tests/test-patchbomb.out --- a/tests/test-patchbomb.out +++ b/tests/test-patchbomb.out @@ -1177,17 +1177,20 @@ diff -r eae5fcf795ee -r e317db6a6f28 .hg +ff2c9fa2018b15fa74b33363bda9527323e2a99f two +ff2c9fa2018b15fa74b33363bda9527323e2a99f two.diff +abort: Subject:[PATCH 0 of 2] Please enter a valid value +This patch series consists of 2 patches. + This patch series consists of 2 patches. Write the introductory message for the patch series. -Displaying [PATCH 0 of 2] None ... +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] None +Subject: [PATCH 0 of 2] test Message-Id: References: