/brz/remove-bazaar

To get this branch, use:
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
0.215.73 by Jelmer Vernooij
James is ok with licensing his code GPLv2 or later rather than GPLv2-only.
7
# or (at your option) any later version of the License.
0.211.4 by James Westby
Add methods to repo to get objects of a certain type.
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
0.211.48 by Jelmer Vernooij
Some more work resolving objects.
53
54
class ObjectMissing(Exception):
55
  """Indicates that a requested object is missing."""
56
57
  def __init__(self, sha, *args, **kwargs):
58
    Exception.__init__(self, "%s is not in the pack" % sha)
0.211.52 by Jelmer Vernooij
Fix offsets in pack files.
59
60
61
class ApplyDeltaError(Exception):
62
    """Indicates that applying a delta failed."""
63
    
64
    def __init__(self, *args, **kwargs):
65
        Exception.__init__(self, *args, **kwargs)
0.215.48 by Jelmer Vernooij
Raise exception when no git repository is found.
66
67
68
class NotGitRepository(Exception):
69
    """Indicates that no Git repository was found."""
70
71
    def __init__(self, *args, **kwargs):
72
        Exception.__init__(self, *args, **kwargs)
0.215.58 by Jelmer Vernooij
Raise exception when client hangs up.
73
74
75
class GitProtocolError(Exception):
76
    """Git protocol exception."""
77
    
78
    def __init__(self, *args, **kwargs):
79
        Exception.__init__(self, *args, **kwargs)
80
81
82
class HangupException(GitProtocolError):
83
    """Hangup exception."""