Rev 5011: (mbp) change cmd_uncommit to use UIFactory more in file:///home/pqm/archives/thelove/bzr/%2Btrunk/

Canonical.com Patch Queue Manager pqm at pqm.ubuntu.com
Sat Feb 6 10:54:38 GMT 2010


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

------------------------------------------------------------
revno: 5011 [merge]
revision-id: pqm at pqm.ubuntu.com-20100206105435-3mmfhv9xg6267nyy
parent: pqm at pqm.ubuntu.com-20100205124650-p5vtdmc5isa5qa7o
parent: mbp at canoncial.com-20100206101556-oebe7u4duznhociv
committer: Canonical.com Patch Queue Manager <pqm at pqm.ubuntu.com>
branch nick: +trunk
timestamp: Sat 2010-02-06 10:54:35 +0000
message:
  (mbp) change cmd_uncommit to use UIFactory more
modified:
  bzrlib/builtins.py             builtins.py-20050830033751-fc01482b9ca23183
  bzrlib/tests/blackbox/test_uncommit.py test_uncommit.py-20051027212835-84944b63adae51be
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2010-02-04 11:02:01 +0000
+++ b/bzrlib/builtins.py	2010-02-05 15:41:45 +0000
@@ -4719,11 +4719,12 @@
                 rev_id = b.get_rev_id(revno)
 
         if rev_id is None or _mod_revision.is_null(rev_id):
-            self.outf.write('No revisions to uncommit.\n')
+            ui.ui_factory.note('No revisions to uncommit.')
             return 1
 
+        log_collector = ui.ui_factory.make_output_stream()
         lf = log_formatter('short',
-                           to_file=self.outf,
+                           to_file=log_collector,
                            show_timezone='original')
 
         show_log(b,
@@ -4734,23 +4735,21 @@
                  end_revision=last_revno)
 
         if dry_run:
-            print 'Dry-run, pretending to remove the above revisions.'
-            if not force:
-                val = raw_input('Press <enter> to continue')
+            ui.ui_factory.note('Dry-run, pretending to remove the above revisions.')
         else:
-            print 'The above revision(s) will be removed.'
-            if not force:
-                val = raw_input('Are you sure [y/N]? ')
-                if val.lower() not in ('y', 'yes'):
-                    print 'Canceled'
-                    return 0
+            ui.ui_factory.note('The above revision(s) will be removed.')
+
+        if not force:
+            if not ui.ui_factory.get_boolean('Are you sure [y/N]? '):
+                ui.ui_factory.note('Canceled')
+                return 0
 
         mutter('Uncommitting from {%s} to {%s}',
                last_rev_id, rev_id)
         uncommit(b, tree=tree, dry_run=dry_run, verbose=verbose,
                  revno=revno, local=local)
-        note('You can restore the old tip by running:\n'
-             '  bzr pull . -r revid:%s', last_rev_id)
+        ui.ui_factory.note('You can restore the old tip by running:\n'
+             '  bzr pull . -r revid:%s' % last_rev_id)
 
 
 class cmd_break_lock(Command):

=== modified file 'bzrlib/tests/blackbox/test_uncommit.py'
--- a/bzrlib/tests/blackbox/test_uncommit.py	2009-10-06 14:40:37 +0000
+++ b/bzrlib/tests/blackbox/test_uncommit.py	2010-02-06 10:15:56 +0000
@@ -1,4 +1,4 @@
-# Copyright (C) 2005, 2006, 2008 Canonical Ltd
+# Copyright (C) 2005, 2006, 2008, 2010 Canonical Ltd
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -22,6 +22,7 @@
 from bzrlib.bzrdir import BzrDirMetaFormat1
 from bzrlib.errors import BzrError, BoundBranchOutOfDate
 from bzrlib.tests import TestCaseWithTransport
+from bzrlib.tests.script import ScriptRunner
 
 
 class TestUncommit(TestCaseWithTransport):
@@ -215,11 +216,18 @@
 
     def test_uncommit_shows_log_with_revision_id(self):
         wt = self.create_simple_tree()
-
-        out, err = self.run_bzr('uncommit --force', working_dir='tree')
-        self.assertContainsRe(out, r'second commit')
-        self.assertContainsRe(err, r'You can restore the old tip by running')
-        self.assertContainsRe(err, r'bzr pull . -r revid:a2')
+        
+        script = ScriptRunner()
+        script.run_script(self, """
+$ cd tree
+$ bzr uncommit --force 
+    2 ...
+      second commit
+...
+The above revision(s) will be removed.
+You can restore the old tip by running:
+  bzr pull . -r revid:a2
+""")
 
     def test_uncommit_octopus_merge(self):
         # Check that uncommit keeps the pending merges in the same order




More information about the bazaar-commits mailing list