Merge lp:~bialix/bzr-explorer/lazy-commands into lp:~bzr-explorer-dev/bzr-explorer/trunk.old

Proposed by Alexander Belchenko
Status: Merged
Merged at revision: not available
Proposed branch: lp:~bialix/bzr-explorer/lazy-commands
Merge into: lp:~bzr-explorer-dev/bzr-explorer/trunk.old
Diff against target: 109 lines (+49/-27)
2 files modified
__init__.py (+48/-0)
lib/commands.py (+1/-27)
To merge this branch: bzr merge lp:~bialix/bzr-explorer/lazy-commands
Reviewer Review Type Date Requested Status
Ian Clatworthy Approve
Bazaar Explorer Developers Pending
Review via email: mp+15186@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Alexander Belchenko (bialix) wrote :

This patch provides new feature to bzr-explorer: it register all commands lazily using appropriate API of bzrlib. This reduce coupling between explorer and qbzr so now non-explorer commands does not need to import several (big) modules from QBzr. This is clear improvements, and I don;t see any real reasons to not do lazy registering.

Revision history for this message
Ian Clatworthy (ian-clatworthy) wrote :

Looks good. Thanks.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file '__init__.py'
2--- __init__.py 1970-01-01 00:00:00 +0000
3+++ __init__.py 2009-11-24 09:40:26 +0000
4@@ -0,0 +1,48 @@
5+# Copyright (C) 2009 Canonical Ltd
6+#
7+# This program is free software; you can redistribute it and/or modify
8+# it under the terms of the GNU General Public License as published by
9+# the Free Software Foundation; either version 2 of the License, or
10+# (at your option) any later version.
11+#
12+# This program is distributed in the hope that it will be useful,
13+# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+# GNU General Public License for more details.
16+#
17+# You should have received a copy of the GNU General Public License
18+# along with this program; if not, write to the Free Software
19+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
21+"""Version Control for Human Beings.
22+
23+Bazaar Explorer is a desktop application providing an easy-to-use
24+interface to the Bazaar version control system. It is designed to
25+be simple enough for casual users of version control, yet powerful
26+enough for experts to use as their primary interface to Bazaar.
27+
28+Please visit the home page, http://doc.bazaar-vcs.org/explorer/en/,
29+for more information.
30+"""
31+
32+version_info = (0, 9, 1, 'dev', 0)
33+__version__ = '.'.join(map(str, version_info))
34+
35+
36+from bzrlib.commands import plugin_cmds
37+
38+lazy_commands = (
39+ # name, aliases, module
40+ ('cmd_explorer', ['explore'], 'bzrlib.plugins.explorer.lib.commands'),
41+ ('cmd_init_ala_explorer', ['ws-init'], 'bzrlib.plugins.explorer.lib.commands'),
42+ ('cmd_qinit_ala_explorer', [], 'bzrlib.plugins.explorer.lib.commands'),
43+ ('cmd_qcheckout_ala_explorer', [], 'bzrlib.plugins.explorer.lib.commands'),
44+)
45+
46+for name, aliases, module in lazy_commands:
47+ plugin_cmds.register_lazy(name, aliases, module)
48+
49+
50+def load_tests(basic_tests, module, loader):
51+ from bzrlib.plugins.explorer.tests import load_tests
52+ return load_tests(basic_tests, module, loader)
53
54=== renamed file '__init__.py' => 'lib/commands.py'
55--- __init__.py 2009-11-23 12:05:40 +0000
56+++ lib/commands.py 2009-11-24 09:40:26 +0000
57@@ -14,21 +14,6 @@
58 # along with this program; if not, write to the Free Software
59 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
60
61-"""Version Control for Human Beings.
62-
63-Bazaar Explorer is a desktop application providing an easy-to-use
64-interface to the Bazaar version control system. It is designed to
65-be simple enough for casual users of version control, yet powerful
66-enough for experts to use as their primary interface to Bazaar.
67-
68-Please visit the home page, http://doc.bazaar-vcs.org/explorer/en/,
69-for more information.
70-"""
71-
72-version_info = (0, 9, 1, 'dev', 0)
73-__version__ = '.'.join(map(str, version_info))
74-
75-
76 import sys
77
78 import bzrlib
79@@ -56,7 +41,7 @@
80 simple_revision_option,
81 )
82 except ImportError:
83- raise Exception("Bazaar Explorer requires QBzr. "
84+ raise bzrlib.errors.BzrError("Bazaar Explorer requires QBzr. "
85 "Please install QBzr (https://launchpad.net/qbzr).")
86
87 if getattr(sys, "frozen", None):
88@@ -64,11 +49,6 @@
89 import bzrlib.plugins.qbzr.lib
90
91
92-def load_tests(basic_tests, module, loader):
93- from bzrlib.plugins.explorer.tests import load_tests
94- return load_tests(basic_tests, module, loader)
95-
96-
97 def _init_explorer_command(zzz=False, experimental=False):
98 # Set up global exception handling.
99 from bzrlib.plugins.qbzr.lib.trace import excepthook
100@@ -251,9 +231,3 @@
101 revision=revision, ui_mode=ui_mode)
102 window.show()
103 app.exec_()
104-
105-
106-register_command(cmd_explorer)
107-register_command(cmd_init_ala_explorer)
108-register_command(cmd_qinit_ala_explorer)
109-register_command(cmd_qcheckout_ala_explorer)

Subscribers

People subscribed via source and target branches