Mercurial > hg-stable
changeset 8208:32a2a1e244f1
ui: make interactive a method
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Sun, 26 Apr 2009 16:50:44 -0500 |
parents | dd8d5be57d65 |
children | a1a5a57efe90 |
files | hgext/patchbomb.py hgext/record.py mercurial/ui.py mercurial/url.py |
diffstat | 4 files changed, 10 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/hgext/patchbomb.py Sun Apr 26 16:50:44 2009 -0500 +++ b/hgext/patchbomb.py Sun Apr 26 16:50:44 2009 -0500 @@ -76,7 +76,7 @@ from mercurial.node import bin def prompt(ui, prompt, default=None, rest=': ', empty_ok=False): - if not ui.interactive: + if not ui.interactive(): return default if default: prompt += ' [%s]' % default
--- a/hgext/record.py Sun Apr 26 16:50:44 2009 -0500 +++ b/hgext/record.py Sun Apr 26 16:50:44 2009 -0500 @@ -394,7 +394,7 @@ def dorecord(ui, repo, committer, *pats, **opts): - if not ui.interactive: + if not ui.interactive(): raise util.Abort(_('running non-interactively, use commit instead')) def recordfunc(ui, repo, message, match, opts):
--- a/mercurial/ui.py Sun Apr 26 16:50:44 2009 -0500 +++ b/mercurial/ui.py Sun Apr 26 16:50:44 2009 -0500 @@ -16,7 +16,7 @@ def __init__(self, src=None): self._buffers = [] self.quiet = self.verbose = self.debugflag = self._traceback = False - self.interactive = self._reportuntrusted = True + self._reportuntrusted = True self._ocfg = config.config() # overlay self._tcfg = config.config() # trusted self._ucfg = config.config() # untrusted @@ -37,18 +37,6 @@ def copy(self): return ui(self) - _isatty = None - def isatty(self): - if ui._isatty is None: - try: - ui._isatty = sys.stdin.isatty() - except AttributeError: # not a real file object - ui._isatty = False - except IOError: - # access to stdin is unsafe in a WSGI environment - ui._isatty = False - return ui._isatty - def _is_trusted(self, fp, f): st = util.fstat(fp) if util.isowner(fp, st): @@ -112,7 +100,6 @@ if self.verbose and self.quiet: self.quiet = self.verbose = False self._reportuntrusted = self.configbool("ui", "report_untrusted", True) - self.interactive = self.configbool("ui", "interactive", self.isatty()) self._traceback = self.configbool('ui', 'traceback', False) # update trust information @@ -259,8 +246,11 @@ try: sys.stderr.flush() except: pass + def interactive(self): + return self.configbool("ui", "interactive") or sys.stdin.isatty() + def _readline(self, prompt=''): - if self.isatty(): + if sys.stdin.isatty(): try: # magically add command line editing support, where # available @@ -282,7 +272,7 @@ If not interactive -- the default is returned """ - if not self.interactive: + if not self.interactive(): self.note(msg, ' ', default, "\n") return default while True: @@ -298,7 +288,7 @@ raise util.Abort(_('response expected')) def getpass(self, prompt=None, default=None): - if not self.interactive: return default + if not self.interactive(): return default try: return getpass.getpass(prompt or _('password: ')) except EOFError:
--- a/mercurial/url.py Sun Apr 26 16:50:44 2009 -0500 +++ b/mercurial/url.py Sun Apr 26 16:50:44 2009 -0500 @@ -107,7 +107,7 @@ if user and passwd: return (user, passwd) - if not self.ui.interactive: + if not self.ui.interactive(): raise util.Abort(_('http authorization required')) self.ui.write(_("http authorization required\n"))