64
64
from dulwich import __version__ as dulwich_version
65
65
except ImportError:
66
66
raise bzr_errors.DependencyNotPresent("dulwich",
67
"bzr-git: Please install dulwich, https://www.dulwich.io/")
67
"bzr-git: Please install dulwich, https://www.dulwich.io/")
69
69
if dulwich_version < dulwich_minimum_version:
70
70
raise bzr_errors.DependencyNotPresent("dulwich",
71
"bzr-git: Dulwich is too old; at least %d.%d.%d is required" %
72
dulwich_minimum_version)
71
"bzr-git: Dulwich is too old; at least %d.%d.%d is required" %
72
dulwich_minimum_version)
75
75
_versions_checked = False
76
78
def lazy_check_versions():
77
79
global _versions_checked
78
80
if _versions_checked:
81
83
_versions_checked = True
83
86
format_registry.register_lazy('git',
84
__name__ + ".dir", "LocalGitControlDirFormat",
85
help='GIT repository.', native=False, experimental=False,
87
__name__ + ".dir", "LocalGitControlDirFormat",
88
help='GIT repository.', native=False, experimental=False,
88
91
format_registry.register_lazy('git-bare',
89
__name__ + ".dir", "BareLocalGitControlDirFormat",
90
help='Bare GIT repository (no working tree).', native=False,
92
__name__ + ".dir", "BareLocalGitControlDirFormat",
93
help='Bare GIT repository (no working tree).', native=False,
94
97
from ..revisionspec import (RevisionSpec_dwim, revspec_registry)
95
98
revspec_registry.register_lazy("git:", __name__ + ".revspec",
97
100
RevisionSpec_dwim.append_possible_lazy_revspec(
98
101
__name__ + ".revspec", "RevisionSpec_git")
152
156
req = Request('GET', url, accepted_errors=[200, 403, 404, 405],
154
(scheme, user, password, host, port, path) = urlutils.parse_url(req.get_full_url())
158
(scheme, user, password, host, port,
159
path) = urlutils.parse_url(req.get_full_url())
155
160
if host == "github.com":
156
161
# GitHub requires we lie. https://github.com/dulwich/dulwich/issues/562
157
162
req.add_header("User-Agent", user_agent_for_github())
222
227
plugin_cmds.register_lazy("cmd_git_import", [], __name__ + ".commands")
223
228
plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
224
__name__ + ".commands")
229
__name__ + ".commands")
225
230
plugin_cmds.register_lazy("cmd_git_refs", [], __name__ + ".commands")
226
231
plugin_cmds.register_lazy("cmd_git_apply", [], __name__ + ".commands")
227
232
plugin_cmds.register_lazy("cmd_git_push_pristine_tar_deltas",
228
['git-push-pristine-tar', 'git-push-pristine'],
229
__name__ + ".commands")
233
['git-push-pristine-tar', 'git-push-pristine'],
234
__name__ + ".commands")
231
237
def extract_git_foreign_revid(rev):
254
260
stanza.add("git-commit", git_commit)
256
263
from ..hooks import install_lazy_named_hook
257
264
install_lazy_named_hook("breezy.version_info_formats.format_rio",
258
"RioVersionInfoBuilder.hooks", "revision", update_stanza,
265
"RioVersionInfoBuilder.hooks", "revision", update_stanza,
262
269
transport_server_registry.register_lazy('git',
263
__name__ + '.server',
265
'Git Smart server protocol over TCP. (default port: 9418)')
270
__name__ + '.server',
272
'Git Smart server protocol over TCP. (default port: 9418)')
267
274
transport_server_registry.register_lazy('git-receive-pack',
268
__name__ + '.server',
269
'serve_git_receive_pack',
270
help='Git Smart server receive pack command. (inetd mode only)')
275
__name__ + '.server',
276
'serve_git_receive_pack',
277
help='Git Smart server receive pack command. (inetd mode only)')
271
278
transport_server_registry.register_lazy('git-upload-pack',
272
__name__ + 'git.server',
273
'serve_git_upload_pack',
274
help='Git Smart server upload pack command. (inetd mode only)')
279
__name__ + 'git.server',
280
'serve_git_upload_pack',
281
help='Git Smart server upload pack command. (inetd mode only)')
276
283
from ..repository import (
277
284
format_registry as repository_format_registry,
278
285
network_format_registry as repository_network_format_registry,
280
287
repository_network_format_registry.register_lazy(b'git',
281
__name__ + '.repository', 'GitRepositoryFormat')
288
__name__ + '.repository', 'GitRepositoryFormat')
283
290
register_extra_lazy_repository_format = getattr(repository_format_registry,
284
"register_extra_lazy")
291
"register_extra_lazy")
285
292
register_extra_lazy_repository_format(__name__ + '.repository',
286
'GitRepositoryFormat')
293
'GitRepositoryFormat')
288
295
from ..branch import (
289
296
network_format_registry as branch_network_format_registry,
291
298
branch_network_format_registry.register_lazy(b'git',
292
__name__ + '.branch', 'LocalGitBranchFormat')
299
__name__ + '.branch', 'LocalGitBranchFormat')
295
302
from ..branch import (
344
351
topic_registry.register_lazy('git', __name__ + '.help', 'help_git',
345
'Using Bazaar with Git')
352
'Using Bazaar with Git')
347
354
from ..foreign import (
348
355
foreign_vcs_registry,
350
357
foreign_vcs_registry.register_lazy("git",
351
__name__ + ".mapping", "foreign_vcs_git", "Stupid content tracker")
358
__name__ + ".mapping", "foreign_vcs_git", "Stupid content tracker")
353
360
register_lazy("breezy.diff", "format_registry",
354
'git', __name__ + '.send', 'GitDiffTree',
355
'Git am-style diff format')
361
'git', __name__ + '.send', 'GitDiffTree',
362
'Git am-style diff format')
356
363
register_lazy("breezy.send", "format_registry",
357
'git', __name__ + '.send', 'send_git',
358
'Git am-style diff format')
364
'git', __name__ + '.send', 'send_git',
365
'Git am-style diff format')
359
366
register_lazy('breezy.directory_service', 'directories', 'github:',
360
__name__ + '.directory', 'GitHubDirectory',
367
__name__ + '.directory', 'GitHubDirectory',
362
369
register_lazy('breezy.directory_service', 'directories',
363
'git@github.com:', __name__ + '.directory',
364
'GitHubDirectory', 'GitHub directory.')
370
'git@github.com:', __name__ + '.directory',
371
'GitHubDirectory', 'GitHub directory.')
365
372
register_lazy('breezy.help_topics', 'topic_registry',
366
'git', __name__ + '.help', 'help_git',
367
'Using Bazaar with Git')
373
'git', __name__ + '.help', 'help_git',
374
'Using Bazaar with Git')
368
375
register_lazy('breezy.foreign', 'foreign_vcs_registry', "git",
369
__name__ + ".mapping", "foreign_vcs_git", "Stupid content tracker")
376
__name__ + ".mapping", "foreign_vcs_git", "Stupid content tracker")
371
379
def update_git_cache(repository, revid):
372
380
"""Update the git cache after a local commit."""
373
381
if getattr(repository, "_git", None) is not None:
374
return # No need to update cache for git repositories
382
return # No need to update cache for git repositories
376
384
if not repository.control_transport.has("git"):
377
return # No existing cache, don't bother updating
385
return # No existing cache, don't bother updating
379
387
lazy_check_versions()
380
388
except bzr_errors.DependencyNotPresent as e:
381
389
# dulwich is probably missing. silently ignore
382
390
trace.mutter("not updating git map for %r: %s",
385
393
from .object_store import BazaarObjectStore
386
394
store = BazaarObjectStore(repository)
418
426
from .server import git_http_hook
419
427
return git_http_hook(branch, environ['REQUEST_METHOD'],
420
environ['PATH_INFO'])
428
environ['PATH_INFO'])
422
431
install_lazy_named_hook("breezy.branch",
423
"Branch.hooks", "post_commit", post_commit_update_cache,
432
"Branch.hooks", "post_commit", post_commit_update_cache,
425
434
install_lazy_named_hook("breezy.plugins.loggerhead.apps.branch",
426
"BranchWSGIApp.hooks", "controller",
427
loggerhead_git_hook, "git support")
435
"BranchWSGIApp.hooks", "controller",
436
loggerhead_git_hook, "git support")
430
439
from ..config import (