diff mercurial/help.py @ 14316:d5b525697ddb

extensions: drop maxlength from enabled and disabled This is a bad/silly API. Instead calculate maxlength in one place in help it's used and simplify all the callers.
author Matt Mackall <mpm@selenic.com>
date Fri, 13 May 2011 11:04:51 -0500
parents 135e244776f0
children 660b0c1b6196
line wrap: on
line diff
--- a/mercurial/help.py	Fri May 13 11:26:29 2011 +0200
+++ b/mercurial/help.py	Fri May 13 11:04:51 2011 -0500
@@ -43,10 +43,11 @@
 
     return ''.join(result)
 
-def listexts(header, exts, maxlength, indent=1):
+def listexts(header, exts, indent=1):
     '''return a text listing of the given extensions'''
     if not exts:
         return ''
+    maxlength = max(len(e) for e in exts)
     result = '\n%s\n\n' % header
     for name, desc in sorted(exts.iteritems()):
         result += '%s%-*s %s\n' % (' ' * indent, maxlength + 2,
@@ -55,13 +56,8 @@
 
 def extshelp():
     doc = loaddoc('extensions')()
-
-    exts, maxlength = extensions.enabled()
-    doc += listexts(_('enabled extensions:'), exts, maxlength)
-
-    exts, maxlength = extensions.disabled()
-    doc += listexts(_('disabled extensions:'), exts, maxlength)
-
+    doc += listexts(_('enabled extensions:'), extensions.enabled())
+    doc += listexts(_('disabled extensions:'), extensions.disabled())
     return doc
 
 def loaddoc(topic):