22
22
"""A GIT branch and repository format implementation for bzr."""
33
from bzrlib.foreign import (
36
from bzrlib.lockable_files import (
39
from bzrlib.transport import (
40
register_lazy_transport,
41
register_transport_proto,
43
from bzrlib.commands import (
46
from bzrlib.trace import (
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)
55
if version_info[3] == 'final':
56
version_string = '%d.%d.%d' % version_info[:3]
58
version_string = '%d.%d.%d%s%d' % version_info
59
__version__ = version_string
61
MINIMUM_DULWICH_VERSION = (0, 1, 1)
62
COMPATIBLE_BZR_VERSIONS = [(1, 13, 0)]
64
if getattr(sys, "frozen", None):
65
# allow import additional libs from ./_lib for bzr.exe only
66
sys.path.append(os.path.normpath(os.path.join(os.path.dirname(__file__), '_lib')))
26
from bzrlib import bzrdir, errors as bzr_errors
27
from bzrlib.foreign import foreign_vcs_registry
28
from bzrlib.lockable_files import TransportLock
29
from bzrlib.transport import register_lazy_transport
30
from bzrlib.commands import plugin_cmds
31
from bzrlib.trace import warning
33
MINIMUM_DULWICH_VERSION = (0, 1, 0)
34
COMPATIBLE_BZR_VERSIONS = [(1, 11, 0), (1, 12, 0)]
68
36
_versions_checked = False
69
37
def lazy_check_versions():
75
43
from dulwich import __version__ as dulwich_version
76
44
except ImportError:
77
raise ImportError("bzr-git: Please install dulwich, https://launchpad.net/dulwich")
45
warning("Please install dulwich, https://launchpad.net/dulwich")
79
48
if dulwich_version < MINIMUM_DULWICH_VERSION:
80
raise ImportError("bzr-git: Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
49
warning("Dulwich is too old; at least %d.%d.%d is required" % MINIMUM_DULWICH_VERSION)
82
52
bzrlib.api.require_any_api(bzrlib, COMPATIBLE_BZR_VERSIONS)
86
56
help='GIT repository.', native=False, experimental=True,
89
from bzrlib.revisionspec import revspec_registry
90
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
60
from bzrlib.revisionspec import revspec_registry
61
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
65
from bzrlib.revisionspec import SPEC_TYPES
66
from bzrlib.plugins.git.revspec import RevisionSpec_git
67
SPEC_TYPES.append(RevisionSpec_git)
93
69
class GitBzrDirFormat(bzrdir.BzrDirFormat):
94
70
_lock_class = TransportLock
177
153
"""Open this directory.
180
# we dont grok readonly - git isn't integrated with transport.
182
if url.startswith('readonly+'):
183
url = url[len('readonly+'):]
184
if (not url.startswith("git://") and
185
not url.startswith("git+")):
186
raise bzr_errors.NotBranchError(transport.base)
187
156
from bzrlib.plugins.git.remote import RemoteGitDir, GitSmartTransport
188
157
if not isinstance(transport, GitSmartTransport):
189
158
raise bzr_errors.NotBranchError(transport.base)
159
# we dont grok readonly - git isn't integrated with transport.
161
if url.startswith('readonly+'):
162
url = url[len('readonly+'):]
190
164
from bzrlib.plugins.git.dir import GitLockableFiles, GitLock
191
165
lockfiles = GitLockableFiles(transport, GitLock())
192
166
return RemoteGitDir(transport, lockfiles, self)
195
169
def probe_transport(klass, transport):
196
170
"""Our format is present if the transport ends in '.not/'."""
198
if url.startswith('readonly+'):
199
url = url[len('readonly+'):]
200
if (not url.startswith("git://") and
201
not url.startswith("git+")):
202
raise bzr_errors.NotBranchError(transport.base)
203
171
# little ugly, but works
205
173
from bzrlib.plugins.git.remote import GitSmartTransport
229
197
bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
230
198
bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
232
register_transport_proto('git://',
233
help="Access using the Git smart server protocol.")
234
register_transport_proto('git+ssh://',
235
help="Access using the Git smart server protocol over SSH.")
237
200
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
238
'TCPGitSmartTransport')
240
register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
241
'SSHGitSmartTransport')
243
203
foreign_vcs_registry.register_lazy("git",
244
204
"bzrlib.plugins.git.mapping",
248
208
plugin_cmds.register_lazy("cmd_git_serve", [], "bzrlib.plugins.git.commands")
249
209
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
251
def get_rich_root_format():
253
return bzrdir.format_registry.make_bzrdir("default-rich-root")
255
return bzrdir.format_registry.make_bzrdir("1.9-rich-root")
257
211
def test_suite():
258
212
from bzrlib.plugins.git import tests
259
213
return tests.test_suite()