fix ImportError if the interface is not available (closes #77984)

authorAlain Leufroy <alain.leufroy@logilab.fr>
changesetc50ff1cdc2c8
branchdefault
phasepublic
hiddenno
parent revision#91022962925e [util] follow hg api change (closes #79058)
child revision#f2cc8e2ff806 [curses] fancier graph highlighting for current/working changeset (closes #79263)
files modified by this revision
hgviewlib/application.py
# HG changeset patch
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1319096406 -7200
# Thu Oct 20 09:40:06 2011 +0200
# Node ID c50ff1cdc2c8920ada1f39a999bb53dec96e394d
# Parent 91022962925e26bee688643a827079fe57479dd4
fix ImportError if the interface is not available (closes #77984)

diff --git a/hgviewlib/application.py b/hgviewlib/application.py
@@ -114,21 +114,22 @@
1 
2      config = HgConfig(repo.ui)
3      if not opts.interface:
4          opts.interface = config.getInterface()
5 
6 -    if opts.interface in ('raw', 'curses'):
7 -        from hgviewlib.curses.application import HgViewUrwidApplication as Application
8 -    elif opts.interface == 'qt':
9 -        from hgviewlib.qt4.application import HgViewQtApplication as Application
10 -    else:
11 -        fnerror('Unknown interface: "%s"' % opts.interface)
12 -
13      try:
14 +        if opts.interface in ('raw', 'curses'):
15 +            from hgviewlib.curses.application import HgViewUrwidApplication as Application
16 +        elif opts.interface == 'qt':
17 +            from hgviewlib.qt4.application import HgViewQtApplication as Application
18 +        else:
19 +            fnerror('Unknown interface: "%s"' % opts.interface)
20          app = Application(repo, opts, args)
21      except ApplicationError, err:
22          fnerror(str(err))
23 +    except ImportError:
24 +        fnerror('Interface is not available: %s' % opts.interface)
25 
26      sys.exit(app.exec_())
27 
28  def main():
29      """