Mercurial > hg
changeset 16751:2d432a1fc0db
ui: add _isatty method to easily disable cooked I/O
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 20 May 2012 14:31:56 -0500 |
parents | 5b1f869b5548 |
children | 359fda6cb01d |
files | mercurial/ui.py |
diffstat | 1 files changed, 8 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/ui.py Tue May 15 22:36:47 2012 +0200 +++ b/mercurial/ui.py Sun May 20 14:31:56 2012 -0500 @@ -492,6 +492,11 @@ try: self.ferr.flush() except (IOError, ValueError): pass + def _isatty(self, fh): + if self.configbool('ui', 'nontty', False): + return False + return util.isatty(fh) + def interactive(self): '''is interactive input allowed? @@ -510,7 +515,7 @@ if i is None: # some environments replace stdin without implementing isatty # usually those are non-interactive - return util.isatty(self.fin) + return self._isatty(self.fin) return i @@ -548,12 +553,12 @@ if i is None: # some environments replace stdout without implementing isatty # usually those are non-interactive - return util.isatty(self.fout) + return self._isatty(self.fout) return i def _readline(self, prompt=''): - if util.isatty(self.fin): + if self._isatty(self.fin): try: # magically add command line editing support, where # available