Title: [95549] trunk/Tools
- Revision
- 95549
- Author
- [email protected]
- Date
- 2011-09-20 09:45:34 -0700 (Tue, 20 Sep 2011)
Log Message
Changelog class should have a method to return all entries
https://bugs.webkit.org/show_bug.cgi?id=68399
Implement ChangeLog.parse_entries_from_file(). This method returns a generator
of ChangeLogEntry objects, ordered from the latest to the oldest entry in the file.
Patch by Leandro Pereira <[email protected]> on 2011-09-20
Reviewed by Ryosuke Niwa.
* Scripts/webkitpy/common/checkout/changelog.py: Copy parse_latest_entry_from_file()
and adapt it to become a generator.
* Scripts/webkitpy/common/checkout/changelog_unittest.py: Add test case.
Modified Paths
Diff
Modified: trunk/Tools/ChangeLog (95548 => 95549)
--- trunk/Tools/ChangeLog 2011-09-20 16:41:59 UTC (rev 95548)
+++ trunk/Tools/ChangeLog 2011-09-20 16:45:34 UTC (rev 95549)
@@ -1,3 +1,17 @@
+2011-09-20 Leandro Pereira <[email protected]>
+
+ Changelog class should have a method to return all entries
+ https://bugs.webkit.org/show_bug.cgi?id=68399
+
+ Implement ChangeLog.parse_entries_from_file(). This method returns a generator
+ of ChangeLogEntry objects, ordered from the latest to the oldest entry in the file.
+
+ Reviewed by Ryosuke Niwa.
+
+ * Scripts/webkitpy/common/checkout/changelog.py: Copy parse_latest_entry_from_file()
+ and adapt it to become a generator.
+ * Scripts/webkitpy/common/checkout/changelog_unittest.py: Add test case.
+
2011-09-20 Jarred Nicholls <[email protected]>
[Qt] Permit qrc resources to load in QWebSettings::setUserStyleSheetUrl()
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py (95548 => 95549)
--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py 2011-09-20 16:41:59 UTC (rev 95548)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog.py 2011-09-20 16:45:34 UTC (rev 95549)
@@ -160,6 +160,28 @@
entry_lines.append(line)
return None # We never found a date line!
+ @staticmethod
+ def parse_entries_from_file(changelog_file):
+ """changelog_file must be a file-like object which returns
+ unicode strings. Use codecs.open or StringIO(unicode())
+ to pass file objects to this class."""
+ date_line_regexp = re.compile(ChangeLogEntry.date_line_regexp)
+ rolled_over_regexp = re.compile(ChangeLogEntry.rolled_over_regexp)
+ entry_lines = []
+ # The first line should be a date line.
+ first_line = changelog_file.readline()
+ assert(isinstance(first_line, unicode))
+ if not date_line_regexp.match(first_line):
+ raise StopIteration
+ entry_lines.append(first_line)
+
+ for line in changelog_file:
+ if date_line_regexp.match(line) or rolled_over_regexp.match(line):
+ # Remove the extra newline at the end
+ yield ChangeLogEntry(''.join(entry_lines[:-1]))
+ entry_lines = []
+ entry_lines.append(line)
+
def latest_entry(self):
# ChangeLog files are always UTF-8, we read them in as such to support Reviewers with unicode in their names.
changelog_file = codecs.open(self.path, "r", "utf-8")
Modified: trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py (95548 => 95549)
--- trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py 2011-09-20 16:41:59 UTC (rev 95548)
+++ trunk/Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py 2011-09-20 16:45:34 UTC (rev 95549)
@@ -153,6 +153,13 @@
self.assertEquals(57354, parse_bug_id_from_changelog(commit_text))
+ def test_parse_log_entries_from_changelog(self):
+ parsed_entries = list(ChangeLog.parse_entries_from_changelog(ChangeLogTest._example_changelog))
+ self.assertEquals(len(parsed_entries), 3)
+ self.assertEquals(parsed_entries[0].reviewer(), 'David Levin')
+ self.assertEquals(parsed_entries[1].author_email(), '[email protected]')
+ self.assertEquals(parsed_entries[2].touched_files(), ['DumpRenderTree/mac/DumpRenderTreeWindow.mm'])
+
def test_latest_entry_parse(self):
changelog_contents = u"%s\n%s" % (self._example_entry, self._example_changelog)
changelog_file = StringIO(changelog_contents)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes