/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
0.196.16 by Jelmer Vernooij
Clarify license, copyright.
1
# Copyright (C) 2010-2012 Jelmer Vernooij <jelmer@samba.org>
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
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
7143.15.2 by Jelmer Vernooij
Run autopep8.
5
# the Free Software Foundation; version 3 of the License or
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
6
# (at your option) a 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
"""Monotone foreign branch support.
18
19
Currently only tells the user that Monotone is not supported.
20
"""
21
7143.11.1 by Jelmer Vernooij
Remove some unused imports.
22
from ... import version_info  # noqa: F401
6652.2.2 by Jelmer Vernooij
Bundle mtn plugin.
23
24
from ... import (
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
25
    controldir,
26
    errors,
27
    )
28
29
0.196.6 by Jelmer Vernooij
Implement .check_status.
30
class MonotoneUnsupportedError(errors.UnsupportedFormatError):
31
32
    _fmt = ('Monotone branches are not yet supported. '
7490.113.1 by Jelmer Vernooij
Don't reference Bazaar in message suggesting fsatimports.
33
            'To interoperate with Monotone branches, '
34
            'use fastimport.')
0.196.6 by Jelmer Vernooij
Implement .check_status.
35
36
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
37
class MonotoneDirFormat(controldir.ControlDirFormat):
38
    """Monotone directory format."""
39
40
    def get_converter(self):
41
        raise NotImplementedError(self.get_converter)
42
43
    def get_format_description(self):
44
        return "Monotone control directory"
45
46
    def initialize_on_transport(self, transport):
0.196.4 by Jelmer Vernooij
Raise UninitializableFormat on initialize.
47
        raise errors.UninitializableFormat(self)
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
48
0.196.3 by Jelmer Vernooij
mark monotone format as not supported.
49
    def is_supported(self):
50
        return False
51
0.196.14 by Jelmer Vernooij
Implement supports_transport.
52
    def supports_transport(self, transport):
53
        return False
54
0.196.7 by Jelmer Vernooij
Rename check_status -> check_support_status.
55
    def check_support_status(self, allow_unsupported, recommend_upgrade=True,
7143.15.2 by Jelmer Vernooij
Run autopep8.
56
                             basedir=None):
0.196.6 by Jelmer Vernooij
Implement .check_status.
57
        raise MonotoneUnsupportedError(self)
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
58
0.196.15 by Jelmer Vernooij
Implement .open().
59
    def open(self, transport):
60
        # Raise NotBranchError if there is nothing there
61
        MonotoneProber().probe_transport(transport)
62
        raise NotImplementedError(self.open)
63
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
64
65
class MonotoneProber(controldir.Prober):
66
67
    @classmethod
7413.6.1 by Jelmer Vernooij
Add an optional priority field for probers.
68
    def priority(klass, transport):
69
        return 100
70
71
    @classmethod
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
72
    def probe_transport(klass, transport):
73
        """Our format is present if the transport has a '_MTN/' subdir."""
74
        if transport.has('_MTN'):
75
            return MonotoneDirFormat()
6778 by Jelmer Vernooij
Merge lp:~jelmer/brz/warn-mtn-cvs.
76
        raise errors.NotBranchError(path=transport.base)
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
77
0.196.5 by Jelmer Vernooij
Update for new Prober.known_formats() interface.
78
    @classmethod
79
    def known_formats(cls):
6973.12.9 by Jelmer Vernooij
More fixes.
80
        return [MonotoneDirFormat()]
0.196.5 by Jelmer Vernooij
Update for new Prober.known_formats() interface.
81
82
0.196.1 by Jelmer Vernooij
Add simple foreign branch plugin for monotone.
83
controldir.ControlDirFormat.register_prober(MonotoneProber)