Changeset 70059 in webkit


Ignore:
Timestamp:
Oct 19, 2010 8:21:01 AM (14 years ago)
Author:
abarth@webkit.org
Message:

2010-10-19 Adam Barth <abarth@webkit.org>

Reviewed by Eric Seidel.

webkit-patch stats the filesystem too many times
https://bugs.webkit.org/show_bug.cgi?id=47883

This patch attempts to cache the list of changed files more agressively
and to use that list to compute the diff instead of stating the file
system again.

  • Scripts/webkitpy/common/checkout/api.py:
  • Scripts/webkitpy/common/checkout/scm.py:
  • Scripts/webkitpy/tool/mocktool.py:
  • Scripts/webkitpy/tool/steps/abstractstep.py:
  • Scripts/webkitpy/tool/steps/editchangelog.py:
  • Scripts/webkitpy/tool/steps/preparechangelog.py:
Location:
trunk/WebKitTools
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r70057 r70059  
     12010-10-19  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        webkit-patch stats the filesystem too many times
     6        https://bugs.webkit.org/show_bug.cgi?id=47883
     7
     8        This patch attempts to cache the list of changed files more agressively
     9        and to use that list to compute the diff instead of stating the file
     10        system again.
     11
     12        * Scripts/webkitpy/common/checkout/api.py:
     13        * Scripts/webkitpy/common/checkout/scm.py:
     14        * Scripts/webkitpy/tool/mocktool.py:
     15        * Scripts/webkitpy/tool/steps/abstractstep.py:
     16        * Scripts/webkitpy/tool/steps/editchangelog.py:
     17        * Scripts/webkitpy/tool/steps/preparechangelog.py:
     18
    1192010-10-19  David Kilzer  <ddkilzer@apple.com>
    220
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/api.py

    r70023 r70059  
    8484        return self.commit_info_for_revision(revision).bug_id()
    8585
    86     def _modified_files_matching_predicate(self, git_commit, predicate):
     86    def _modified_files_matching_predicate(self, git_commit, predicate, changed_files=None):
    8787        # SCM returns paths relative to scm.checkout_root
    8888        # Callers (especially those using the ChangeLog class) may
    8989        # expect absolute paths, so this method returns absolute paths.
    90         changed_files = self._scm.changed_files(git_commit)
     90        if not changed_files:
     91            changed_files = self._scm.changed_files(git_commit)
    9192        absolute_paths = [os.path.join(self._scm.checkout_root, path) for path in changed_files]
    9293        return [path for path in absolute_paths if predicate(path)]
    9394
    94     def modified_changelogs(self, git_commit):
    95         return self._modified_files_matching_predicate(git_commit, self._is_path_to_changelog)
     95    def modified_changelogs(self, git_commit, changed_files=None):
     96        return self._modified_files_matching_predicate(git_commit, self._is_path_to_changelog, changed_files=changed_files)
    9697
    97     def modified_non_changelogs(self, git_commit):
    98         return self._modified_files_matching_predicate(git_commit, lambda path: not self._is_path_to_changelog(path))
     98    def modified_non_changelogs(self, git_commit, changed_files=None):
     99        return self._modified_files_matching_predicate(git_commit, lambda path: not self._is_path_to_changelog(path), changed_files=changed_files)
    99100
    100101    def commit_message_for_this_commit(self, git_commit):
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py

    r70020 r70059  
    261261        self._subclass_must_implement()
    262262
    263     def create_patch(self, git_commit=None):
     263    def create_patch(self, git_commit=None, changed_files=[]):
    264264        self._subclass_must_implement()
    265265
     
    458458
    459459    # FIXME: This method should be on Checkout.
    460     def create_patch(self, git_commit=None):
     460    def create_patch(self, git_commit=None, changed_files=[]):
    461461        """Returns a byte array (str()) representing the patch file.
    462462        Patch files are effectively binary since they may contain
    463463        files of multiple different encodings."""
    464         return self.run([self.script_path("svn-create-patch")],
     464        return self.run([self.script_path("svn-create-patch")] + changed_files,
    465465            cwd=self.checkout_root, return_stderr=False,
    466466            decode_output=False)
     
    690690        return "git"
    691691
    692     def create_patch(self, git_commit=None):
     692    def create_patch(self, git_commit=None, changed_files=[]):
    693693        """Returns a byte array (str()) representing the patch file.
    694694        Patch files are effectively binary since they may contain
    695695        files of multiple different encodings."""
    696696        # FIXME: This should probably use cwd=self.checkout_root
    697         return self.run(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit)], decode_output=False)
     697        return self.run(['git', 'diff', '--binary', "--no-ext-diff", "--full-index", "-M", self.merge_base(git_commit)] + changed_files, decode_output=False)
    698698
    699699    @classmethod
  • trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py

    r70023 r70059  
    430430        self.checkout_root = self.fake_checkout_root
    431431
    432     def create_patch(self, git_commit):
     432    def create_patch(self, git_commit, changed_files=None):
    433433        return "Patch1"
    434434
     
    476476        return [self.commit_info_for_revision(32)]
    477477
    478     def modified_changelogs(self, git_commit):
     478    def modified_changelogs(self, git_commit, changed_files=None):
    479479        # Ideally we'd return something more interesting here.  The problem is
    480480        # that LandDiff will try to actually read the patch from disk!
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/abstractstep.py

    r69829 r70059  
    4646        self._tool.executive.run_and_throw_if_fail(command, quiet)
    4747
     48    def _changed_files(self, state):
     49        return self.cached_lookup(state, "changed_files")
     50
    4851    _well_known_keys = {
    49         "diff": lambda self, state: self._tool.scm().create_patch(self._options.git_commit),
    50         "changelogs": lambda self, state: self._tool.checkout().modified_changelogs(self._options.git_commit),
    5152        "bug_title": lambda self, state: self._tool.bugs.fetch_bug(state["bug_id"]).title(),
     53        "changed_files": lambda self, state: self._tool.scm().changed_files(self._options.git_commit),
     54        "diff": lambda self, state: self._tool.scm().create_patch(self._options.git_commit, changed_files=self._changed_files(state)),
     55        "changelogs": lambda self, state: self._tool.checkout().modified_changelogs(self._options.git_commit, changed_files=self._changed_files(state)),
    5256    }
    5357
     
    6064        return state[key]
    6165
     66    def did_modify_checkout(self, state):
     67        state["diff"] = None
     68        state["changelogs"] = None
     69        state["changed_files"] = None
     70
    6271    @classmethod
    6372    def options(cls):
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/editchangelog.py

    r60384 r70059  
    3636        os.chdir(self._tool.scm().checkout_root)
    3737        self._tool.user.edit_changelog(self.cached_lookup(state, "changelogs"))
     38        self.did_modify_checkout(state)
  • trunk/WebKitTools/Scripts/webkitpy/tool/steps/preparechangelog.py

    r69829 r70059  
    7575        except ScriptError, e:
    7676            error("Unable to prepare ChangeLogs.")
    77         state["diff"] = None # We've changed the diff
     77        self.did_modify_checkout(state)
Note: See TracChangeset for help on using the changeset viewer.