[PATCH 1 of 4] help: remove dependency on ui from some helper functions

Olav Reinert seroton10 at gmail.com
Tue May 22 15:11:40 CDT 2012


# HG changeset patch
# User Olav Reinert <seroton10 at gmail.com>
# Date 1337717321 -7200
# Node ID dc0f31ff7a90acf5e2c71a9f17f873c9926224bf
# Parent  d0b9ebba41e9a1733294d5fa1b497ada5eda93c8
help: remove dependency on ui from some helper functions

diff -r d0b9ebba41e9 -r dc0f31ff7a90 mercurial/commands.py
--- a/mercurial/commands.py	Sun May 20 14:40:36 2012 -0500
+++ b/mercurial/commands.py	Tue May 22 22:08:41 2012 +0200
@@ -3089,7 +3089,7 @@
 
     textwidth = min(ui.termwidth(), 80) - 2
 
-    def optrst(options):
+    def optrst(options, verbose):
         data = []
         multioccur = False
         for option in options:
@@ -3099,7 +3099,7 @@
                 shortopt, longopt, default, desc = option
                 optlabel = _("VALUE") # default label
 
-            if _("DEPRECATED") in desc and not ui.verbose:
+            if _("DEPRECATED") in desc and not verbose:
                 continue
 
             so = ''
@@ -3125,7 +3125,7 @@
         return rst
 
     # list all option lists
-    def opttext(optlist, width):
+    def opttext(optlist, width, verbose):
         rst = ''
         if not optlist:
             return ''
@@ -3134,7 +3134,7 @@
             rst += '\n%s\n' % title
             if options:
                 rst += "\n"
-                rst += optrst(options)
+                rst += optrst(options, verbose)
                 rst += '\n'
 
         return '\n' + minirst.format(rst, width)
@@ -3223,13 +3223,13 @@
             rst += '\n'
             rst += _("options:")
             rst += '\n\n'
-            rst += optrst(entry[1])
+            rst += optrst(entry[1], ui.verbose)
 
         if ui.verbose:
             rst += '\n'
             rst += _("global options:")
             rst += '\n\n'
-            rst += optrst(globalopts)
+            rst += optrst(globalopts, ui.verbose)
 
         keep = ui.verbose and ['verbose'] or []
         formatted, pruned = minirst.format(rst, textwidth, keep=keep)
@@ -3304,7 +3304,7 @@
 
         optlist = []
         addglobalopts(optlist, True)
-        ui.write(opttext(optlist, textwidth))
+        ui.write(opttext(optlist, textwidth, ui.verbose))
 
     def helptopic(name):
         for names, header, doc in help.helptable:


More information about the Mercurial-devel mailing list