# HG changeset patch
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1324304769 -3600
# Mon Dec 19 15:26:09 2011 +0100
# Node ID 6257f4fa274b0f165be7fc2cdb667d28d8ad1c1e
# Parent 655120b1239ba7d4ddefcb5182b74fc0618b6077
Fall back to the text interface if qt is not available (closes #84939)
Instead of defaulting to qt and erroring out if it's not there, try both
interfaces in turn and use the first one we find if the user didn't set
a preference.
# User Julien Cristau <julien.cristau@logilab.fr>
# Date 1324304769 -3600
# Mon Dec 19 15:26:09 2011 +0100
# Node ID 6257f4fa274b0f165be7fc2cdb667d28d8ad1c1e
# Parent 655120b1239ba7d4ddefcb5182b74fc0618b6077
Fall back to the text interface if qt is not available (closes #84939)
Instead of defaulting to qt and erroring out if it's not there, try both
interfaces in turn and use the first one we find if the user didn't set
a preference.
@@ -114,22 +114,31 @@
1 2 config = HgConfig(repo.ui) 3 if not opts.interface: 4 opts.interface = config.getInterface() 5 6 - try: 7 - if opts.interface in ('raw', 'curses'): 8 + Application = None 9 + if not opts.interface or opts.interface == 'qt': 10 + try: 11 + from hgviewlib.qt4.application import HgViewQtApplication as Application 12 + opts.interface = 'qt' 13 + except ImportError: 14 + pass 15 + if not opts.interface or opts.interface in ('raw', 'curses'): 16 + try: 17 from hgviewlib.curses.application import HgViewUrwidApplication as Application 18 - elif opts.interface == 'qt': 19 - from hgviewlib.qt4.application import HgViewQtApplication as Application 20 - else: 21 - fnerror('Unknown interface: "%s"' % opts.interface) 22 + opts.interface = 'raw' 23 + except ImportError: 24 + pass 25 + if not opts.interface: 26 + fnerror('No interface found') 27 + if not Application: 28 + fnerror('Interface is not available: %s' % opts.interface) 29 + try: 30 app = Application(repo, opts, args) 31 except ApplicationError, err: 32 fnerror(str(err)) 33 - except ImportError: 34 - fnerror('Interface is not available: %s' % opts.interface) 35 36 sys.exit(app.exec_()) 37 38 def main(): 39 """
@@ -239,11 +239,11 @@
40 mqhidetags: hide mq tags 41 """ 42 return self.ui.config(self.section, 'mqhidetags', default) 43 44 @cached 45 - def getInterface(self, default='qt'): 46 + def getInterface(self, default=None): 47 """ 48 interface: which GUI interface to use (among "qt", "raw" and "curses") 49 """ 50 return self.ui.config(self.section, 'interface', default) 51