bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.211.20
by Jelmer Vernooij
Change project name to dulwich everywhere, add assertion. |
1 |
# errors.py -- errors for dulwich
|
|
0.211.4
by James Westby
Add methods to repo to get objects of a certain type. |
2 |
# Copyright (C) 2007 James Westby <jw+debian@jameswestby.net>
|
3 |
#
|
|
4 |
# This program is free software; you can redistribute it and/or
|
|
5 |
# modify it under the terms of the GNU General Public License
|
|
6 |
# as published by the Free Software Foundation; version 2
|
|
7 |
# of the License.
|
|
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., 51 Franklin Street, Fifth Floor, Boston,
|
|
17 |
# MA 02110-1301, USA.
|
|
18 |
||
19 |
class WrongObjectException(Exception): |
|
20 |
"""Baseclass for all the _ is not a _ exceptions on objects. |
|
21 |
||
22 |
Do not instantiate directly.
|
|
23 |
||
24 |
Subclasses should define a _type attribute that indicates what
|
|
25 |
was expected if they were raised.
|
|
26 |
"""
|
|
27 |
||
28 |
def __init__(self, sha, *args, **kwargs): |
|
29 |
string = "%s is not a %s" % (sha, self._type) |
|
30 |
Exception.__init__(self, string) |
|
31 |
||
32 |
class NotCommitError(WrongObjectException): |
|
33 |
"""Indicates that the sha requested does not point to a commit.""" |
|
34 |
||
35 |
_type = 'commit' |
|
36 |
||
37 |
class NotTreeError(WrongObjectException): |
|
38 |
"""Indicates that the sha requested does not point to a tree.""" |
|
39 |
||
40 |
_type = 'tree' |
|
41 |
||
42 |
class NotBlobError(WrongObjectException): |
|
43 |
"""Indicates that the sha requested does not point to a blob.""" |
|
44 |
||
45 |
_type = 'blob' |
|
46 |
||
|
0.211.6
by James Westby
Error when a commit isn't found to avoid problems later. |
47 |
class MissingCommitError(Exception): |
48 |
"""Indicates that a commit was not found in the repository""" |
|
49 |
||
50 |
def __init__(self, sha, *args, **kwargs): |
|
51 |
Exception.__init__(self, "%s is not in the revision store" % sha) |
|
52 |