comparison mercurial/ui.py @ 18966:5572f688e0a9

ui: add 'force' parameter to traceback() to override the current print setting This will allow a current traceback.print_exc() call in dispatch to be replaced with ui.traceback() even if --traceback was not given on the command line.
author Matt Harbison <matt_harbison@yahoo.com>
date Sat, 09 Feb 2013 14:22:52 -0500
parents 0062508b1900
children 2c4cd1c42365
comparison
equal deleted inserted replaced
18965:0062508b1900 18966:5572f688e0a9
679 finally: 679 finally:
680 os.unlink(name) 680 os.unlink(name)
681 681
682 return t 682 return t
683 683
684 def traceback(self, exc=None): 684 def traceback(self, exc=None, force=False):
685 '''print exception traceback if traceback printing enabled. 685 '''print exception traceback if traceback printing enabled or forced.
686 only to call in exception handler. returns true if traceback 686 only to call in exception handler. returns true if traceback
687 printed.''' 687 printed.'''
688 if self.tracebackflag: 688 if self.tracebackflag or force:
689 if exc is None: 689 if exc is None:
690 exc = sys.exc_info() 690 exc = sys.exc_info()
691 cause = getattr(exc[1], 'cause', None) 691 cause = getattr(exc[1], 'cause', None)
692 692
693 if cause is not None: 693 if cause is not None:
701 ''.join(causetb), 701 ''.join(causetb),
702 ''.join(exconly)) 702 ''.join(exconly))
703 else: 703 else:
704 traceback.print_exception(exc[0], exc[1], exc[2], 704 traceback.print_exception(exc[0], exc[1], exc[2],
705 file=self.ferr) 705 file=self.ferr)
706 return self.tracebackflag 706 return self.tracebackflag or force
707 707
708 def geteditor(self): 708 def geteditor(self):
709 '''return editor to use''' 709 '''return editor to use'''
710 if sys.platform == 'plan9': 710 if sys.platform == 'plan9':
711 # vi is the MIPS instruction simulator on Plan 9. We 711 # vi is the MIPS instruction simulator on Plan 9. We