[SCM] WebKit Debian packaging branch, webkit-1.2, updated. upstream/1.1.90-6072-g9a69373

eric at webkit.org eric at webkit.org
Wed Apr 7 23:50:16 UTC 2010


The following commit has been merged in the webkit-1.2 branch:
commit 17d8063e8466c320c6bb67a6330db9bcc339d476
Author: eric at webkit.org <eric at webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Thu Nov 19 23:21:03 2009 +0000

    2009-11-19  Eric Seidel  <eric at webkit.org>
    
            Reviewed by Adam Barth.
    
            Re-factor help printing to use modern python idioms
            https://bugs.webkit.org/show_bug.cgi?id=31685
    
            * Scripts/bugzilla-tool:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51208 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index abc850f..c4000eb 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,5 +1,14 @@
 2009-11-19  Eric Seidel  <eric at webkit.org>
 
+        Reviewed by Adam Barth.
+
+        Re-factor help printing to use modern python idioms
+        https://bugs.webkit.org/show_bug.cgi?id=31685
+
+        * Scripts/bugzilla-tool:
+
+2009-11-19  Eric Seidel  <eric at webkit.org>
+
         Reviewed by Darin Adler.
 
         commit-queue empty queue logs twice
diff --git a/WebKitTools/Scripts/bugzilla-tool b/WebKitTools/Scripts/bugzilla-tool
index b1871d4..0c274a8 100755
--- a/WebKitTools/Scripts/bugzilla-tool
+++ b/WebKitTools/Scripts/bugzilla-tool
@@ -89,7 +89,7 @@ class Command:
         self.options = options
         self.option_parser = HelpPrintingOptionParser(usage=SUPPRESS_USAGE, add_help_option=False, option_list=self.options)
         self.requires_local_commits = requires_local_commits
-    
+
     def name_with_arguments(self, command_name):
         usage_string = command_name
         if len(self.options) > 0:
@@ -903,29 +903,35 @@ class BugzillaTool:
     def usage_line():
         return "Usage: %prog [options] command [command-options] [command-arguments]"
 
-    def commands_usage(self):
-        commands_text = "Commands:\n"
-        longest_name_length = 0
-        command_rows = []
-        scm_supports_local_commits = self.scm().supports_local_commits()
-        for command in self.commands:
-            command_object = command["object"]
-            if command_object.requires_local_commits and not scm_supports_local_commits:
-                continue
-            command_name_and_args = command_object.name_with_arguments(command["name"])
-            command_rows.append({ "name-and-args": command_name_and_args, "object": command_object })
-            longest_name_length = max([longest_name_length, len(command_name_and_args)])
-        
+    # FIXME: This can all be simplified once Command objects know their own names.
+    @staticmethod
+    def _name_and_arguments(command):
+        return command['object'].name_with_arguments(command["name"])
+
+    def _command_help_formatter(self):
         # Use our own help formatter so as to indent enough.
         formatter = IndentedHelpFormatter()
         formatter.indent()
         formatter.indent()
-        
-        for row in command_rows:
-            command_object = row["object"]
-            commands_text += "  " + row["name-and-args"].ljust(longest_name_length + 3) + command_object.help_text + "\n"
-            commands_text += command_object.option_parser.format_option_help(formatter)
-        return commands_text
+        return formatter
+
+    @classmethod
+    def _help_for_command(cls, command, formatter, longest_name_length):
+        help_text = "  " + cls._name_and_arguments(command).ljust(longest_name_length + 3) + command['object'].help_text + "\n"
+        help_text += command['object'].option_parser.format_option_help(formatter)
+        return help_text
+
+    def commands_usage(self):
+        if not self.scm().supports_local_commits():
+            command_filter = lambda command: not command["object"].requires_local_commits
+        else:
+            command_filter = None
+
+        # Only show commands which are relevant to this checkout.  This might be confusing to some users?
+        relevant_commands = filter(command_filter, self.commands)
+        longest_name_length = max(map(lambda command: len(self._name_and_arguments(command)), relevant_commands))
+        command_help_texts = map(lambda command: self._help_for_command(command, self._command_help_formatter(), longest_name_length), relevant_commands)
+        return "Commands:\n" + "".join(command_help_texts)
 
     def handle_global_args(self, args):
         (options, args) = self.global_option_parser.parse_args(args)
@@ -967,7 +973,7 @@ class BugzillaTool:
         
         if not command_name:
             self.global_option_parser.error("No command specified")
-        
+
         command = self.command_by_name(command_name)
         if not command:
             self.global_option_parser.error(command_name + " is not a recognized command")

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list