Show More
@@ -76,7 +76,7 b' from mercurial.i18n import _' | |||
|
76 | 76 | from mercurial.node import bin |
|
77 | 77 | |
|
78 | 78 | def prompt(ui, prompt, default=None, rest=': ', empty_ok=False): |
|
79 | if not ui.interactive: | |
|
79 | if not ui.interactive(): | |
|
80 | 80 | return default |
|
81 | 81 | if default: |
|
82 | 82 | prompt += ' [%s]' % default |
@@ -394,7 +394,7 b' def qrecord(ui, repo, patch, *pats, **op' | |||
|
394 | 394 | |
|
395 | 395 | |
|
396 | 396 | def dorecord(ui, repo, committer, *pats, **opts): |
|
397 | if not ui.interactive: | |
|
397 | if not ui.interactive(): | |
|
398 | 398 | raise util.Abort(_('running non-interactively, use commit instead')) |
|
399 | 399 | |
|
400 | 400 | def recordfunc(ui, repo, message, match, opts): |
@@ -16,7 +16,7 b' class ui(object):' | |||
|
16 | 16 | def __init__(self, src=None): |
|
17 | 17 | self._buffers = [] |
|
18 | 18 | self.quiet = self.verbose = self.debugflag = self._traceback = False |
|
19 |
|
|
|
19 | self._reportuntrusted = True | |
|
20 | 20 | self._ocfg = config.config() # overlay |
|
21 | 21 | self._tcfg = config.config() # trusted |
|
22 | 22 | self._ucfg = config.config() # untrusted |
@@ -37,18 +37,6 b' class ui(object):' | |||
|
37 | 37 | def copy(self): |
|
38 | 38 | return ui(self) |
|
39 | 39 | |
|
40 | _isatty = None | |
|
41 | def isatty(self): | |
|
42 | if ui._isatty is None: | |
|
43 | try: | |
|
44 | ui._isatty = sys.stdin.isatty() | |
|
45 | except AttributeError: # not a real file object | |
|
46 | ui._isatty = False | |
|
47 | except IOError: | |
|
48 | # access to stdin is unsafe in a WSGI environment | |
|
49 | ui._isatty = False | |
|
50 | return ui._isatty | |
|
51 | ||
|
52 | 40 | def _is_trusted(self, fp, f): |
|
53 | 41 | st = util.fstat(fp) |
|
54 | 42 | if util.isowner(fp, st): |
@@ -112,7 +100,6 b' class ui(object):' | |||
|
112 | 100 | if self.verbose and self.quiet: |
|
113 | 101 | self.quiet = self.verbose = False |
|
114 | 102 | self._reportuntrusted = self.configbool("ui", "report_untrusted", True) |
|
115 | self.interactive = self.configbool("ui", "interactive", self.isatty()) | |
|
116 | 103 | self._traceback = self.configbool('ui', 'traceback', False) |
|
117 | 104 | |
|
118 | 105 | # update trust information |
@@ -259,8 +246,11 b' class ui(object):' | |||
|
259 | 246 | try: sys.stderr.flush() |
|
260 | 247 | except: pass |
|
261 | 248 | |
|
249 | def interactive(self): | |
|
250 | return self.configbool("ui", "interactive") or sys.stdin.isatty() | |
|
251 | ||
|
262 | 252 | def _readline(self, prompt=''): |
|
263 |
if s |
|
|
253 | if sys.stdin.isatty(): | |
|
264 | 254 | try: |
|
265 | 255 | # magically add command line editing support, where |
|
266 | 256 | # available |
@@ -282,7 +272,7 b' class ui(object):' | |||
|
282 | 272 | |
|
283 | 273 | If not interactive -- the default is returned |
|
284 | 274 | """ |
|
285 | if not self.interactive: | |
|
275 | if not self.interactive(): | |
|
286 | 276 | self.note(msg, ' ', default, "\n") |
|
287 | 277 | return default |
|
288 | 278 | while True: |
@@ -298,7 +288,7 b' class ui(object):' | |||
|
298 | 288 | raise util.Abort(_('response expected')) |
|
299 | 289 | |
|
300 | 290 | def getpass(self, prompt=None, default=None): |
|
301 | if not self.interactive: return default | |
|
291 | if not self.interactive(): return default | |
|
302 | 292 | try: |
|
303 | 293 | return getpass.getpass(prompt or _('password: ')) |
|
304 | 294 | except EOFError: |
@@ -107,7 +107,7 b' class passwordmgr(urllib2.HTTPPasswordMg' | |||
|
107 | 107 | if user and passwd: |
|
108 | 108 | return (user, passwd) |
|
109 | 109 | |
|
110 | if not self.ui.interactive: | |
|
110 | if not self.ui.interactive(): | |
|
111 | 111 | raise util.Abort(_('http authorization required')) |
|
112 | 112 | |
|
113 | 113 | self.ui.write(_("http authorization required\n")) |
General Comments 0
You need to be logged in to leave comments.
Login now