1
by mbp at sourcefrog
import from baz patch-364 |
1 |
#! /usr/bin/env python
|
2 |
# -*- coding: UTF-8 -*-
|
|
3 |
||
4 |
# This program is free software; you can redistribute it and/or modify
|
|
5 |
# it under the terms of the GNU General Public License as published by
|
|
6 |
# the Free Software Foundation; either version 2 of the License, or
|
|
7 |
# (at your option) any later version.
|
|
8 |
||
9 |
# This program is distributed in the hope that it will be useful,
|
|
10 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
11 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
12 |
# GNU General Public License for more details.
|
|
13 |
||
14 |
# You should have received a copy of the GNU General Public License
|
|
15 |
# along with this program; if not, write to the Free Software
|
|
16 |
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
17 |
||
18 |
||
19 |
__copyright__ = "Copyright (C) 2005 Canonical Ltd." |
|
20 |
__author__ = "Martin Pool <mbp@canonical.com>" |
|
21 |
||
22 |
||
23 |
######################################################################
|
|
24 |
# exceptions
|
|
25 |
class BzrError(StandardError): |
|
1193
by Martin Pool
- better string formatting of BzrErrors with explanation |
26 |
def __str__(self): |
1195
by Martin Pool
- better error display |
27 |
if len(self.args) == 1: |
28 |
return self.args[0] |
|
29 |
elif len(self.args) == 2: |
|
1193
by Martin Pool
- better string formatting of BzrErrors with explanation |
30 |
# further explanation or suggestions
|
31 |
return '\n '.join([self.args[0]] + self.args[1]) |
|
32 |
else: |
|
33 |
return `self.args` |
|
34 |
||
1
by mbp at sourcefrog
import from baz patch-364 |
35 |
|
36 |
class BzrCheckError(BzrError): |
|
37 |
pass
|
|
38 |
||
39 |
||
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
40 |
class InvalidRevisionNumber(BzrError): |
41 |
def __init__(self, revno): |
|
42 |
self.args = [revno] |
|
43 |
||
44 |
def __str__(self): |
|
45 |
return 'invalid revision number: %r' % self.args[0] |
|
46 |
||
47 |
||
48 |
class InvalidRevisionId(BzrError): |
|
49 |
pass
|
|
50 |
||
51 |
||
329
by Martin Pool
- refactor command functions into command classes |
52 |
class BzrCommandError(BzrError): |
53 |
# Error from malformed user command
|
|
54 |
pass
|
|
1
by mbp at sourcefrog
import from baz patch-364 |
55 |
|
56 |
||
573
by Martin Pool
- new exception NotBranchError |
57 |
class NotBranchError(BzrError): |
58 |
"""Specified path is not in a branch"""
|
|
59 |
pass
|
|
60 |
||
61 |
||
753
by Martin Pool
- new exception NotVersionedError |
62 |
class NotVersionedError(BzrError): |
63 |
"""Specified object is not versioned."""
|
|
64 |
||
65 |
||
599
by Martin Pool
- better error reporting from smart_add |
66 |
class BadFileKindError(BzrError): |
67 |
"""Specified file is of a kind that cannot be added.
|
|
68 |
||
69 |
(For example a symlink or device file.)"""
|
|
70 |
pass
|
|
71 |
||
72 |
||
73 |
class ForbiddenFileError(BzrError): |
|
74 |
"""Cannot operate on a file because it is a control file."""
|
|
75 |
pass
|
|
76 |
||
77 |
||
614
by Martin Pool
- unify two defintions of LockError |
78 |
class LockError(Exception): |
79 |
"""All exceptions from the lock/unlock functions should be from
|
|
80 |
this exception class. They will be translated as necessary. The
|
|
81 |
original exception is available as e.original_error
|
|
82 |
"""
|
|
83 |
def __init__(self, e=None): |
|
84 |
self.original_error = e |
|
85 |
if e: |
|
86 |
Exception.__init__(self, e) |
|
87 |
else: |
|
88 |
Exception.__init__(self) |
|
882
by Martin Pool
- Optionally raise EmptyCommit if there are no changes. Test for this. |
89 |
|
90 |
||
885
by Martin Pool
- commit command refuses unless something is changed or --unchanged is given |
91 |
class PointlessCommit(Exception): |
882
by Martin Pool
- Optionally raise EmptyCommit if there are no changes. Test for this. |
92 |
"""Commit failed because nothing was changed."""
|
974.1.26
by aaron.bentley at utoronto
merged mbp@sourcefrog.net-20050817233101-0939da1cf91f2472 |
93 |
|
94 |
||
95 |
class NoSuchRevision(BzrError): |
|
96 |
def __init__(self, branch, revision): |
|
97 |
self.branch = branch |
|
98 |
self.revision = revision |
|
99 |
msg = "Branch %s has no revision %s" % (branch, revision) |
|
100 |
BzrError.__init__(self, msg) |
|
101 |
||
1034
by Martin Pool
- merge bzrlib.revision.is_ancestor from aaron |
102 |
|
1192
by Martin Pool
- clean up code for retrieving stored inventories |
103 |
class HistoryMissing(BzrError): |
104 |
def __init__(self, branch, object_type, object_id): |
|
105 |
self.branch = branch |
|
106 |
BzrError.__init__(self, |
|
107 |
'%s is missing %s {%s}' |
|
108 |
% (branch, object_type, object_id)) |
|
109 |
||
110 |
||
1105
by Martin Pool
- expose 'find-merge-base' as a new expert command, |
111 |
class UnrelatedBranches(BzrCommandError): |
112 |
def __init__(self): |
|
113 |
msg = "Branches have no common ancestor, and no base revision"\ |
|
114 |
" specified."
|
|
115 |
BzrCommandError.__init__(self, msg) |
|
116 |
||
117 |
||
974.2.7
by aaron.bentley at utoronto
Merged from bzr.24 |
118 |
class NotAncestor(BzrError): |
119 |
def __init__(self, rev_id, not_ancestor_id): |
|
120 |
self.rev_id = rev_id |
|
121 |
self.not_ancestor_id = not_ancestor_id |
|
122 |
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id, |
|
123 |
rev_id) |
|
124 |
BzrError.__init__(self, msg) |
|
974.1.42
by Aaron Bentley
Initial 'intervening revisions' implementation |
125 |
|
1092.1.42
by Robert Collins
merge from abentley |
126 |
|
974.1.30
by aaron.bentley at utoronto
Changed copy_multi to permit failure and return a tuple, tested missing required revisions |
127 |
class InstallFailed(BzrError): |
128 |
def __init__(self, revisions): |
|
129 |
self.revisions = revisions |
|
130 |
msg = "Could not install revisions:\n%s" % " ,".join(revisions) |
|
131 |
BzrError.__init__(self, msg) |
|
1154
by Martin Pool
- fix imports for moved errors |
132 |
|
133 |
||
134 |
class AmbiguousBase(BzrError): |
|
135 |
def __init__(self, bases): |
|
136 |
msg = "The correct base is unclear, becase %s are all equally close" %\ |
|
137 |
", ".join(bases) |
|
138 |
BzrError.__init__(self, msg) |
|
139 |
self.bases = bases |
|
140 |