Rev 4799: Fix failing tests by checking stdin when needed only. in file:///home/vila/src/bzr/reviews/shelve-no-tty/

Vincent Ladeuil v.ladeuil+lp at free.fr
Thu Nov 26 17:06:33 GMT 2009


At file:///home/vila/src/bzr/reviews/shelve-no-tty/

------------------------------------------------------------
revno: 4799
revision-id: v.ladeuil+lp at free.fr-20091126170632-zcgrykp0dt0yig52
parent: bialix at ukr.net-20091116110658-06omssmns2wf5r6g
committer: Vincent Ladeuil <v.ladeuil+lp at free.fr>
branch nick: shelve-no-tty
timestamp: Thu 2009-11-26 18:06:32 +0100
message:
  Fix failing tests by checking stdin when needed only.
-------------- next part --------------
=== modified file 'bzrlib/builtins.py'
--- a/bzrlib/builtins.py	2009-11-16 11:06:58 +0000
+++ b/bzrlib/builtins.py	2009-11-26 17:06:32 +0000
@@ -5662,8 +5662,6 @@
             writer=None, list=False, destroy=False):
         if list:
             return self.run_for_list()
-        if not sys.stdin.isatty():
-            raise errors.BzrError("shelve must be run from command line only.")
         from bzrlib.shelf_ui import Shelver
         if writer is None:
             writer = bzrlib.option.diff_writer_registry.get()

=== modified file 'bzrlib/shelf_ui.py'
--- a/bzrlib/shelf_ui.py	2009-11-02 21:56:42 +0000
+++ b/bzrlib/shelf_ui.py	2009-11-26 17:06:32 +0000
@@ -253,6 +253,12 @@
         :param message: The message to prompt a user with.
         :return: A character.
         """
+        if not sys.stdin.isatty():
+            # Since there is no controlling terminal we will hang when trying
+            # to prompt the user, better abort now.  See
+            # https://code.launchpad.net/~bialix/bzr/shelve-no-tty/+merge/14905
+            # for more context.
+            raise errors.BzrError("You need a controlling terminal.")
         sys.stdout.write(message)
         char = osutils.getchar()
         sys.stdout.write("\r" + ' ' * len(message) + '\r')



More information about the bazaar-commits mailing list