2
# -*- coding: UTF-8 -*-
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.
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.
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
19
__copyright__ = "Copyright (C) 2005 Canonical Ltd."
20
__author__ = "Martin Pool <mbp@canonical.com>"
23
######################################################################
25
class BzrError(StandardError):
27
if len(self.args) == 2:
28
# further explanation or suggestions
29
return '\n '.join([self.args[0]] + self.args[1])
34
class BzrCheckError(BzrError):
38
class InvalidRevisionNumber(BzrError):
39
def __init__(self, revno):
43
return 'invalid revision number: %r' % self.args[0]
46
class InvalidRevisionId(BzrError):
50
class BzrCommandError(BzrError):
51
# Error from malformed user command
55
class NotBranchError(BzrError):
56
"""Specified path is not in a branch"""
60
class NotVersionedError(BzrError):
61
"""Specified object is not versioned."""
64
class BadFileKindError(BzrError):
65
"""Specified file is of a kind that cannot be added.
67
(For example a symlink or device file.)"""
71
class ForbiddenFileError(BzrError):
72
"""Cannot operate on a file because it is a control file."""
76
class LockError(Exception):
77
"""All exceptions from the lock/unlock functions should be from
78
this exception class. They will be translated as necessary. The
79
original exception is available as e.original_error
81
def __init__(self, e=None):
82
self.original_error = e
84
Exception.__init__(self, e)
86
Exception.__init__(self)
89
class PointlessCommit(Exception):
90
"""Commit failed because nothing was changed."""
93
class NoSuchRevision(BzrError):
94
def __init__(self, branch, revision):
96
self.revision = revision
97
msg = "Branch %s has no revision %s" % (branch, revision)
98
BzrError.__init__(self, msg)
101
class HistoryMissing(BzrError):
102
def __init__(self, branch, object_type, object_id):
104
BzrError.__init__(self,
105
'%s is missing %s {%s}'
106
% (branch, object_type, object_id))
109
class UnrelatedBranches(BzrCommandError):
111
msg = "Branches have no common ancestor, and no base revision"\
113
BzrCommandError.__init__(self, msg)
116
class NotAncestor(BzrError):
117
def __init__(self, rev_id, not_ancestor_id):
119
self.not_ancestor_id = not_ancestor_id
120
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
122
BzrError.__init__(self, msg)
125
class InstallFailed(BzrError):
126
def __init__(self, revisions):
127
self.revisions = revisions
128
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
129
BzrError.__init__(self, msg)
132
class AmbiguousBase(BzrError):
133
def __init__(self, bases):
134
msg = "The correct base is unclear, becase %s are all equally close" %\
136
BzrError.__init__(self, msg)