Don't update author info in PrepareChangeLog and allow users to skip the PrepareChang...
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 00:30:22 +0000 (00:30 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 5 Feb 2013 00:30:22 +0000 (00:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=108788

Patch by Timothy Loh <timloh@chromium.com> on 2013-02-04
Reviewed by Ryosuke Niwa.

As per discussion in Bug 74358, it's probably preferable to remove the
behaviour of updating the author details in a ChangeLog entry. We also
want to be able to skip preparing change logs (e.g. rebaselining many
tests), so a --no-prepare-changelogs option is added to webkit-patch.

* Scripts/webkitpy/common/checkout/changelog.py:
(ChangeLogEntry._parse_entry):
(ChangeLogEntry.date): Added
* Scripts/webkitpy/common/checkout/changelog_unittest.py:
(test_parse_log_entries_from_changelog):
* Scripts/webkitpy/tool/commands/commandtest.py:
(CommandsTest.assert_execute_outputs):
* Scripts/webkitpy/tool/steps/options.py:
(Options): Added --no-prepare-changelogs
* Scripts/webkitpy/tool/steps/preparechangelog.py:
(PrepareChangeLog.options):
(PrepareChangeLog._merge_entries): date_line() gets the entire line, including
the author's name and email, but we only want to replace the date.
(PrepareChangeLog.run):
* Scripts/webkitpy/tool/steps/preparechangelog_unittest.py:
(PrepareChangeLogTest.test_resolve_existing_entry): Added tests for changed
authors. Removed unneeded variable.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@141829 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/common/checkout/changelog.py
Tools/Scripts/webkitpy/common/checkout/changelog_unittest.py
Tools/Scripts/webkitpy/tool/commands/commandtest.py
Tools/Scripts/webkitpy/tool/steps/options.py
Tools/Scripts/webkitpy/tool/steps/preparechangelog.py
Tools/Scripts/webkitpy/tool/steps/preparechangelog_unittest.py

index 39b34bf3d07a7dcdc4981eedbbcbce0556aa83b0..597c3700e517ddd995da785d565e651f5140939d 100644 (file)
@@ -1,3 +1,33 @@
+2013-02-04  Timothy Loh  <timloh@chromium.com>
+
+        Don't update author info in PrepareChangeLog and allow users to skip the PrepareChangeLog step entirely.
+        https://bugs.webkit.org/show_bug.cgi?id=108788
+
+        Reviewed by Ryosuke Niwa.
+
+        As per discussion in Bug 74358, it's probably preferable to remove the
+        behaviour of updating the author details in a ChangeLog entry. We also
+        want to be able to skip preparing change logs (e.g. rebaselining many
+        tests), so a --no-prepare-changelogs option is added to webkit-patch.
+
+        * Scripts/webkitpy/common/checkout/changelog.py:
+        (ChangeLogEntry._parse_entry):
+        (ChangeLogEntry.date): Added
+        * Scripts/webkitpy/common/checkout/changelog_unittest.py:
+        (test_parse_log_entries_from_changelog):
+        * Scripts/webkitpy/tool/commands/commandtest.py:
+        (CommandsTest.assert_execute_outputs):
+        * Scripts/webkitpy/tool/steps/options.py:
+        (Options): Added --no-prepare-changelogs
+        * Scripts/webkitpy/tool/steps/preparechangelog.py:
+        (PrepareChangeLog.options):
+        (PrepareChangeLog._merge_entries): date_line() gets the entire line, including
+        the author's name and email, but we only want to replace the date.
+        (PrepareChangeLog.run):
+        * Scripts/webkitpy/tool/steps/preparechangelog_unittest.py:
+        (PrepareChangeLogTest.test_resolve_existing_entry): Added tests for changed
+        authors. Removed unneeded variable.
+
 2013-02-04  Jochen Eisinger  <jochen@chromium.org>
 
         [chromium] Remove WebEventSender and WebAccessibilityController from public TestRunner API
index 4975b605449d57bbaa3437b19d6ed4cc51391534..5b60c2f4b5da222b741e91cd9cd2758cc86daf2f 100644 (file)
@@ -195,6 +195,7 @@ class ChangeLogEntry(object):
             _log.warning("Creating invalid ChangeLogEntry:\n%s" % self._contents)
 
         self._date_line = match.group()
+        self._date = match.group("date")
         self._bug_description = self._parse_bug_description(self._contents)
 
         # FIXME: group("name") does not seem to be Unicode?  Probably due to self._contents not being unicode.
@@ -211,6 +212,9 @@ class ChangeLogEntry(object):
     def date_line(self):
         return self._date_line
 
+    def date(self):
+        return self._date
+
     def author_text(self):
         return self._author_text
 
index c18a8467f006ac197e54be5f0e58710b46107227..38ef290c143ba57ebf96742b95db4ebc3bb7af29 100644 (file)
@@ -237,8 +237,11 @@ class ChangeLogTest(unittest.TestCase):
         parsed_entries = list(ChangeLog.parse_entries_from_file(changelog_file))
         self.assertEqual(len(parsed_entries), 9)
         self.assertEqual(parsed_entries[0].date_line(), u"2009-08-17  Tor Arne Vestb\xf8  <vestbo@webkit.org>")
+        self.assertEqual(parsed_entries[0].date(), "2009-08-17")
         self.assertEqual(parsed_entries[0].reviewer_text(), "David Levin")
         self.assertEqual(parsed_entries[0].is_touched_files_text_clean(), False)
+        self.assertEqual(parsed_entries[1].date_line(), "2009-08-16  David Kilzer  <ddkilzer@apple.com>")
+        self.assertEqual(parsed_entries[1].date(), "2009-08-16")
         self.assertEqual(parsed_entries[1].author_email(), "ddkilzer@apple.com")
         self.assertEqual(parsed_entries[1].touched_files_text(), "        * Scripts/bugzilla-tool:\n        * Scripts/modules/scm.py:\n")
         self.assertEqual(parsed_entries[1].is_touched_files_text_clean(), True)
index 65f45b58f04eac7f323a32e599f9ff5ccc4182ab..6d009bcca9ff02e8fea6932bac9331bed2757552 100644 (file)
@@ -42,6 +42,7 @@ class CommandsTest(TestCase):
         options.obsolete_patches = True
         options.open_bug = True
         options.port = 'MOCK port'
+        options.prepare_changelogs = True
         options.quiet = True
         options.reviewer = 'MOCK reviewer'
         command.bind_to_tool(tool)
index 46c8690187b1cae52bf4cfeaa8d8e40b4aad877d..05204fa166a85379a1c53587d3c909d51031cab4 100644 (file)
@@ -49,6 +49,7 @@ class Options(object):
     obsolete_patches = make_option("--no-obsolete", action="store_false", dest="obsolete_patches", default=True, help="Do not obsolete old patches before posting this one.")
     open_bug = make_option("--open-bug", action="store_true", dest="open_bug", default=False, help="Opens the associated bug in a browser.")
     parent_command = make_option("--parent-command", action="store", dest="parent_command", default=None, help="(Internal) The command that spawned this instance.")
+    prepare_changelogs = make_option("--no-prepare-changelogs", action="store_false", dest="prepare_changelogs", default=True, help="Don't prepare (create and/or update) ChangeLogs.")
     quiet = make_option("--quiet", action="store_true", dest="quiet", default=False, help="Produce less console output.")
     request_commit = make_option("--request-commit", action="store_true", dest="request_commit", default=False, help="Mark the patch as needing auto-commit after review.")
     review = make_option("--no-review", action="store_false", dest="review", default=True, help="Do not mark the patch for review.")
index 5a052ee6a294014b6c2881b1c4fc9f7820a4401d..9262903bac44c2ce1ed7b594ea2f68a9737dfc5c 100644 (file)
@@ -45,6 +45,7 @@ class PrepareChangeLog(AbstractStep):
             Options.quiet,
             Options.email,
             Options.git_commit,
+            Options.prepare_changelogs,
         ]
 
     def _ensure_bug_url(self, state):
@@ -83,10 +84,7 @@ class PrepareChangeLog(AbstractStep):
     def _merge_entries(self, old_entry, new_entry):
         final_entry = old_entry.contents()
 
-        new_date_line = new_entry.date_line()
-        old_date_line = old_entry.date_line()
-        if new_date_line != old_date_line:
-            final_entry = final_entry.replace(old_date_line, new_date_line)
+        final_entry = final_entry.replace(old_entry.date(), new_entry.date(), 1)
 
         new_bug_desc = new_entry.bug_description()
         old_bug_desc = old_entry.bug_description()
@@ -104,6 +102,9 @@ class PrepareChangeLog(AbstractStep):
         return final_entry + "\n"
 
     def run(self, state):
+        if not self._options.prepare_changelogs:
+            return
+
         if self.cached_lookup(state, "changelogs"):
             self._ensure_bug_url(state)
 
index a703ca2ec6eada1c57a0861985790b2742a623dc..803f072a30922bc0b1ff28ea595234ed6a31683c 100644 (file)
@@ -40,12 +40,12 @@ class PrepareChangeLogTest(changelog_unittest.ChangeLogTest):
     def test_resolve_existing_entry(self):
         step = PrepareChangeLog(MockTool(), MockOptions())
 
-        roll_over = "== Rolled over to ChangeLog-2012-10-02 =="
-
         headers = ["2013-01-18  Timothy Loh  <timloh@chromium.com>\n\n",
                    "2013-01-20  Timothy Loh  <timloh@chromium.com>\n\n",
                   u"2009-08-17  Tor Arne Vestb\xf8  <vestbo@webkit.org>\n\n",
                   u"2009-08-18  Tor Arne Vestb\xf8  <vestbo@webkit.org>\n\n",
+                   "2013-01-18  Eric Seidel  <eric@webkit.org>\n\n",
+                   "2013-01-20  Eric Seidel  <eric@webkit.org>\n\n",
                   ]
 
         bug_descs = ["        prepare-Changelog should support updating the list of changed files\n",
@@ -93,15 +93,19 @@ class PrepareChangeLogTest(changelog_unittest.ChangeLogTest):
                       ((0, 0, 0, 1), (0, 0, 1, 2), (0, 0, 1, 3)),
                       ((1, 1, 0, 1), (0, 0, 0, 2), (1, 1, 0, 3)),
                       ((3, 0, 0, 0), (2, 0, 1, 0), (3, 0, 1, 0)),
+                      ((4, 0, 0, 0), (0, 0, 0, 0), (0, 0, 0, 0)),
+                      ((5, 0, 0, 0), (0, 0, 0, 0), (1, 0, 0, 0)),
+                      ((0, 0, 0, 0), (4, 0, 0, 0), (4, 0, 0, 0)),
+                      ((1, 0, 0, 0), (4, 0, 0, 0), (5, 0, 0, 0)),
         ]
 
         for new, old, final in test_cases:
             new_entry = make_entry(new)
             old_entry = make_entry(old)
-            start_file = new_entry + old_entry + roll_over
+            start_file = new_entry + old_entry + self._rolled_over_footer
 
             final_entry = make_entry(final)
-            end_file = final_entry + roll_over
+            end_file = final_entry + self._rolled_over_footer
 
             path = "ChangeLog"
             step._tool.filesystem = MockFileSystem()