Changeset 75769 in webkit


Ignore:
Timestamp:
Jan 13, 2011 9:40:18 PM (13 years ago)
Author:
eric@webkit.org
Message:

2011-01-13 Eric Seidel <eric@webkit.org>

Reviewed by David Levin.

webkit-patch suggest-reviewers dies when ChangeLogs are missing
https://bugs.webkit.org/show_bug.cgi?id=49158

This is not the most elegant, but it is a very safe fix to this bug.
One advantage of catching ScriptError like this instead of adding a
new added_or_modified_files or fixing all changed_files callers
to use a more specific change_files variant, is that we catch
all kinds of ScriptErrors which might cause our (non-essential)
suggest-reviewers code to fail out. This should make passing
--suggest-reviewers to webkit-patch upload much more robust
and may even make it possible for us to make it default.

The root of the problem here is that SCM.changed_files includes
deleted ChangeLog paths (from moves, etc) which then when we ask
SVN/Git for the contents of the file at that revision, the command
errors out and Executive.run_command raises a ScriptError.

In the future we might fix this differently by making all current
callers of chagned_files use a more specific method for requesting
what types of changes they're interested in (adds, modifies, deletes, etc.)

  • Scripts/webkitpy/common/checkout/api.py:
  • Scripts/webkitpy/common/checkout/api_unittest.py:
Location:
trunk/Tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r75768 r75769  
     12011-01-13  Eric Seidel  <eric@webkit.org>
     2
     3        Reviewed by David Levin.
     4
     5        webkit-patch suggest-reviewers dies when ChangeLogs are missing
     6        https://bugs.webkit.org/show_bug.cgi?id=49158
     7
     8        This is not the most elegant, but it is a very safe fix to this bug.
     9        One advantage of catching ScriptError like this instead of adding a
     10        new added_or_modified_files or fixing all changed_files callers
     11        to use a more specific change_files variant, is that we catch
     12        all kinds of ScriptErrors which might cause our (non-essential)
     13        suggest-reviewers code to fail out.  This should make passing
     14        --suggest-reviewers to webkit-patch upload much more robust
     15        and may even make it possible for us to make it default.
     16
     17        The root of the problem here is that SCM.changed_files includes
     18        deleted ChangeLog paths (from moves, etc) which then when we ask
     19        SVN/Git for the contents of the file at that revision, the command
     20        errors out and Executive.run_command raises a ScriptError.
     21
     22        In the future we might fix this differently by making all current
     23        callers of chagned_files use a more specific method for requesting
     24        what types of changes they're interested in (adds, modifies, deletes, etc.)
     25
     26        * Scripts/webkitpy/common/checkout/api.py:
     27        * Scripts/webkitpy/common/checkout/api_unittest.py:
     28
    1292011-01-13  Dan Bernstein  <mitz@apple.com>
    230
  • trunk/Tools/Scripts/webkitpy/common/checkout/api.py

    r75761 r75769  
    6363        # FIXME: This gets confused if ChangeLog files are moved, as
    6464        # deletes are still "changed files" per changed_files_for_revision.
    65         return [self._latest_entry_for_changelog_at_revision(path, revision) for path in changed_files if self.is_path_to_changelog(path)]
     65        # FIXME: For now we hack around this by caching any exceptions
     66        # which result from having deleted files included the changed_files list.
     67        changelog_entries = []
     68        for path in changed_files:
     69            if not self.is_path_to_changelog(path):
     70                continue
     71            try:
     72                changelog_entries.append(self._latest_entry_for_changelog_at_revision(path, revision))
     73            except ScriptError:
     74                pass
     75        return changelog_entries
    6676
    6777    @memoized
  • trunk/Tools/Scripts/webkitpy/common/checkout/api_unittest.py

    r75761 r75769  
    3939from webkitpy.common.checkout.scm import detect_scm_system, CommitMessage
    4040from webkitpy.common.system.outputcapture import OutputCapture
     41from webkitpy.common.system.executive import ScriptError
    4142from webkitpy.thirdparty.mock import Mock
    4243
     
    139140        self.assertEqual(entry.contents(), _changelog1entry1)
    140141
     142    # FIXME: This tests a hack around our current changed_files handling.
     143    # Right now changelog_entries_for_revision tries to fetch deleted files
     144    # from revisions, resulting in a ScriptError exception.  Test that we
     145    # recover from those and still return the other ChangeLog entries.
     146    def test_changelog_entries_for_revision(self):
     147        scm = Mock()
     148        scm.changed_files_for_revision = lambda revision: ['foo/ChangeLog', 'bar/ChangeLog']
     149        checkout = Checkout(scm)
     150
     151        def mock_latest_entry_for_changelog_at_revision(path, revision):
     152            if path == "foo/ChangeLog":
     153                return 'foo'
     154            raise ScriptError()
     155
     156        checkout._latest_entry_for_changelog_at_revision = mock_latest_entry_for_changelog_at_revision
     157
     158        # Even though fetching one of the entries failed, the other should succeed.
     159        entries = checkout.changelog_entries_for_revision(1)
     160        self.assertEqual(len(entries), 1)
     161        self.assertEqual(entries[0], 'foo')
     162
    141163    def test_commit_info_for_revision(self):
    142164        scm = Mock()
Note: See TracChangeset for help on using the changeset viewer.