/b-gtk/fix-viz

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/b-gtk/fix-viz

« back to all changes in this revision

Viewing changes to errors.py

  • Committer: Jelmer Vernooij
  • Date: 2007-02-03 11:52:13 UTC
  • Revision ID: jelmer@samba.org-20070203115213-qz5549tkrt2wsz05
Move more code to top-level directory. 
Import (last proposed) logo for Bazaar.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2007 Jelmer Vernooij <jelmer@samba.org>
 
2
 
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; either version 2 of the License, or
 
6
# (at your option) any later version.
 
7
 
 
8
# This program is distributed in the hope that it will be useful,
 
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
# GNU General Public License for more details.
 
12
 
 
13
# You should have received a copy of the GNU General Public License
 
14
# along with this program; if not, write to the Free Software
 
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
16
 
 
17
import bzrlib.errors as errors
 
18
 
 
19
from olive.dialog import error_dialog
 
20
 
 
21
def show_bzr_error(unbound):
 
22
    """Decorator that shows bazaar exceptions. """
 
23
    def convert(*args, **kwargs):
 
24
        try:
 
25
            unbound(*args, **kwargs)
 
26
        except errors.NotBranchError:
 
27
            error_dialog(_('Directory is not a branch'),
 
28
                         _('You can perform this action only in a branch.'))
 
29
        except errors.LocalRequiresBoundBranch:
 
30
            error_dialog(_('Directory is not a checkout'),
 
31
                         _('You can perform local commit only on checkouts.'))
 
32
        except errors.PointlessCommit:
 
33
            error_dialog(_('No changes to commit'),
 
34
                         _('Try force commit if you want to commit anyway.'))
 
35
        except errors.ConflictsInTree:
 
36
            error_dialog(_('Conflicts in tree'),
 
37
                         _('You need to resolve the conflicts before committing.'))
 
38
        except errors.StrictCommitFailed:
 
39
            error_dialog(_('Strict commit failed'),
 
40
                         _('There are unknown files in the working tree.\nPlease add or delete them.'))
 
41
        except errors.BoundBranchOutOfDate, errmsg:
 
42
            error_dialog(_('Bound branch is out of date'),
 
43
                         _('%s') % errmsg)
 
44
        except errors.NotVersionedError:
 
45
            error_dialog(_('File not versioned'),
 
46
                         _('The selected file is not versioned.'))
 
47
        except errors.DivergedBranches:
 
48
            error_dialog(_('Branches have been diverged'),
 
49
                         _('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
50
        except errors.NoSuchFile:
 
51
            error_dialog(_("No diff output"),
 
52
                         _("The selected file hasn't changed."))
 
53
        except errors.NoSuchRevision:
 
54
                error_dialog(_('No such revision'),
 
55
                             _("The revision you specified doesn't exist."))
 
56
        except errors.FileExists:
 
57
                error_dialog(_('Target already exists'),
 
58
                             _("Target directory already exists. Please select another target."))
 
59
        except errors.AlreadyBranchError, errmsg:
 
60
            error_dialog(_('Directory is already a branch'),
 
61
                         _('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
 
62
        except errors.BranchExistsWithoutWorkingTree, errmsg:
 
63
            error_dialog(_('Branch without a working tree'),
 
64
                         _('The current directory (%s)\nis a branch without a working tree.') % errmsg)
 
65
        except errors.BzrError, msg:
 
66
            error_dialog(_('Unknown bzr error'), str(msg))
 
67
        except errors.PermissionDenied:
 
68
            error_dialog(_("Permission denied"), _("permission denied."))
 
69
        except Exception, msg:
 
70
            error_dialog(_('Unknown error'), str(msg))
 
71
 
 
72
    convert.__doc__ = unbound.__doc__
 
73
    convert.__name__ = unbound.__name__
 
74
    return convert
 
75
 
 
76
 
 
77