changeset 16884:4fd1f1d7569b

help: fix 'hg help -k' matching an extension without docs getattr is not needed, __doc__ always exists and defaults to None
author Thomas Arendsen Hein <thomas@intevation.de>
date Thu, 07 Jun 2012 15:54:40 +0200
parents 2255950e1f76
children d628bcb3a567
files mercurial/help.py tests/test-help.t
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/help.py	Wed Jun 06 21:17:33 2012 -0500
+++ b/mercurial/help.py	Thu Jun 07 15:54:40 2012 +0200
@@ -107,8 +107,11 @@
         for cmd, entry in getattr(mod, 'cmdtable', {}).iteritems():
             if kw in cmd or (len(entry) > 2 and lowercontains(entry[2])):
                 cmdname = cmd.split('|')[0].lstrip('^')
-                cmddoc=getattr(mod, '__doc__', '').splitlines()[0]
-                results['extensioncommands'].append((cmdname, _(cmddoc)))
+                if mod.__doc__:
+                    cmddoc = gettext(mod.__doc__).splitlines()[0]
+                else:
+                    cmddoc = _('(no help text available)')
+                results['extensioncommands'].append((cmdname, cmddoc))
     return results
 
 def loaddoc(topic):
--- a/tests/test-help.t	Wed Jun 06 21:17:33 2012 -0500
+++ b/tests/test-help.t	Thu Jun 07 15:54:40 2012 +0200
@@ -598,6 +598,15 @@
   
   use "hg -v help nohelp" to show more info
 
+  $ hg help -k nohelp
+  Commands:
+  
+   nohelp hg nohelp
+  
+  Extension Commands:
+  
+   nohelp (no help text available)
+
 Test that default list of commands omits extension commands
 
   $ hg help