Merge lp:~jelmer/bzr-service/lazy into lp:bzr-service

Proposed by Jelmer Vernooij
Status: Merged
Approved by: John A Meinel
Approved revision: 18
Merged at revision: 18
Proposed branch: lp:~jelmer/bzr-service/lazy
Merge into: lp:bzr-service
Diff against target: 128 lines (+68/-45)
2 files modified
__init__.py (+7/-45)
cmds.py (+61/-0)
To merge this branch: bzr merge lp:~jelmer/bzr-service/lazy
Reviewer Review Type Date Requested Status
John A Meinel Approve
Review via email: mp+52278@code.launchpad.net

Description of the change

Lazily load the service plugin commands.

To post a comment you must log in.
Revision history for this message
John A Meinel (jameinel) wrote :

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 3/5/2011 3:03 AM, Jelmer Vernooij wrote:
> Jelmer Vernooij has proposed merging lp:~jelmer/bzr-service/lazy into lp:bzr-service.
>
> Requested reviews:
> Bazaar Developers (bzr)
>
> For more details, see:
> https://code.launchpad.net/~jelmer/bzr-service/lazy/+merge/52278
>
> Lazily load the service plugin commands.

 merge: approve

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAk101g8ACgkQJdeBCYSNAAPiZQCcCBUbrICGTVChbnlVEoSqCNLJ
jlIAoK4ul8XwekUGXG78c9U3FecTfHCU
=UaMf
-----END PGP SIGNATURE-----

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file '__init__.py'
--- __init__.py 2007-04-09 16:12:48 +0000
+++ __init__.py 2011-03-05 02:03:09 +0000
@@ -19,51 +19,13 @@
19commands. (see also commands like 'bzr shell' from bzrtools)19commands. (see also commands like 'bzr shell' from bzrtools)
20"""20"""
2121
22from bzrlib import (22from bzrlib.commands import plugin_cmds
23 commands,23
24 ui,24
25 )25plugin_cmds.register_lazy("cmd_start_service", [],
2626 "bzrlib.plugins.service.cmds")
2727plugin_cmds.register_lazy("cmd_stop_service", [],
28class cmd_start_service(commands.Command):28 "bzrlib.plugins.service.cmds")
29 """Run a bzr service on the local machine, which should make startup time faster.
30
31 TODO: Instead of using a TCPServer, consider using local FIFOs.
32 That would allow you to open a FIFO for stdout and one for STDERR, and
33 the client could then poll the FIFOs, and print out information as
34 it comes in.
35
36 It also guarantees no remote access to the local server.
37 """
38
39 aliases = ['service']
40
41 def run(self):
42 import service
43 from bzrlib.ui.text import TextUIFactory
44
45 # Try to load all of the code right now,
46 # so that the spawned program won't have to
47 service.load_important_syslib()
48 service.load_all_bzrlib()
49
50 ui.ui_factory = TextUIFactory()
51
52 server = service.BzrTCPServer(('localhost', 11111),
53 service.BzrRequestHandler)
54
55 server.serve_forever()
56
57
58class cmd_stop_service(commands.Command):
59 """Stop a running bzr service on the local machine."""
60
61 def run(self):
62 pass
63
64
65commands.register_command(cmd_start_service)
66commands.register_command(cmd_stop_service)
6729
6830
69def test_suite():31def test_suite():
7032
=== added file 'cmds.py'
--- cmds.py 1970-01-01 00:00:00 +0000
+++ cmds.py 2011-03-05 02:03:09 +0000
@@ -0,0 +1,61 @@
1# Copyright (C) 2005, 2007 Canonical Ltd
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation; either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program; if not, write to the Free Software
15# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16
17"""Service plugin commands."""
18
19from bzrlib import (
20 commands,
21 ui,
22 )
23
24class cmd_start_service(commands.Command):
25 """Run a bzr service on the local machine, which should make startup time faster.
26
27 TODO: Instead of using a TCPServer, consider using local FIFOs.
28 That would allow you to open a FIFO for stdout and one for STDERR, and
29 the client could then poll the FIFOs, and print out information as
30 it comes in.
31
32 It also guarantees no remote access to the local server.
33 """
34
35 aliases = ['service']
36
37 def run(self):
38 import service
39 from bzrlib.ui.text import TextUIFactory
40
41 # Try to load all of the code right now,
42 # so that the spawned program won't have to
43 service.load_important_syslib()
44 service.load_all_bzrlib()
45
46 ui.ui_factory = TextUIFactory()
47
48 server = service.BzrTCPServer(('localhost', 11111),
49 service.BzrRequestHandler)
50
51 server.serve_forever()
52
53
54class cmd_stop_service(commands.Command):
55 """Stop a running bzr service on the local machine."""
56
57 def run(self):
58 pass
59
60
61

Subscribers

People subscribed via source and target branches

to all changes: