Merge lp:~lifeless/bzr-git/bug-526133 into lp:bzr-git

Proposed by Robert Collins on 2010-02-23
Status: Rejected
Rejected by: Jelmer Vernooij on 2010-04-07
Proposed branch: lp:~lifeless/bzr-git/bug-526133
Merge into: lp:bzr-git
Diff against target: 216 lines (+110/-54)
2 files modified
NEWS (+3/-0)
__init__.py (+107/-54)
To merge this branch: bzr merge lp:~lifeless/bzr-git/bug-526133
Reviewer Review Type Date Requested Status
Michael Hudson-Doyle 2010-02-23 Pending
Bazaar Developers 2010-02-23 Pending
Review via email: mp+19944@code.launchpad.net
To post a comment you must log in.
Robert Collins (lifeless) wrote :

as per request - a [hackish] but function deregister. I made register() so that it can be done again, and to group up the registration activities.

Jelmer Vernooij (jelmer) wrote :

On Tue, 2010-02-23 at 07:27 +0000, Robert Collins wrote:
> Robert Collins has proposed merging lp:~lifeless/bzr-git/bug-526133 into lp:bzr-git.
>
> Requested reviews:
> Michael Hudson (mwhudson)
> Bazaar Developers (bzr)
> Related bugs:
> #526133 need to be able to unload bzr-git
> https://bugs.launchpad.net/bugs/526133
>
>
> as per request - a [hackish] but function deregister. I made register() so that it can be done again, and to group up the registration activities.
I wonder, since this is hackish and specific to Launchpad, should it
perhaps land in lp:~launchpad-pqm/bzr-git/devel ?

Cheers,

Jelmer

Robert Collins (lifeless) wrote :

On Tue, 2010-02-23 at 14:30 +0000, Jelmer Vernooij wrote:

> I wonder, since this is hackish and specific to Launchpad, should it
> perhaps land in lp:~launchpad-pqm/bzr-git/devel ?

Up to you; either way is fine with me.

-Rob

Michael Hudson-Doyle (mwhudson) wrote :

Jelmer Vernooij wrote:
> On Tue, 2010-02-23 at 07:27 +0000, Robert Collins wrote:
>> Robert Collins has proposed merging lp:~lifeless/bzr-git/bug-526133 into lp:bzr-git.
>>
>> Requested reviews:
>> Michael Hudson (mwhudson)
>> Bazaar Developers (bzr)
>> Related bugs:
>> #526133 need to be able to unload bzr-git
>> https://bugs.launchpad.net/bugs/526133
>>
>>
>> as per request - a [hackish] but function deregister. I made register() so that it can be done again, and to group up the registration activities.
> I wonder, since this is hackish and specific to Launchpad, should it
> perhaps land in lp:~launchpad-pqm/bzr-git/devel ?

I tested the hack in ec2 and it seems sufficient for Launchpad's needs.

Cheers,
mwh

Jelmer Vernooij (jelmer) wrote :

should we land this in lp:~launchpad-pqm/bzr-git/devel?

Michael Hudson-Doyle (mwhudson) wrote :

Jelmer Vernooij wrote:
> should we land this in lp:~launchpad-pqm/bzr-git/devel?

Yes please. I've been meaning to do it, but you know...

Cheers,
mwh

Unmerged revisions

722. By Robert Collins on 2010-02-23

