Rev 4492: (mbp) accept uppercase Y/N from get_boolean in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Tue Jun 30 07:35:07 BST 2009


At file:///home/pqm/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 4492 [merge]
revision-id: pqm at pqm.ubuntu.com-20090630063506-f7wlyoa0ldu816g0
parent: pqm at pqm.ubuntu.com-20090630051227-ncar0w60u6cbyydk
parent: mbp at sourcefrog.net-20090630053447-q7j4q6caq250311m
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Tue 2009-06-30 07:35:06 +0100
message:
  (mbp) accept uppercase Y/N from get_boolean
modified:
  NEWS                           NEWS-20050323055033-4e00b5db738777ff
  bzrlib/tests/test_ui.py        test_ui.py-20051130162854-458e667a7414af09
  bzrlib/ui/__init__.py          ui.py-20050824083933-8cf663c763ba53a9
=== modified file 'NEWS'
--- a/NEWS	2009-06-30 04:13:19 +0000
+++ b/NEWS	2009-06-30 05:34:47 +0000
@@ -29,6 +29,9 @@
 Bug Fixes
 *********
 
+* Accept uppercase "Y/N" to prompts such as from break lock. 
+  (#335182, Tim Powell, Martin Pool)
+
 * Add documentation about diverged branches and how to fix them in the
   centralized workflow with local commits.  Mention ``bzr help
   diverged-branches`` when a push fails because the branches have

=== modified file 'bzrlib/tests/test_ui.py'
--- a/bzrlib/tests/test_ui.py	2009-06-29 12:14:09 +0000
+++ b/bzrlib/tests/test_ui.py	2009-06-30 05:34:47 +0000
@@ -176,7 +176,10 @@
     def assert_get_bool_acceptance_of_user_input(self, factory):
         factory.stdin = StringIO("y\nyes with garbage\n"
                                  "yes\nn\nnot an answer\n"
-                                 "no\nfoo\n")
+                                 "no\n"
+                                 "N\nY\n"
+                                 "foo\n"
+                                )
         factory.stdout = StringIO()
         factory.stderr = StringIO()
         # there is no output from the base factory
@@ -184,6 +187,8 @@
         self.assertEqual(True, factory.get_boolean(""))
         self.assertEqual(False, factory.get_boolean(""))
         self.assertEqual(False, factory.get_boolean(""))
+        self.assertEqual(False, factory.get_boolean(""))
+        self.assertEqual(True, factory.get_boolean(""))
         self.assertEqual("foo\n", factory.stdin.read())
         # stdin should be empty
         self.assertEqual('', factory.stdin.readline())

=== modified file 'bzrlib/ui/__init__.py'
--- a/bzrlib/ui/__init__.py	2009-06-10 03:56:49 +0000
+++ b/bzrlib/ui/__init__.py	2009-06-30 05:34:47 +0000
@@ -157,10 +157,10 @@
         self.stderr = stderr or sys.stderr
 
     def get_boolean(self, prompt):
-        # FIXME: make a regexp and handle case variations as well.
         while True:
             self.prompt(prompt + "? [y/n]: ")
             line = self.stdin.readline()
+            line = line.lower()
             if line in ('y\n', 'yes\n'):
                 return True
             if line in ('n\n', 'no\n'):




More information about the bazaar-commits mailing list