/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

Add description of git-v1 mapping.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2006 Canonical Ltd
 
1
# Copyright (C) 2006-2009 Canonical Ltd
2
2
 
3
3
# Authors: Robert Collins <robert.collins@canonical.com>
4
4
#          Jelmer Vernooij <jelmer@samba.org>
26
26
 
27
27
import bzrlib
28
28
import bzrlib.api
29
 
from bzrlib import bzrdir, errors as bzr_errors
30
 
from bzrlib.foreign import foreign_vcs_registry
31
 
from bzrlib.lockable_files import TransportLock
32
 
from bzrlib.transport import register_lazy_transport
33
 
from bzrlib.commands import plugin_cmds
34
 
from bzrlib.trace import warning
35
 
 
36
 
MINIMUM_DULWICH_VERSION = (0, 1, 0)
37
 
COMPATIBLE_BZR_VERSIONS = [(1, 11, 0), (1, 12, 0)]
 
29
from bzrlib import (
 
30
    bzrdir,
 
31
    errors as bzr_errors,
 
32
    )
 
33
from bzrlib.foreign import (
 
34
    foreign_vcs_registry,
 
35
    )
 
36
from bzrlib.lockable_files import (
 
37
    TransportLock,
 
38
    )
 
39
from bzrlib.transport import (
 
40
    register_lazy_transport,
 
41
    register_transport_proto,
 
42
    )
 
43
from bzrlib.commands import (
 
44
    plugin_cmds,
 
45
    )
 
46
from bzrlib.trace import (
 
47
    warning,
 
48
    )
 
49
 
 
50
# versions ending in 'exp' mean experimental mappings
 
51
# versions ending in 'dev' mean development version
 
52
# versions ending in 'final' mean release (well tested, etc)
 
53
version_info = (0, 2, 0, 'dev', 0)
 
54
 
 
55
if version_info[3] == 'final':
 
56
    version_string = '%d.%d.%d' % version_info[:3]
 
57
else:
 
58
    version_string = '%d.%d.%d%s%d' % version_info
 
59
__version__ = version_string
 
60
 
 
61
MINIMUM_DULWICH_VERSION = (0, 1, 1)
 
62
COMPATIBLE_BZR_VERSIONS = [(1, 15, 0)]
38
63
 
39
64
if getattr(sys, "frozen", None):
40
65
    # allow import additional libs from ./_lib for bzr.exe only
61
86
    help='GIT repository.', native=False, experimental=True,
62
87
    )
63
88
 
64
 
try:
65
 
    from bzrlib.revisionspec import revspec_registry
66
 
    revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec", 
67
 
        "RevisionSpec_git")
68
 
except ImportError:
69
 
    lazy_check_versions()
70
 
    from bzrlib.revisionspec import SPEC_TYPES
71
 
    from bzrlib.plugins.git.revspec import RevisionSpec_git
72
 
    SPEC_TYPES.append(RevisionSpec_git)
 
89
from bzrlib.revisionspec import revspec_registry
 
90
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec", 
 
91
    "RevisionSpec_git")
 
92
 
73
93
 
74
94
class GitBzrDirFormat(bzrdir.BzrDirFormat):
75
95
    _lock_class = TransportLock
158
178
        """Open this directory.
159
179
 
160
180
        """
 
181
        # we dont grok readonly - git isn't integrated with transport.
 
182
        url = transport.base
 
183
        if url.startswith('readonly+'):
 
184
            url = url[len('readonly+'):]
 
185
        if (not url.startswith("git://") and 
 
186
            not url.startswith("git+")):
 
187
            raise bzr_errors.NotBranchError(transport.base)
161
188
        from bzrlib.plugins.git.remote import RemoteGitDir, GitSmartTransport
162
189
        if not isinstance(transport, GitSmartTransport):
163
190
            raise bzr_errors.NotBranchError(transport.base)
164
 
        # we dont grok readonly - git isn't integrated with transport.
165
 
        url = transport.base
166
 
        if url.startswith('readonly+'):
167
 
            url = url[len('readonly+'):]
168
 
 
169
191
        from bzrlib.plugins.git.dir import GitLockableFiles, GitLock
170
192
        lockfiles = GitLockableFiles(transport, GitLock())
171
193
        return RemoteGitDir(transport, lockfiles, self)
173
195
    @classmethod
174
196
    def probe_transport(klass, transport):
175
197
        """Our format is present if the transport ends in '.not/'."""
 
198
        url = transport.base
 
199
        if url.startswith('readonly+'):
 
200
            url = url[len('readonly+'):]
 
201
        if (not url.startswith("git://") and 
 
202
            not url.startswith("git+")):
 
203
            raise bzr_errors.NotBranchError(transport.base)
176
204
        # little ugly, but works
177
205
        format = klass()
178
206
        from bzrlib.plugins.git.remote import GitSmartTransport
202
230
bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
203
231
bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
204
232
 
 
233
register_transport_proto('git://', 
 
234
        help="Access using the Git smart server protocol.")
 
235
register_transport_proto('git+ssh://', 
 
236
        help="Access using the Git smart server protocol over SSH.")
 
237
 
205
238
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
206
 
                        'GitSmartTransport')
 
239
                        'TCPGitSmartTransport')
 
240
register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
 
241
                        'SSHGitSmartTransport')
207
242
 
208
243
foreign_vcs_registry.register_lazy("git", 
209
 
                        "bzrlib.plugins.git.mapping", 
210
 
                        "foreign_git",
211
 
                        "Stupid content tracker")
 
244
    "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
212
245
 
213
246
plugin_cmds.register_lazy("cmd_git_serve", [], "bzrlib.plugins.git.commands")
214
247
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
215
248
 
 
249
def get_rich_root_format(stacked=False):
 
250
    if stacked:
 
251
        return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
 
252
    else:
 
253
        return bzrdir.format_registry.make_bzrdir("default-rich-root")
 
254
 
216
255
def test_suite():
217
256
    from bzrlib.plugins.git import tests
218
257
    return tests.test_suite()