Title: [149480] trunk/Tools
Revision
149480
Author
[email protected]
Date
2013-05-01 19:10:25 -0700 (Wed, 01 May 2013)

Log Message

[webkitpy] Need abstract base class for commands that analyze commit logs
https://bugs.webkit.org/show_bug.cgi?id=115391

Reviewed by Benjamin Poulain.

Move commit log parsing functions into new abstract base class AbstractCommitLogCommand
in preparation for adding two new commands that will reuse this functionality along with
suggest-nominations. See https://bugs.webkit.org/show_bug.cgi?id=115387 and
https://bugs.webkit.org/show_bug.cgi?id=115388.

No new tests as this patch does not change existing functionality or behavior.

* Scripts/webkitpy/tool/commands/suggestnominations.py:
(AbstractCommitLogCommand): Add abstract base class for commands that analyze commit logs.
(AbstractCommitLogCommand.__init__):
(AbstractCommitLogCommand._init_options):
(AbstractCommitLogCommand._parse_commit_message):
(SuggestNominations): Move generic commit log parsing into new base class. Use new base class.
(SuggestNominations.__init__):
(SuggestNominations._init_options):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (149479 => 149480)


--- trunk/Tools/ChangeLog	2013-05-02 02:01:43 UTC (rev 149479)
+++ trunk/Tools/ChangeLog	2013-05-02 02:10:25 UTC (rev 149480)
@@ -1,3 +1,26 @@
+2013-05-01  Glenn Adams  <[email protected]>
+
+        [webkitpy] Need abstract base class for commands that analyze commit logs
+        https://bugs.webkit.org/show_bug.cgi?id=115391
+
+        Reviewed by Benjamin Poulain.
+
+        Move commit log parsing functions into new abstract base class AbstractCommitLogCommand
+        in preparation for adding two new commands that will reuse this functionality along with
+        suggest-nominations. See https://bugs.webkit.org/show_bug.cgi?id=115387 and
+        https://bugs.webkit.org/show_bug.cgi?id=115388.
+
+        No new tests as this patch does not change existing functionality or behavior.
+
+        * Scripts/webkitpy/tool/commands/suggestnominations.py:
+        (AbstractCommitLogCommand): Add abstract base class for commands that analyze commit logs.
+        (AbstractCommitLogCommand.__init__):
+        (AbstractCommitLogCommand._init_options):
+        (AbstractCommitLogCommand._parse_commit_message):
+        (SuggestNominations): Move generic commit log parsing into new base class. Use new base class.
+        (SuggestNominations.__init__): 
+        (SuggestNominations._init_options):
+
 2013-05-01  Seokju Kwon  <[email protected]>
 
         Web Inspector: Fix check-inspector-strings script and fix localized strings

Modified: trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py (149479 => 149480)


--- trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py	2013-05-02 02:01:43 UTC (rev 149479)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/suggestnominations.py	2013-05-02 02:10:25 UTC (rev 149480)
@@ -46,10 +46,7 @@
         CommitLogError.__init__(self)
 
 
-class SuggestNominations(Command):
-    name = "suggest-nominations"
-    help_text = "Suggest contributors for committer/reviewer nominations"
-
+class AbstractCommitLogCommand(Command):
     _leading_indent_regexp = re.compile(r"^[ ]{4}", re.MULTILINE)
     _reviewed_by_regexp = re.compile(ChangeLogEntry.reviewed_by_regexp, re.MULTILINE)
     _patch_by_regexp = re.compile(r'^Patch by (?P<name>.+?)\s+<(?P<email>[^<>]+)> on (?P<date>\d{4}-\d{2}-\d{2})$', re.MULTILINE)
@@ -57,23 +54,19 @@
     _date_regexp = re.compile(r'^Date:   (?P<date>\d{4}-\d{2}-\d{2}) (?P<time>\d{2}:\d{2}:\d{2}) [\+\-]\d{4}$', re.MULTILINE)
     _revision_regexp = re.compile(r'^git-svn-id: http://svn.webkit.org/repository/webkit/trunk@(?P<svnid>\d+) (?P<gitid>[0-9a-f\-]{36})$', re.MULTILINE)
 
-    def __init__(self):
-        options = [
-            make_option("--committer-minimum", action="" dest="committer_minimum", type="int", default=10, help="Specify minimum patch count for Committer nominations."),
-            make_option("--reviewer-minimum", action="" dest="reviewer_minimum", type="int", default=80, help="Specify minimum patch count for Reviewer nominations."),
-            make_option("--max-commit-age", action="" dest="max_commit_age", type="int", default=9, help="Specify max commit age to consider for nominations (in months)."),
-            make_option("--show-commits", action="" dest="show_commits", default=False, help="Show commit history with nomination suggestions."),
+    def __init__(self, options=None):
+        options = options or []
+        options += [
+            make_option("--max-commit-age", action="" dest="max_commit_age", type="int", default=9, help="Specify maximum commit age to consider (in months)."),
         ]
-        super(SuggestNominations, self).__init__(options=options)
+        options = sorted(options, cmp=lambda a, b: cmp(a._long_opts, b._long_opts))
+        super(AbstractCommitLogCommand, self).__init__(options=options)
         # FIXME: This should probably be on the tool somewhere.
         self._committer_list = CommitterList()
 
     def _init_options(self, options):
-        self.committer_minimum = options.committer_minimum
-        self.reviewer_minimum = options.reviewer_minimum
+        self.verbose = options.verbose
         self.max_commit_age = options.max_commit_age
-        self.show_commits = options.show_commits
-        self.verbose = options.verbose
 
     # FIXME: This should move to scm.py
     def _recent_commit_messages(self):
@@ -150,6 +143,25 @@
             'reviewers': reviewers,
         }
 
+
+class SuggestNominations(AbstractCommitLogCommand):
+    name = "suggest-nominations"
+    help_text = "Suggest contributors for committer/reviewer nominations"
+
+    def __init__(self):
+        options = [
+            make_option("--committer-minimum", action="" dest="committer_minimum", type="int", default=10, help="Specify minimum patch count for Committer nominations."),
+            make_option("--reviewer-minimum", action="" dest="reviewer_minimum", type="int", default=80, help="Specify minimum patch count for Reviewer nominations."),
+            make_option("--show-commits", action="" dest="show_commits", default=False, help="Show commit history with nomination suggestions."),
+        ]
+        super(SuggestNominations, self).__init__(options=options)
+
+    def _init_options(self, options):
+        super(SuggestNominations, self)._init_options(options)
+        self.committer_minimum = options.committer_minimum
+        self.reviewer_minimum = options.reviewer_minimum
+        self.show_commits = options.show_commits
+
     def _count_commit(self, commit, analysis):
         author_name = commit['author_name']
         author_email = commit['author_email']
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to