[PATCH] fix patchbomb prompt when sending series of patches

Benoit Boissinot benoit.boissinot at ens-lyon.org
Mon Sep 28 17:02:37 CDT 2009


On Sat, Sep 26, 2009 at 11:51:00PM +0300, Alexander Solovyov wrote:
> # HG changeset patch
> # User Alexander Solovyov <piranha at piranha.org.ua>
> # Date 1253998251 -10800
> # Node ID b9647af1b557d6350acee987167bfcd87e0991bf
> # Parent  9114629969488f36ce474cd6eaac10838a0b34e5
> fix patchbomb prompt when sending series of patches

I think we want to abort properly here.

Instead of:
+  File "/tmp/hgtests.hmTfPF/install/lib/python/hgext/patchbomb.py", line 334, in getpatchmsgs
+    subj += opts.get('subject') or prompt(ui, 'Subject:', rest=subj)
+TypeError: cannot concatenate 'str' and 'NoneType' objects

So should we make the subject mandatory?

Like:

diff --git a/hgext/patchbomb.py b/hgext/patchbomb.py
--- a/hgext/patchbomb.py
+++ b/hgext/patchbomb.py
@@ -78,7 +78,9 @@
 
 def prompt(ui, prompt, default=None, 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'):
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 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 @@
 +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>

-- 
:wq


More information about the Mercurial-devel mailing list