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):
29
class BzrCheckError(BzrError):
33
class InvalidRevisionNumber(BzrError):
34
def __init__(self, revno):
38
return 'invalid revision number: %r' % self.args[0]
41
class InvalidRevisionId(BzrError):
45
class BzrCommandError(BzrError):
46
# Error from malformed user command
50
class NotBranchError(BzrError):
51
"""Specified path is not in a branch"""
55
class NotVersionedError(BzrError):
56
"""Specified object is not versioned."""
59
class BadFileKindError(BzrError):
60
"""Specified file is of a kind that cannot be added.
62
(For example a symlink or device file.)"""
66
class ForbiddenFileError(BzrError):
67
"""Cannot operate on a file because it is a control file."""
71
class LockError(Exception):
72
"""All exceptions from the lock/unlock functions should be from
73
this exception class. They will be translated as necessary. The
74
original exception is available as e.original_error
76
def __init__(self, e=None):
77
self.original_error = e
79
Exception.__init__(self, e)
81
Exception.__init__(self)
84
class PointlessCommit(Exception):
85
"""Commit failed because nothing was changed."""
88
class NoSuchRevision(BzrError):
89
def __init__(self, branch, revision):
91
self.revision = revision
92
msg = "Branch %s has no revision %s" % (branch, revision)
93
BzrError.__init__(self, msg)
96
class DivergedBranches(BzrError):
97
def __init__(self, branch1, branch2):
98
BzrError.__init__(self, "These branches have diverged.")
99
self.branch1 = branch1
100
self.branch2 = branch2
102
class UnrelatedBranches(BzrCommandError):
104
msg = "Branches have no common ancestor, and no base revision"\
106
BzrCommandError.__init__(self, msg)
108
class NoCommonAncestor(BzrError):
109
def __init__(self, revision_a, revision_b):
110
msg = "Revisions have no common ancestor: %s %s." \
111
% (revision_a, revision_b)
112
BzrError.__init__(self, msg)
114
class NoCommonRoot(BzrError):
115
def __init__(self, revision_a, revision_b):
116
msg = "Revisions are not derived from the same root: %s %s." \
117
% (revision_a, revision_b)
118
BzrError.__init__(self, msg)
120
class NotAncestor(BzrError):
121
def __init__(self, rev_id, not_ancestor_id):
122
msg = "Revision %s is not an ancestor of %s" % (not_ancestor_id,
124
BzrError.__init__(self, msg)
126
self.not_ancestor_id = not_ancestor_id
129
class InstallFailed(BzrError):
130
def __init__(self, revisions):
131
msg = "Could not install revisions:\n%s" % " ,".join(revisions)
132
BzrError.__init__(self, msg)
133
self.revisions = revisions
136
class AmbiguousBase(BzrError):
137
def __init__(self, bases):
138
msg = "The correct base is unclear, becase %s are all equally close" %\
140
BzrError.__init__(self, msg)
143
class NoCommits(BzrError):
144
def __init__(self, branch):
145
msg = "Branch %s has no commits." % branch
146
BzrError.__init__(self, msg)