82
82
from dulwich import __version__ as dulwich_version
83
83
except ImportError:
84
raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Please install dulwich, https://launchpad.net/dulwich")
84
raise bzr_errors.DependencyNotPresent("dulwich",
85
"bzr-git: Please install dulwich, https://launchpad.net/dulwich")
86
87
if dulwich_version < dulwich_minimum_version:
87
88
raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Dulwich is too old; at least %d.%d.%d is required" % dulwich_minimum_version)
89
bzrdir.format_registry.register_lazy('git',
90
bzrdir.format_registry.register_lazy('git',
90
91
"bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
91
92
help='GIT repository.', native=False, experimental=True,
94
95
from bzrlib.revisionspec import revspec_registry
95
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
96
revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
96
97
"RevisionSpec_git")
129
132
lazy_check_versions()
131
133
# we dont grok readonly - git isn't integrated with transport.
133
if url.startswith('readonly+'):
134
url = url[len('readonly+'):]
134
from bzrlib.transport.local import LocalTransport
135
if isinstance(transport, LocalTransport):
137
137
gitrepo = dulwich.repo.Repo(transport.local_abspath(".").encode(osutils._fs_enc))
138
except bzr_errors.NotLocalUrl:
139
raise bzr_errors.NotBranchError(path=transport.base)
139
from bzrlib.plugins.git.transportgit import TransportRepo
140
gitrepo = TransportRepo(transport)
140
141
from bzrlib.plugins.git.dir import LocalGitDir, GitLockableFiles, GitLock
141
142
lockfiles = GitLockableFiles(transport, GitLock())
142
143
return LocalGitDir(transport, lockfiles, gitrepo, self)
145
146
def probe_transport(klass, transport):
146
"""Our format is present if the transport ends in '.not/'."""
147
from bzrlib.transport.local import LocalTransport
149
if not isinstance(transport, LocalTransport):
150
raise bzr_errors.NotBranchError(path=transport.base)
152
# This should quickly filter out most things that are not
153
# git repositories, saving us the trouble from loading dulwich.
154
if not transport.has(".git") and not transport.has("objects"):
155
raise bzr_errors.NotBranchError(path=transport.base)
148
if not (transport.has('info/refs') or
149
transport.has('.git/branches') or
150
transport.has('branches')):
151
raise bzr_errors.NotBranchError(path=transport.base)
152
except bzr_errors.NoSuchFile:
153
raise bzr_errors.NotBranchError(path=transport.base)
154
from bzrlib import urlutils
155
if urlutils.split(transport.base)[1] == ".git":
156
raise bzr_errors.NotBranchError(path=transport.base)
157
157
lazy_check_versions()
201
201
url = transport.base
202
202
if url.startswith('readonly+'):
203
203
url = url[len('readonly+'):]
204
if (not url.startswith("git://") and
205
not url.startswith("git+")):
204
if (not url.startswith("git://") and not url.startswith("git+")):
206
205
raise bzr_errors.NotBranchError(transport.base)
207
206
from bzrlib.plugins.git.remote import RemoteGitDir, GitSmartTransport
208
207
if not isinstance(transport, GitSmartTransport):
217
216
url = transport.base
218
217
if url.startswith('readonly+'):
219
218
url = url[len('readonly+'):]
220
if (not url.startswith("git://") and
221
not url.startswith("git+")):
219
if (not url.startswith("git://") and not url.startswith("git+")):
222
220
raise bzr_errors.NotBranchError(transport.base)
223
221
# little ugly, but works
240
238
bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
241
239
bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
243
register_transport_proto('git://',
241
register_transport_proto('git://',
244
242
help="Access using the Git smart server protocol.")
245
register_transport_proto('git+ssh://',
243
register_transport_proto('git+ssh://',
246
244
help="Access using the Git smart server protocol over SSH.")
248
246
register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
250
248
register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
251
249
'SSHGitSmartTransport')
253
foreign_vcs_registry.register_lazy("git",
251
foreign_vcs_registry.register_lazy("git",
254
252
"bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
256
254
plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
257
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
255
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
258
256
"bzrlib.plugins.git.commands")
257
plugin_cmds.register_lazy("cmd_git_refs", [], "bzrlib.plugins.git.commands")
258
plugin_cmds.register_lazy("cmd_git_apply", [], "bzrlib.plugins.git.commands")
260
260
def update_stanza(rev, stanza):
261
261
mapping = getattr(rev, "mapping", None)
271
271
from bzrlib.transport import transport_server_registry
272
272
transport_server_registry.register_lazy('git',
273
'bzrlib.plugins.git.server',
273
'bzrlib.plugins.git.server',
275
275
'Git Smart server protocol over TCP. (default port: 9418)')
278
278
from bzrlib.repository import network_format_registry as repository_network_format_registry
279
repository_network_format_registry.register_lazy('git',
279
repository_network_format_registry.register_lazy('git',
280
280
'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
282
282
from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry
292
292
send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
293
293
'send_git', 'Git am-style diff format')
296
from bzrlib.diff import format_registry as diff_format_registry
300
diff_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
301
'GitDiffTree', 'Git am-style diff format')
295
303
def test_suite():
296
304
from bzrlib.plugins.git import tests
297
305
return tests.test_suite()