fix patchbomb prompt when sending series of patches
authorAlexander Solovyov <piranha@piranha.org.ua>
Mon, 19 Oct 2009 23:27:20 +0300
changeset 9612 d051db8e9e44
parent 9611 a3d73b3e1f8a
child 9613 c63c336ee2f7
child 9614 58edd448da4f
fix patchbomb prompt when sending series of patches
hgext/patchbomb.py
tests/test-patchbomb
tests/test-patchbomb.out
--- a/hgext/patchbomb.py	Fri Oct 16 23:57:34 2009 +0200
+++ b/hgext/patchbomb.py	Mon Oct 19 23:27:20 2009 +0300
@@ -76,9 +76,11 @@
 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 @@
                 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'):
--- a/tests/test-patchbomb	Fri Oct 16 23:57:34 2009 +0200
+++ b/tests/test-patchbomb	Mon Oct 19 23:27:20 2009 +0300
@@ -152,6 +152,9 @@
 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
--- a/tests/test-patchbomb.out	Fri Oct 16 23:57:34 2009 +0200
+++ b/tests/test-patchbomb.out	Mon Oct 19 23:27:20 2009 +0300
@@ -1177,17 +1177,20 @@
 +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: <patchbomb.60@
 In-Reply-To: <baz>
 References: <baz>