Rev 6230: (jelmer) Use UIFactory.get_boolean for confirmation prompt in `bzr in file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

Patch Queue Manager pqm at pqm.ubuntu.com
Sun Oct 23 18:40:24 UTC 2011


At file:///srv/pqm.bazaar-vcs.org/archives/thelove/bzr/%2Btrunk/

------------------------------------------------------------
revno: 6230 [merge]
revision-id: pqm at pqm.ubuntu.com-20111023184023-0ymq0vcsndal81fs
parent: pqm at pqm.ubuntu.com-20111021162427-1p469p9ckc3pb5b9
parent: benoit.pierre at gmail.com-20111021231124-x3a19u51nh3a861v
committer: Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sun 2011-10-23 18:40:23 +0000
message:
  (jelmer) Use UIFactory.get_boolean for confirmation prompt in `bzr
   clean-tree`. (Benoit PIERRE)
modified:
  bzrlib/clean_tree.py           clean_tree.py-20050827022328-5ba46e22d074695c
  bzrlib/tests/blackbox/test_clean_tree.py test_clean_tree.py-20090219235516-em1ybc01twsqacx9-1
  doc/en/release-notes/bzr-2.5.txt bzr2.5.txt-20110708125756-587p0hpw7oke4h05-1
=== modified file 'bzrlib/clean_tree.py'
--- a/bzrlib/clean_tree.py	2011-10-11 12:01:51 +0000
+++ b/bzrlib/clean_tree.py	2011-10-21 23:11:24 +0000
@@ -63,12 +63,10 @@
             return 0
         if not no_prompt:
             for path, subp in deletables:
-                # FIXME using print is very bad idea
-                # clean_tree should accept to_file argument to write the output
-                print subp
-            val = raw_input('Are you sure you wish to delete these [y/N]?')
-            if val.lower() not in ('y', 'yes'):
-                print 'Canceled'
+                ui.ui_factory.note(subp)
+            prompt = gettext('Are you sure you wish to delete these')
+            if not ui.ui_factory.get_boolean(prompt):
+                ui.ui_factory.note(gettext('Canceled'))
                 return 0
         delete_items(deletables, dry_run=dry_run)
     finally:

=== modified file 'bzrlib/tests/blackbox/test_clean_tree.py'
--- a/bzrlib/tests/blackbox/test_clean_tree.py	2011-05-13 12:51:05 +0000
+++ b/bzrlib/tests/blackbox/test_clean_tree.py	2011-10-21 23:05:41 +0000
@@ -23,6 +23,7 @@
 
 from bzrlib import ignores
 from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests.script import run_script
 
 
 class TestBzrTools(TestCaseWithTransport):
@@ -88,3 +89,30 @@
         self.assertPathDoesNotExist('a/unknown')
         self.assertPathDoesNotExist('a/ignored')
         self.assertPathExists('a/added')
+
+    def test_clean_tree_interactive(self):
+        wt = self.make_branch_and_tree('.')
+        self.touch('bar')
+        self.touch('foo')
+        run_script(self, """
+        $ bzr clean-tree
+        bar
+        foo
+        2>Are you sure you wish to delete these? ([y]es, [n]o): no
+        <n
+        Canceled
+        """)
+        self.assertPathExists('bar')
+        self.assertPathExists('foo')
+        run_script(self, """
+        $ bzr clean-tree
+        bar
+        foo
+        2>Are you sure you wish to delete these? ([y]es, [n]o): yes
+        <y
+        2>deleting paths:
+        2>  bar
+        2>  foo
+        """)
+        self.assertPathDoesNotExist('bar')
+        self.assertPathDoesNotExist('foo')

=== modified file 'doc/en/release-notes/bzr-2.5.txt'
--- a/doc/en/release-notes/bzr-2.5.txt	2011-10-21 15:58:51 +0000
+++ b/doc/en/release-notes/bzr-2.5.txt	2011-10-23 18:40:23 +0000
@@ -58,6 +58,10 @@
   it usable when creating a custom ``UIFactory`` implementation. (Benoît
   Pierre)
 
+* ``bzr clean-tree`` now use ``UIFactory.get_boolean`` for confirmation
+  prompt, making it usable when using a custom ``UIFactory``
+  implementation. (Benoît Pierre)
+
 * If sending a crash through Apport fails report the Apport failure to
   bzr.log rather than stderr. (Jonathan Riddell, #766735)
 




More information about the bazaar-commits mailing list