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