/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to errors.py

  • Committer: Canonical.com Patch Queue Manager
  • Date: 2006-04-13 23:16:57 UTC
  • mfrom: (1662.1.1 bzr.mbp.integration)
  • Revision ID: pqm@pqm.ubuntu.com-20060413231657-bce3d67d3e7a4f2b
(mbp/olaf) push/pull/merge --remember improvements

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2007 Canonical Ltd
2
 
#
3
 
# This program is free software; you can redistribute it and/or modify
4
 
# it under the terms of the GNU General Public License as published by
5
 
# the Free Software Foundation; either version 2 of the License, or
6
 
# (at your option) any later version.
7
 
#
8
 
# This program is distributed in the hope that it will be useful,
9
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
 
# GNU General Public License for more details.
12
 
#
13
 
# You should have received a copy of the GNU General Public License
14
 
# along with this program; if not, write to the Free Software
15
 
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
 
 
17
 
 
18
 
"""A grouping of Exceptions for bzr-git"""
19
 
 
20
 
from __future__ import absolute_import
21
 
 
22
 
from dulwich import errors as git_errors
23
 
 
24
 
from ... import errors as bzr_errors
25
 
 
26
 
 
27
 
class BzrGitError(bzr_errors.BzrError):
28
 
    """The base-level exception for bzr-git errors."""
29
 
 
30
 
 
31
 
class NoSuchRef(BzrGitError):
32
 
    """Raised when a ref can not be found."""
33
 
 
34
 
    _fmt = "The ref %(ref)s was not found in the repository at %(location)s."
35
 
 
36
 
    def __init__(self, ref, location, present_refs=None):
37
 
        self.ref = ref
38
 
        self.location = location
39
 
        self.present_refs = present_refs
40
 
 
41
 
 
42
 
def convert_dulwich_error(error):
43
 
    """Convert a Dulwich error to a Bazaar error."""
44
 
 
45
 
    if isinstance(error, git_errors.HangupException):
46
 
        raise bzr_errors.ConnectionReset(error.msg, "")
47
 
    raise error
48
 
 
49
 
 
50
 
class NoPushSupport(bzr_errors.BzrError):
51
 
    _fmt = "Push is not yet supported for bzr-git. Try dpush instead."
52
 
 
53
 
 
54
 
class GitSmartRemoteNotSupported(bzr_errors.UnsupportedOperation):
55
 
    _fmt = "This operation is not supported by the Git smart server protocol."
56
 
 
57
 
 
58
 
class UnknownCommitExtra(bzr_errors.BzrError):
59
 
    _fmt = "Unknown extra fields in %(object)r: %(fields)r."
60
 
 
61
 
    def __init__(self, object, fields):
62
 
        bzr_errors.BzrError.__init__(self)
63
 
        self.object = object
64
 
        self.fields = ",".join(fields)
65
 
 
66
 
 
67
 
class UnknownMercurialCommitExtra(bzr_errors.BzrError):
68
 
    _fmt = "Unknown mercurial extra fields in %(object)r: %(fields)r."
69
 
 
70
 
    def __init__(self, object, fields):
71
 
        bzr_errors.BzrError.__init__(self)
72
 
        self.object = object
73
 
        self.fields = ",".join(fields)