Merge lp:~lifeless/bzr/command-help-bug-177500 into lp:bzr

Proposed by Robert Collins on 2010-05-11
Status: Merged
Approved by: John A Meinel on 2010-05-11
Approved revision: no longer in the revision history of the source branch.
Merged at revision: 5224
Proposed branch: lp:~lifeless/bzr/command-help-bug-177500
Merge into: lp:bzr
Diff against target: 54 lines (+13/-3)
3 files modified
NEWS (+3/-0)
bzrlib/commands.py (+5/-3)
bzrlib/tests/test_commands.py (+5/-0)
To merge this branch: bzr merge lp:~lifeless/bzr/command-help-bug-177500
Reviewer Review Type Date Requested Status
John A Meinel 2010-05-11 Approve on 2010-05-11
Review via email: mp+25055@code.launchpad.net

Commit Message

Fail to construct commands that have no help, rather than failing when help is first requested.

Description of the Change

fix bug 177500 by erroring earlier, so that users won't encounter broken plugins etc (from new code).

To post a comment you must log in.
5223. By Canonical.com Patch Queue Manager <email address hidden> on 2010-05-11

(lifeless) Provide a consistent interface to Tree, Branch,
 Repository where lock methods return an object with an unlock method to
 unlock the lock. This breaks the API for Branch,
 Repository on their lock_write methods. (Robert Collins)

John A Meinel (jameinel) wrote :

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

Robert Collins wrote:
> Robert Collins has proposed merging lp:~lifeless/bzr/command-help-bug-177500 into lp:bzr.
>
> Requested reviews:
> bzr-core (bzr-core)
>
>
> fix bug 177500 by erroring earlier, so that users won't encounter broken plugins etc (from new code).
>

 merge: approve

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

iEYEARECAAYFAkvpVi8ACgkQJdeBCYSNAAM6XQCg05ARutbkufuzYek3lJzxmY/J
pjAAn2SxRURkS3dyIs8h0Zt/CrDdNgbn
=bHWi
-----END PGP SIGNATURE-----

review: Approve
Robert Collins (lifeless) wrote :

submitted to PQM by hand.

5224. By Canonical.com Patch Queue Manager <email address hidden> on 2010-05-11

(lifeless) Fail to construct commands that have no help,
 rather than failing when help is first requested. (Robert Collins)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'NEWS'
2--- NEWS 2010-05-10 18:43:19 +0000
3+++ NEWS 2010-05-11 11:08:26 +0000
4@@ -18,6 +18,9 @@
5 whoami``.
6 (Parth Malwankar, #549310)
7
8+* ``bzrlib.commands.Command`` will now raise ValueError during
9+ construction if there is no __doc__ set. (Robert Collins)
10+
11 New Features
12 ************
13
14
15=== modified file 'bzrlib/commands.py'
16--- bzrlib/commands.py 2010-04-28 13:03:47 +0000
17+++ bzrlib/commands.py 2010-05-11 11:08:26 +0000
18@@ -407,8 +407,8 @@
19
20 def __init__(self):
21 """Construct an instance of this command."""
22- if self.__doc__ == Command.__doc__:
23- warn("No help message set for %r" % self)
24+ if self.__doc__ == Command.__doc__ or not self.__doc__:
25+ raise ValueError("No help message set for %r" % self)
26 # List of standard options directly supported
27 self.supported_std_options = []
28 self._setup_run()
29@@ -483,7 +483,9 @@
30 """
31 doc = self.help()
32 if doc is None:
33- raise NotImplementedError("sorry, no detailed help yet for %r" % self.name())
34+ raise NotImplementedError(
35+ "self.help() returned None - no detailed help yet for %r" %
36+ self.name())
37
38 # Extract the summary (purpose) and sections out from the text
39 purpose,sections,order = self._get_help_parts(doc)
40
41=== modified file 'bzrlib/tests/test_commands.py'
42--- bzrlib/tests/test_commands.py 2010-04-22 18:36:13 +0000
43+++ bzrlib/tests/test_commands.py 2010-05-11 11:08:26 +0000
44@@ -79,6 +79,11 @@
45 c = self.get_command([option.Option('foo', hidden=False)])
46 self.assertContainsRe(c.get_help_text(), '--foo')
47
48+ def test_no_help_init_failure(self):
49+ class cmd_foo(commands.Command):
50+ pass
51+ self.assertRaises(ValueError, cmd_foo)
52+
53
54 class TestGetAlias(tests.TestCase):
55