/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: Vincent Ladeuil
  • Date: 2008-06-10 15:25:47 UTC
  • mto: This revision was merged to the branch mainline in revision 504.
  • Revision ID: v.ladeuil+lp@free.fr-20080610152547-dwmil1p8pd0mfpnl
Fix third failing test (thanks to jam).

* tests/test_commit.py:
(TestPendingRevisions.test_pending_revisions_multi_merge): Fix
provided by jam: bzr we now filter the pending merges so that only
the 'heads()' are included. We just ensure that the pending merges
contain the unique tips for the ancestries.

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
from bzrlib.plugins.gtk import _i18n
 
19
from dialog import error_dialog
 
20
 
 
21
 
 
22
def show_bzr_error(unbound):
 
23
    """Decorator that shows bazaar exceptions. """
 
24
    def convert(*args, **kwargs):
 
25
        try:
 
26
            unbound(*args, **kwargs)
 
27
        except errors.NotBranchError:
 
28
            error_dialog(_i18n('Directory is not a branch'),
 
29
                         _i18n('You can perform this action only in a branch.'))
 
30
        except errors.LocalRequiresBoundBranch:
 
31
            error_dialog(_i18n('Directory is not a checkout'),
 
32
                         _i18n('You can perform local commit only on checkouts.'))
 
33
        except errors.PointlessCommit:
 
34
            error_dialog(_i18n('No changes to commit'),
 
35
                         _i18n('Try force commit if you want to commit anyway.'))
 
36
        except errors.ConflictsInTree:
 
37
            error_dialog(_i18n('Conflicts in tree'),
 
38
                         _i18n('You need to resolve the conflicts before committing.'))
 
39
        except errors.StrictCommitFailed:
 
40
            error_dialog(_i18n('Strict commit failed'),
 
41
                         _i18n('There are unknown files in the working tree.\nPlease add or delete them.'))
 
42
        except errors.BoundBranchOutOfDate, errmsg:
 
43
            error_dialog(_i18n('Bound branch is out of date'),
 
44
                         # FIXME: Really ? Internationalizing %s ?? --vila080505
 
45
                         _i18n('%s') % errmsg)
 
46
        except errors.NotVersionedError:
 
47
            error_dialog(_i18n('File not versioned'),
 
48
                         _i18n('The selected file is not versioned.'))
 
49
        except errors.DivergedBranches:
 
50
            error_dialog(_i18n('Branches have been diverged'),
 
51
                         _i18n('You cannot push if branches have diverged. Use the\noverwrite option if you want to push anyway.'))
 
52
        except errors.NoSuchFile:
 
53
            error_dialog(_i18n("No diff output"),
 
54
                         _i18n("The selected file hasn't changed."))
 
55
        except errors.NoSuchRevision:
 
56
                error_dialog(_i18n('No such revision'),
 
57
                             _i18n("The revision you specified doesn't exist."))
 
58
        except errors.FileExists:
 
59
                error_dialog(_i18n('Target already exists'),
 
60
                             _i18n("Target directory already exists. Please select another target."))
 
61
        except errors.AlreadyBranchError, errmsg:
 
62
            error_dialog(_i18n('Directory is already a branch'),
 
63
                         _i18n('The current directory (%s) is already a branch.\nYou can start using it, or initialize another directory.') % errmsg)
 
64
        except errors.BranchExistsWithoutWorkingTree, errmsg:
 
65
            error_dialog(_i18n('Branch without a working tree'),
 
66
                         _i18n('The current directory (%s)\nis a branch without a working tree.') % errmsg)
 
67
        except errors.BzrError, msg:
 
68
            error_dialog(_i18n('Unknown bzr error'), str(msg))
 
69
        except errors.PermissionDenied:
 
70
            error_dialog(_i18n("Permission denied"), _i18n("permission denied."))
 
71
        except Exception, msg:
 
72
            error_dialog(_i18n('Unknown error'), str(msg))
 
73
 
 
74
    convert.__doc__ = unbound.__doc__
 
75
    convert.__name__ = unbound.__name__
 
76
    return convert
 
77
 
 
78
 
 
79