/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
1
# Copyright (C) 2007 Canonical Ltd
0.358.2 by Jelmer Vernooij
Refresh copyright headers, add my email.
2
# Copyright (C) 2018 Jelmer Vernooij <jelmer@jelmer.uk>
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
3
#
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.
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
0.358.1 by Jelmer Vernooij
Fix FSF address.
16
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
17
18
"""A grouping of Exceptions for bzr-git"""
19
0.200.292 by Jelmer Vernooij
Fix formatting.
20
from dulwich import errors as git_errors
21
7143.7.1 by Jelmer Vernooij
Simplify brz-git, drop imports.
22
from .. import errors as brz_errors
23
24
25
class BzrGitError(brz_errors.BzrError):
0.200.19 by John Arbash Meinel
More refactoring. Add some direct tests for GitModel.
26
    """The base-level exception for bzr-git errors."""
27
28
0.200.165 by Jelmer Vernooij
Give a proper error when the ref can not be found.
29
class NoSuchRef(BzrGitError):
0.200.695 by Jelmer Vernooij
Clean up trailing whitespace.
30
    """Raised when a ref can not be found."""
0.200.165 by Jelmer Vernooij
Give a proper error when the ref can not be found.
31
0.200.1386 by Jelmer Vernooij
Friendlier message if HEAD is not found.
32
    _fmt = "The ref %(ref)s was not found in the repository at %(location)s."
0.200.695 by Jelmer Vernooij
Clean up trailing whitespace.
33
0.200.1386 by Jelmer Vernooij
Friendlier message if HEAD is not found.
34
    def __init__(self, ref, location, present_refs=None):
0.200.165 by Jelmer Vernooij
Give a proper error when the ref can not be found.
35
        self.ref = ref
0.200.1386 by Jelmer Vernooij
Friendlier message if HEAD is not found.
36
        self.location = location
0.200.277 by Jelmer Vernooij
Allow passing in refs that *were* found in NoSuchRef.
37
        self.present_refs = present_refs
38
0.200.210 by Jelmer Vernooij
properly error out about not support lightweight checkouts.
39
0.200.242 by Jelmer Vernooij
Add conversion function for dulwich errors.
40
def convert_dulwich_error(error):
41
    """Convert a Dulwich error to a Bazaar error."""
42
43
    if isinstance(error, git_errors.HangupException):
7143.7.1 by Jelmer Vernooij
Simplify brz-git, drop imports.
44
        raise brz_errors.ConnectionReset(error.msg, "")
0.200.242 by Jelmer Vernooij
Add conversion function for dulwich errors.
45
    raise error
0.200.291 by Jelmer Vernooij
Print proper error about not supporting push.
46
47
7143.7.1 by Jelmer Vernooij
Simplify brz-git, drop imports.
48
class NoPushSupport(brz_errors.BzrError):
7143.15.6 by Jelmer Vernooij
Merge trunk.
49
    _fmt = ("Push is not yet supported from %(source)r to %(target)r "
50
            "using %(mapping)r for %(revision_id)r. Try dpush instead.")
0.200.1718 by Jelmer Vernooij
Support AlreadyControlDirError.
51
0.320.2 by Jelmer Vernooij
Only complain about roundtripping if revisions being pushed didn't originally come from git.
52
    def __init__(self, source, target, mapping, revision_id=None):
0.200.1718 by Jelmer Vernooij
Support AlreadyControlDirError.
53
        self.source = source
54
        self.target = target
55
        self.mapping = mapping
0.320.2 by Jelmer Vernooij
Only complain about roundtripping if revisions being pushed didn't originally come from git.
56
        self.revision_id = revision_id
0.200.319 by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server.
57
58
7143.7.1 by Jelmer Vernooij
Simplify brz-git, drop imports.
59
class GitSmartRemoteNotSupported(brz_errors.UnsupportedOperation):
0.200.319 by Jelmer Vernooij
Print proper error when trying unsupported operations against a git server.
60
    _fmt = "This operation is not supported by the Git smart server protocol."