Title: [143504] trunk/Tools
Revision
143504
Author
t...@chromium.org
Date
2013-02-20 14:03:49 -0800 (Wed, 20 Feb 2013)

Log Message

Parse author names with commas in ChangeLogs
https://bugs.webkit.org/show_bug.cgi?id=110356

Reviewed by Dirk Pranke.

Paweł's name has a comma in it, which was confusing the ChangeLog parser.

* Scripts/webkitpy/common/checkout/changelog.py:
(ChangeLogEntry): Move name splitting regexp into a constant.
(ChangeLogEntry._parse_reviewer_text): Use _split_reviewer_names.
(ChangeLogEntry._split_reviewer_names): Rename to be more specific.
(ChangeLogEntry._split_author_names_with_emails): Rename to be more specific and require emails.
(ChangeLogEntry._parse_author_text): Use _split_author_names_with_emails.
* Scripts/webkitpy/common/checkout/changelog_unittest.py:
(test_parse_authors): Test case with Paweł's name.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (143503 => 143504)


--- trunk/Tools/ChangeLog	2013-02-20 21:56:27 UTC (rev 143503)
+++ trunk/Tools/ChangeLog	2013-02-20 22:03:49 UTC (rev 143504)
@@ -1,3 +1,21 @@
+2013-02-20  Tony Chang  <t...@chromium.org>
+
+        Parse author names with commas in ChangeLogs
+        https://bugs.webkit.org/show_bug.cgi?id=110356
+
+        Reviewed by Dirk Pranke.
+
+        Paweł's name has a comma in it, which was confusing the ChangeLog parser.
+
+        * Scripts/webkitpy/common/checkout/changelog.py:
+        (ChangeLogEntry): Move name splitting regexp into a constant.
+        (ChangeLogEntry._parse_reviewer_text): Use _split_reviewer_names.
+        (ChangeLogEntry._split_reviewer_names): Rename to be more specific.
+        (ChangeLogEntry._split_author_names_with_emails): Rename to be more specific and require emails.
+        (ChangeLogEntry._parse_author_text): Use _split_author_names_with_emails.
+        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
+        (test_parse_authors): Test case with Paweł's name.
+
 2013-02-15  Dirk Schulze  <k...@webkit.org>
 
         [Chromium] Add runtime flag for CanvasPath

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py (143503 => 143504)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2013-02-20 21:56:27 UTC (rev 143503)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py	2013-02-20 22:03:49 UTC (rev 143504)
@@ -104,6 +104,8 @@
     # e.g. git-svn-id: http://svn.webkit.org/repository/webkit/trunk@96161 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     svn_id_regexp = r'git-svn-id: http://svn.webkit.org/repository/webkit/trunk@(?P<svnid>\d+) '
 
+    split_names_regexp = r'\s*(?:,(?:\s+and\s+|&)?|(?:^|\s+)and\s+|&&|[/+&])\s*'
+
     def __init__(self, contents, committer_list=CommitterList(), revision=None):
         self._contents = contents
         self._committer_list = committer_list
@@ -131,7 +133,7 @@
         if not len(reviewer_text):
             return None, None
 
-        reviewer_list = ChangeLogEntry._split_contributor_names(reviewer_text)
+        reviewer_list = ChangeLogEntry._split_reviewer_names(reviewer_text)
 
         # Get rid of "reviewers" like "even though this is just a..." in "Reviewed by Sam Weinig, even though this is just a..."
         # and "who wrote the original code" in "Noam Rosenthal, who wrote the original code"
@@ -140,9 +142,17 @@
         return reviewer_text, reviewer_list
 
     @classmethod
-    def _split_contributor_names(cls, text):
-        return re.split(r'\s*(?:,(?:\s+and\s+|&)?|(?:^|\s+)and\s+|&&|[/+&])\s*', text)
+    def _split_reviewer_names(cls, text):
+        return re.split(ChangeLogEntry.split_names_regexp, text)
 
+    @classmethod
+    def _split_author_names_with_emails(cls, text):
+        regex = '>' + ChangeLogEntry.split_names_regexp
+        names = re.split(regex, text)
+        if len(names) > 1:
+            names = [name + ">" for name in names[:-1]] + [names[-1]]
+        return names
+
     def _fuzz_match_reviewers(self, reviewers_text_list):
         if not reviewers_text_list:
             return []
@@ -159,7 +169,7 @@
     def _parse_author_text(cls, text):
         if not text:
             return []
-        authors = cls._split_contributor_names(text)
+        authors = cls._split_author_names_with_emails(text)
         assert(authors and len(authors) >= 1)
         return [cls._parse_author_name_and_email(author) for author in authors]
 

Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py (143503 => 143504)


--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2013-02-20 21:56:27 UTC (rev 143503)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py	2013-02-20 22:03:49 UTC (rev 143504)
@@ -453,6 +453,10 @@
             [('New Contributor', 'n...@webkit.org'), ('Noob', 'n...@webkit.org')])
         self._assert_parse_authors('Adam Barth  <aba...@webkit.org> && Benjamin Poulain  <bpoul...@apple.com>',
             [('Adam Barth', 'aba...@webkit.org'), ('Benjamin Poulain', 'bpoul...@apple.com')])
+        self._assert_parse_authors(u'Pawe\u0142 Hajdan, Jr.  <phajdan...@chromium.org>',
+            [(u'Pawe\u0142 Hajdan, Jr.', u'phajdan...@chromium.org')])
+        self._assert_parse_authors(u'Pawe\u0142 Hajdan, Jr.  <phajdan...@chromium.org>, Adam Barth  <aba...@webkit.org>',
+            [(u'Pawe\u0142 Hajdan, Jr.', u'phajdan...@chromium.org'), (u'Adam Barth', u'aba...@webkit.org')])
 
     def _assert_has_valid_reviewer(self, reviewer_line, expected):
         self.assertEqual(self._entry_with_reviewer(reviewer_line).has_valid_reviewer(), expected)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to