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