[fix core] raise ApplicationError and do not display traceback for NotImplementedErro (closes #78004 #83307)

authorAlain Leufroy <alain.leufroy@logilab.fr>
changeset4a4bf50245b0
branchdefault
phasepublic
hiddenno
parent revision#6257f4fa274b Fall back to the text interface if qt is not available (closes #84939)
child revision#76e2e9a3d14f enable --profile/--time/--traceback/--debug options as mercurial axtension (closes #83309)
files modified by this revision
hgviewlib/application.py
# HG changeset patch
# User Alain Leufroy <alain.leufroy@logilab.fr>
# Date 1321806659 -3600
# Sun Nov 20 17:30:59 2011 +0100
# Node ID 4a4bf50245b00da51cd971a7f89fafadfacb1c65
# Parent 6257f4fa274b0f165be7fc2cdb667d28d8ad1c1e
[fix core] raise ApplicationError and do not display traceback for NotImplementedErro (closes #78004 #83307)

diff --git a/hgviewlib/application.py b/hgviewlib/application.py
@@ -82,11 +82,11 @@
1      def choose_viewer(self):
2          """Choose the right viewer"""
3          if len(self.args) == 1:
4              filename = rootpath(self.repo, self.opts.rev, self.args[0])
5              if not filename:
6 -                ApplicationError("%s is not a tracked file" % self.args[0])
7 +                raise ApplicationError("%s is not a tracked file" % self.args[0])
8 
9              # should be a filename of a file managed in the repo
10              if self.opts.navigate:
11                  viewer = self.FileViewer(self.repo, filename)
12              else:
@@ -95,11 +95,11 @@
13              rev = self.opts.rev
14              if rev:
15                  try:
16                      self.repo.changectx(rev)
17                  except RepoError, e:
18 -                    ApplicationError("Cannot find revision %s" % rev)
19 +                    raise ApplicationError("Cannot find revision %s" % rev)
20                  else:
21                      viewer = self.ManifestViewer(self.repo, rev)
22              else:
23                  viewer = self.HgRepoViewer(self.repo)
24          self.viewer = viewer
@@ -133,11 +133,11 @@
25          fnerror('No interface found')
26      if not Application:
27          fnerror('Interface is not available: %s' % opts.interface)
28      try:
29          app = Application(repo, opts, args)
30 -    except ApplicationError, err:
31 +    except (ApplicationError, NotImplementedError), err:
32          fnerror(str(err))
33 
34      sys.exit(app.exec_())
35 
36  def main():