Mercurial > public > mercurial-scm > hg
diff mercurial/ui.py @ 14515:76f295eaed86
util: add helper function isatty(fd) to check for tty-ness
author | Idan Kamara <idankk86@gmail.com> |
---|---|
date | Thu, 02 Jun 2011 00:43:34 +0300 |
parents | a599431b0ab6 |
children | 4e1ccd4c2b6d |
line wrap: on
line diff
--- a/mercurial/ui.py Thu Jun 02 18:52:31 2011 +0800 +++ b/mercurial/ui.py Thu Jun 02 00:43:34 2011 +0300 @@ -473,12 +473,9 @@ ''' i = self.configbool("ui", "interactive", None) if i is None: - try: - return sys.stdin.isatty() - except AttributeError: - # some environments replace stdin without implementing isatty - # usually those are non-interactive - return False + # some environments replace stdin without implementing isatty + # usually those are non-interactive + return util.isatty(sys.stdin) return i @@ -514,17 +511,14 @@ i = self.configbool("ui", "formatted", None) if i is None: - try: - return sys.stdout.isatty() - except AttributeError: - # some environments replace stdout without implementing isatty - # usually those are non-interactive - return False + # some environments replace stdout without implementing isatty + # usually those are non-interactive + return util.isatty(sys.stdout) return i def _readline(self, prompt=''): - if sys.stdin.isatty(): + if util.isatty(sys.stdin): try: # magically add command line editing support, where # available