Support for unregistering from bzrlib, requested by Launchpad developers in bug 526133.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'NEWS'
--- NEWS 2010-02-18 12:04:46 +0000
+++ NEWS 2010-02-23 07:27:18 +0000
@@ -23,6 +23,9 @@
2323
24 * Support (dumb) HTTP repositories. (#373688, Jelmer Vernooij)24 * Support (dumb) HTTP repositories. (#373688, Jelmer Vernooij)
2525
26 * Support for unregistering from bzrlib, requested by Launchpad developers in
27 bug #526133. (Robert Collins)
28
260.4.3 2010-01-19290.4.3 2010-01-19
2730
28 BUG FIXES31 BUG FIXES
2932
=== modified file '__init__.py'
--- __init__.py 2010-02-12 19:14:43 +0000
+++ __init__.py 2010-02-23 07:27:18 +0000
@@ -46,6 +46,7 @@
46 bzrdir,46 bzrdir,
47 errors as bzr_errors,47 errors as bzr_errors,
48 osutils,48 osutils,
49 transport,
49 )50 )
50from bzrlib.foreign import (51from bzrlib.foreign import (
51 foreign_vcs_registry,52 foreign_vcs_registry,
@@ -87,23 +88,6 @@
87 if dulwich_version < dulwich_minimum_version:88 if dulwich_version < dulwich_minimum_version:
88 raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Dulwich is too old; at least %d.%d.%d is required" % dulwich_minimum_version)89 raise bzr_errors.DependencyNotPresent("dulwich", "bzr-git: Dulwich is too old; at least %d.%d.%d is required" % dulwich_minimum_version)
8990
90bzrdir.format_registry.register_lazy('git',
91 "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
92 help='GIT repository.', native=False, experimental=True,
93 )
94
95from bzrlib.revisionspec import revspec_registry
96revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
97 "RevisionSpec_git")
98
99try:
100 from bzrlib.revisionspec import dwim_revspecs
101except ImportError:
102 pass
103else:
104 from bzrlib.plugins.git.revspec import RevisionSpec_git
105 dwim_revspecs.append(RevisionSpec_git)
106
10791
108class GitBzrDirFormat(bzrdir.BzrDirFormat):92class GitBzrDirFormat(bzrdir.BzrDirFormat):
10993
@@ -229,50 +213,118 @@
229 raise bzr_errors.UninitializableFormat(self)213 raise bzr_errors.UninitializableFormat(self)
230214
231215
232bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
233bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
234
235register_transport_proto('git://',
236 help="Access using the Git smart server protocol.")
237register_transport_proto('git+ssh://',
238 help="Access using the Git smart server protocol over SSH.")
239
240register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
241 'TCPGitSmartTransport')
242register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
243 'SSHGitSmartTransport')
244
245foreign_vcs_registry.register_lazy("git",
246 "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
247
248plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
249plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
250 "bzrlib.plugins.git.commands")
251
252def update_stanza(rev, stanza):216def update_stanza(rev, stanza):
253 mapping = getattr(rev, "mapping", None)217 mapping = getattr(rev, "mapping", None)
254 if mapping is not None and mapping.revid_prefix.startswith("git-"):218 if mapping is not None and mapping.revid_prefix.startswith("git-"):
255 stanza.add("git-commit", rev.foreign_revid)219 stanza.add("git-commit", rev.foreign_revid)
256220
257221
258rio_hooks = getattr(RioVersionInfoBuilder, "hooks", None)222from bzrlib.revisionspec import revspec_registry
259if rio_hooks is not None:223try:
260 rio_hooks.install_named_hook('revision', update_stanza, None)224 from bzrlib.revisionspec import dwim_revspecs
261225except ImportError:
262226 dwim_revspecs = None
263from bzrlib.transport import transport_server_registry227from bzrlib.transport import transport_server_registry
264transport_server_registry.register_lazy('git',
265 'bzrlib.plugins.git.server',
266 'serve_git',
267 'Git Smart server protocol over TCP. (default port: 9418)')
268
269
270from bzrlib.repository import network_format_registry as repository_network_format_registry228from bzrlib.repository import network_format_registry as repository_network_format_registry
271repository_network_format_registry.register_lazy('git',
272 'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
273
274from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry229from bzrlib.bzrdir import network_format_registry as bzrdir_network_format_registry
275bzrdir_network_format_registry.register('git', GitBzrDirFormat)230
231__registered = False
232def register():
233 """Register bzr-git into all the registration points around.
234
235 If already registered, nothing will be done.
236 """
237 global __registered
238 if __registered:
239 return
240 # Register for .git locally
241 bzrdir.format_registry.register_lazy('git',
242 "bzrlib.plugins.git.dir", "LocalGitBzrDirFormat",
243 help='GIT repository.', native=False, experimental=True,
244 )
245 # Register so that a .git repo on a remote server can be opened using
246 # smart methods rather than VFS.
247 bzrdir_network_format_registry.register('git', GitBzrDirFormat)
248 repository_network_format_registry.register_lazy('git',
249 'bzrlib.plugins.git.repository', 'GitRepositoryFormat')
250 revspec_registry.register_lazy("git:", "bzrlib.plugins.git.revspec",
251 "RevisionSpec_git")
252 if dwim_revspecs is not None:
253 from bzrlib.plugins.git.revspec import RevisionSpec_git
254 dwim_revspecs.append(RevisionSpec_git)
255 bzrdir.BzrDirFormat.register_control_format(LocalGitBzrDirFormat)
256 bzrdir.BzrDirFormat.register_control_format(RemoteGitBzrDirFormat)
257 register_transport_proto('git://',
258 help="Access using the Git smart server protocol.")
259 register_lazy_transport("git://", 'bzrlib.plugins.git.remote',
260 'TCPGitSmartTransport')
261 register_transport_proto('git+ssh://',
262 help="Access using the Git smart server protocol over SSH.")
263 register_lazy_transport("git+ssh://", 'bzrlib.plugins.git.remote',
264 'SSHGitSmartTransport')
265 foreign_vcs_registry.register_lazy("git",
266 "bzrlib.plugins.git.mapping", "foreign_git", "Stupid content tracker")
267 plugin_cmds.register_lazy("cmd_git_import", [], "bzrlib.plugins.git.commands")
268 plugin_cmds.register_lazy("cmd_git_object", ["git-objects", "git-cat"],
269 "bzrlib.plugins.git.commands")
270 rio_hooks = getattr(RioVersionInfoBuilder, "hooks", None)
271 if rio_hooks is not None:
272 rio_hooks.install_named_hook('revision', update_stanza, None)
273 transport_server_registry.register_lazy('git',
274 'bzrlib.plugins.git.server',
275 'serve_git',
276 'Git Smart server protocol over TCP. (default port: 9418)')
277 send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
278 'send_git', 'Git am-style diff format')
279 __registered = True
280
281
282def deregister():
283 """Remove the registration of bzr-git from bzrlib.
284
285 This is generally not needed and a bad idea; however it is needed to deal
286 with limitations in the launchpad test suite where some parts of it test
287 behaviour that changes when other repository types are available.
288
289 Note: This is a bit hackish, but does the job. Like register, it is
290 idempotent. This can be improved in time by adding deregistration to bzr
291 core. However, this function only exists to work around bugs in the
292 launchpad test suite, so its general cleanliness should not matter. Once
293 launchpad fixes its test suite, this function can be deleted safely.
294
295 See bug #526133.
296 """
297 global __registered
298 if not __registered:
299 return
300 def unregister(registry, key):
301 registry._dict.pop(key)
302 registry._help_dict.pop(key)
303 registry._info_dict.pop(key)
304 bzrdir.format_registry._registration_order.remove('git')
305 unregister(bzrdir.format_registry, 'git')
306 unregister(bzrdir_network_format_registry, 'git')
307 unregister(revspec_registry, 'git:')
308 if dwim_revspecs is not None:
309 from bzrlib.plugins.git.revspec import RevisionSpec_git
310 dwim_revspecs.remove(RevisionSpec_git)
311 bzrdir.BzrDirFormat._control_formats.remove(LocalGitBzrDirFormat)
312 bzrdir.BzrDirFormat._control_formats.remove(RemoteGitBzrDirFormat)
313 # Technically, this is cheating: other plugins might offer git:// too and
314 # this wipes it out totally.
315 unregister(transport.transport_list_registry, 'git://')
316 unregister(transport.transport_list_registry, 'git+ssh://')
317 unregister(foreign_vcs_registry, "git")
318 unregister(plugin_cmds, 'git-import')
319 unregister(plugin_cmds, 'git-object')
320 rio_hooks = getattr(RioVersionInfoBuilder, "hooks", None)
321 if rio_hooks is not None:
322 hook = rio_hooks['revision']
323 hook._callbacks.remove(update_stanza)
324 unregister(transport_server_registry, 'git')
325 unregister(repository_network_format_registry, 'git')
326 unregister(send_format_registry, 'git')
327 __registered = False
276328
277329
278def get_rich_root_format(stacked=False):330def get_rich_root_format(stacked=False):
@@ -281,9 +333,10 @@
281 else:333 else:
282 return bzrdir.format_registry.make_bzrdir("default-rich-root")334 return bzrdir.format_registry.make_bzrdir("default-rich-root")
283335
284send_format_registry.register_lazy('git', 'bzrlib.plugins.git.send',
285 'send_git', 'Git am-style diff format')
286336
287def test_suite():337def test_suite():
288 from bzrlib.plugins.git import tests338 from bzrlib.plugins.git import tests
289 return tests.test_suite()339 return tests.test_suite()
340
341
342register()

Subscribers

People subscribed via source and target branches

to all changes: