/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 __init__.py

Register lazily where possible.

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
MINIMUM_DULWICH_VERSION = (0, 1, 0)
33
33
COMPATIBLE_BZR_VERSIONS = [(1, 12, 0)]
34
34
 
35
 
try:
36
 
    from dulwich import __version__ as dulwich_version
37
 
except ImportError:
38
 
    warning("Please install dulwich, https://launchpad.net/dulwich")
39
 
    raise
40
 
else:
41
 
    if dulwich_version < MINIMUM_DULWICH_VERSION:
42
 
        warning("Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
43
 
        raise ImportError
44
 
 
 
35
_versions_checked = False
 
36
def lazy_check_versions():
 
37
    global _versions_checked
 
38
    if _versions_checked:
 
39
        return
 
40
    _versions_checked = True
 
41
    try:
 
42
        from dulwich import __version__ as dulwich_version
 
43
    except ImportError:
 
44
        warning("Please install dulwich, https://launchpad.net/dulwich")
 
45
        raise
 
46
    else:
 
47
        if dulwich_version < MINIMUM_DULWICH_VERSION:
 
48
            warning("Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
 
49
            raise ImportError
45
50
 
46
51
bzrlib.api.require_any_api(bzrlib, COMPATIBLE_BZR_VERSIONS)
47
52
 
 
53
bzrdir.format_registry.register_lazy('git', 
 
54
    "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
 
55
    help='GIT repository.', native=False, experimental=True,
 
56
    )
 
57
 
 
58
lazy_check_versions()
 
59
# TODO: This should be lazier
48
60
from bzrlib.plugins.git.dir import LocalGitBzrDirFormat, RemoteGitBzrDirFormat
49
 
 
50
 
bzrdir.format_registry.register(
51
 
    'git', LocalGitBzrDirFormat,
52
 
    help='GIT repository.', 
53
 
    native=False, experimental=True,
54
 
    )
55
 
 
56
 
bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
57
 
bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
 
61
bzrdir.BzrDirFormat.register_control_format_lazy("bzrlib.plugins.git.dir", "LocalGitBzrDirFormat")
 
62
bzrdir.BzrDirFormat.register_control_format_lazy("bzrlib.plugins.git.dir", "RemoteGitBzrDirFormat")
58
63
 
59
64
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
60
65
                        'GitSmartTransport')
77
82
    ]
78
83
 
79
84
    def run(self, directory=None):
 
85
        lazy_check_versions()
80
86
        from dulwich.server import TCPGitServer
81
87
        from bzrlib.plugins.git.server import BzrBackend
82
88
        from bzrlib.trace import warning