def _latest_entry_for_changelog_at_revision(self, changelog_path, revision): changelog_contents = self._scm.contents_at_revision(changelog_path, revision) # contents_at_revision returns a byte array (str()), but we know # that ChangeLog files are utf-8. parse_latest_entry_from_file # expects a file-like object which vends unicode(), so we decode here. changelog_file = StringIO.StringIO(changelog_contents.decode("utf-8")) return ChangeLog.parse_latest_entry_from_file(changelog_file)
def _latest_entry_for_changelog_at_revision(self, changelog_path, revision): changelog_contents = self._scm.contents_at_revision(changelog_path, revision) # contents_at_revision returns a byte array (str()), but we know # that ChangeLog files are utf-8. parse_latest_entry_from_file # expects a file-like object which vends unicode(), so we decode here. changelog_file = StringIO.StringIO(changelog_contents.decode("utf-8")) return ChangeLog.parse_latest_entry_from_file(changelog_file)
def test_latest_entry_parse_single_entry(self): changelog_contents = u"%s\n%s" % (self._example_entry, self._rolled_over_footer) changelog_file = StringIO(changelog_contents) latest_entry = ChangeLog.parse_latest_entry_from_file(changelog_file) self.assertEqual(latest_entry.contents(), self._example_entry) self.assertEqual(latest_entry.author_name(), "Peter Kasting")
def _latest_entry_for_changelog_at_revision(self, changelog_path, revision): changelog_contents = self._scm.contents_at_revision(changelog_path, revision) # contents_at_revision returns a byte array (str()), but we know # that ChangeLog files are utf-8. parse_latest_entry_from_file # expects a file-like object which vends unicode(), so we decode here. # Old revisions of Sources/WebKit/wx/ChangeLog have some invalid utf8 characters. changelog_file = StringIO.StringIO(changelog_contents.decode("utf-8", "ignore")) return ChangeLog.parse_latest_entry_from_file(changelog_file)
def test_latest_entry_parse(self): changelog_contents = u"%s\n%s" % (self._example_entry, self._example_changelog) changelog_file = StringIO(changelog_contents) latest_entry = ChangeLog.parse_latest_entry_from_file(changelog_file) self.assertEqual(latest_entry.contents(), self._example_entry) self.assertEqual(latest_entry.author_name(), "Peter Kasting") self.assertEqual(latest_entry.author_email(), "*****@*****.**") self.assertEqual(latest_entry.reviewer_text(), u"Fr\u00e9d\u00e9ric Wang") touched_files = [ "DumpRenderTree/win/DumpRenderTree.vcproj", "DumpRenderTree/win/ImageDiff.vcproj", "DumpRenderTree/win/TestNetscapePlugin/TestNetscapePlugin.vcproj" ] self.assertEqual(latest_entry.touched_files(), touched_files) self.assertEqual(latest_entry.touched_functions(), dict((f, []) for f in touched_files)) self.assertTrue(latest_entry.reviewer() ) # Make sure that our UTF8-based lookup of Tor works.
def _latest_entry_for_changelog_at_revision(self, changelog_path, revision): changelog_contents = self._scm.contents_at_revision(changelog_path, revision) return ChangeLog.parse_latest_entry_from_file(StringIO.StringIO(changelog_contents))