mercurial/ui.py
changeset 10282 08a0f04b56bd
parent 10264 d6512b3e9ac0
child 10383 f83291e5643e
equal deleted inserted replaced
10281:e7d3b509af8b 10282:08a0f04b56bd
   196             raise util.Abort(_("username %s contains a newline\n") % repr(user))
   196             raise util.Abort(_("username %s contains a newline\n") % repr(user))
   197         return user
   197         return user
   198 
   198 
   199     def shortuser(self, user):
   199     def shortuser(self, user):
   200         """Return a short representation of a user name or email address."""
   200         """Return a short representation of a user name or email address."""
   201         if not self.verbose: user = util.shortuser(user)
   201         if not self.verbose:
       
   202             user = util.shortuser(user)
   202         return user
   203         return user
   203 
   204 
   204     def _path(self, loc):
   205     def _path(self, loc):
   205         p = self.config('paths', loc)
   206         p = self.config('paths', loc)
   206         if p:
   207         if p:
   234             for a in args:
   235             for a in args:
   235                 sys.stdout.write(str(a))
   236                 sys.stdout.write(str(a))
   236 
   237 
   237     def write_err(self, *args):
   238     def write_err(self, *args):
   238         try:
   239         try:
   239             if not sys.stdout.closed: sys.stdout.flush()
   240             if not sys.stdout.closed:
       
   241                 sys.stdout.flush()
   240             for a in args:
   242             for a in args:
   241                 sys.stderr.write(str(a))
   243                 sys.stderr.write(str(a))
   242             # stderr may be buffered under win32 when redirected to files,
   244             # stderr may be buffered under win32 when redirected to files,
   243             # including stdout.
   245             # including stdout.
   244             if not sys.stderr.closed: sys.stderr.flush()
   246             if not sys.stderr.closed:
       
   247                 sys.stderr.flush()
   245         except IOError, inst:
   248         except IOError, inst:
   246             if inst.errno != errno.EPIPE:
   249             if inst.errno != errno.EPIPE:
   247                 raise
   250                 raise
   248 
   251 
   249     def flush(self):
   252     def flush(self):
   309             r = self.prompt(msg, resps[default])
   312             r = self.prompt(msg, resps[default])
   310             if r.lower() in resps:
   313             if r.lower() in resps:
   311                 return resps.index(r.lower())
   314                 return resps.index(r.lower())
   312             self.write(_("unrecognized response\n"))
   315             self.write(_("unrecognized response\n"))
   313 
   316 
   314 
       
   315     def getpass(self, prompt=None, default=None):
   317     def getpass(self, prompt=None, default=None):
   316         if not self.interactive(): return default
   318         if not self.interactive():
       
   319             return default
   317         try:
   320         try:
   318             return getpass.getpass(prompt or _('password: '))
   321             return getpass.getpass(prompt or _('password: '))
   319         except EOFError:
   322         except EOFError:
   320             raise util.Abort(_('response expected'))
   323             raise util.Abort(_('response expected'))
   321     def status(self, *msg):
   324     def status(self, *msg):
   322         if not self.quiet: self.write(*msg)
   325         if not self.quiet:
       
   326             self.write(*msg)
   323     def warn(self, *msg):
   327     def warn(self, *msg):
   324         self.write_err(*msg)
   328         self.write_err(*msg)
   325     def note(self, *msg):
   329     def note(self, *msg):
   326         if self.verbose: self.write(*msg)
   330         if self.verbose:
       
   331             self.write(*msg)
   327     def debug(self, *msg):
   332     def debug(self, *msg):
   328         if self.debugflag: self.write(*msg)
   333         if self.debugflag:
       
   334             self.write(*msg)
   329     def edit(self, text, user):
   335     def edit(self, text, user):
   330         (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
   336         (fd, name) = tempfile.mkstemp(prefix="hg-editor-", suffix=".txt",
   331                                       text=True)
   337                                       text=True)
   332         try:
   338         try:
   333             f = os.fdopen(fd, "w")
   339             f = os.fdopen(fd, "w")