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
1=== modified file '__init__.py'
2--- __init__.py 2007-04-09 16:12:48 +0000
3+++ __init__.py 2011-03-05 02:03:09 +0000
4@@ -19,51 +19,13 @@
5 commands. (see also commands like 'bzr shell' from bzrtools)
6 """
7
8-from bzrlib import (
9- commands,
10- ui,
11- )
12-
13-
14-class cmd_start_service(commands.Command):
15- """Run a bzr service on the local machine, which should make startup time faster.
16-
17- TODO: Instead of using a TCPServer, consider using local FIFOs.
18- That would allow you to open a FIFO for stdout and one for STDERR, and
19- the client could then poll the FIFOs, and print out information as
20- it comes in.
21-
22- It also guarantees no remote access to the local server.
23- """
24-
25- aliases = ['service']
26-
27- def run(self):
28- import service
29- from bzrlib.ui.text import TextUIFactory
30-
31- # Try to load all of the code right now,
32- # so that the spawned program won't have to
33- service.load_important_syslib()
34- service.load_all_bzrlib()
35-
36- ui.ui_factory = TextUIFactory()
37-
38- server = service.BzrTCPServer(('localhost', 11111),
39- service.BzrRequestHandler)
40-
41- server.serve_forever()
42-
43-
44-class cmd_stop_service(commands.Command):
45- """Stop a running bzr service on the local machine."""
46-
47- def run(self):
48- pass
49-
50-
51-commands.register_command(cmd_start_service)
52-commands.register_command(cmd_stop_service)
53+from bzrlib.commands import plugin_cmds
54+
55+
56+plugin_cmds.register_lazy("cmd_start_service", [],
57+ "bzrlib.plugins.service.cmds")
58+plugin_cmds.register_lazy("cmd_stop_service", [],
59+ "bzrlib.plugins.service.cmds")
60
61
62 def test_suite():
63
64=== added file 'cmds.py'
65--- cmds.py 1970-01-01 00:00:00 +0000
66+++ cmds.py 2011-03-05 02:03:09 +0000
67@@ -0,0 +1,61 @@
68+# Copyright (C) 2005, 2007 Canonical Ltd
69+#
70+# This program is free software; you can redistribute it and/or modify
71+# it under the terms of the GNU General Public License as published by
72+# the Free Software Foundation; either version 2 of the License, or
73+# (at your option) any later version.
74+#
75+# This program is distributed in the hope that it will be useful,
76+# but WITHOUT ANY WARRANTY; without even the implied warranty of
77+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
78+# GNU General Public License for more details.
79+#
80+# You should have received a copy of the GNU General Public License
81+# along with this program; if not, write to the Free Software
82+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
83+
84+"""Service plugin commands."""
85+
86+from bzrlib import (
87+ commands,
88+ ui,
89+ )
90+
91+class cmd_start_service(commands.Command):
92+ """Run a bzr service on the local machine, which should make startup time faster.
93+
94+ TODO: Instead of using a TCPServer, consider using local FIFOs.
95+ That would allow you to open a FIFO for stdout and one for STDERR, and
96+ the client could then poll the FIFOs, and print out information as
97+ it comes in.
98+
99+ It also guarantees no remote access to the local server.
100+ """
101+
102+ aliases = ['service']
103+
104+ def run(self):
105+ import service
106+ from bzrlib.ui.text import TextUIFactory
107+
108+ # Try to load all of the code right now,
109+ # so that the spawned program won't have to
110+ service.load_important_syslib()
111+ service.load_all_bzrlib()
112+
113+ ui.ui_factory = TextUIFactory()
114+
115+ server = service.BzrTCPServer(('localhost', 11111),
116+ service.BzrRequestHandler)
117+
118+ server.serve_forever()
119+
120+
121+class cmd_stop_service(commands.Command):
122+ """Stop a running bzr service on the local machine."""
123+
124+ def run(self):
125+ pass
126+
127+
128+

Subscribers

People subscribed via source and target branches

to all changes: