Changeset 70014 in webkit


Ignore:
Timestamp:
Oct 18, 2010 6:38:00 PM (14 years ago)
Author:
abarth@webkit.org
Message:

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

Reviewed by Eric Seidel.

scm.py should be able tell us what revisions made changes to a given file
https://bugs.webkit.org/show_bug.cgi?id=47863

Look again, your SCM.py can now log files.

  • Scripts/webkitpy/common/checkout/scm.py:
  • Scripts/webkitpy/common/checkout/scm_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r70013 r70014  
     12010-10-18  Adam Barth  <abarth@webkit.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        scm.py should be able tell us what revisions made changes to a given file
     6        https://bugs.webkit.org/show_bug.cgi?id=47863
     7
     8        Look again, your SCM.py can now log files.
     9
     10        * Scripts/webkitpy/common/checkout/scm.py:
     11        * Scripts/webkitpy/common/checkout/scm_unittest.py:
     12
    1132010-10-18  Dirk Pranke  <dpranke@chromium.org>
    214
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm.py

    r66064 r70014  
    246246        self._subclass_must_implement()
    247247
    248     def changed_files_for_revision(self):
     248    def changed_files_for_revision(self, revision):
     249        self._subclass_must_implement()
     250
     251    def revisions_changing_file(self, path, limit=5):
    249252        self._subclass_must_implement()
    250253
     
    428431        return self.run_status_and_extract_filenames(status_command, self._status_regexp("ACDMR"))
    429432
     433    def revisions_changing_file(self, path, limit=5):
     434        revisions = []
     435        log_command = ['svn', 'log', '--quiet', '--limit=%s' % limit, path]
     436        for line in self.run(log_command, cwd=self.checkout_root).splitlines():
     437            match = re.search('^r(?P<revision>\d+) ', line)
     438            if not match:
     439                continue
     440            revisions.append(int(match.group('revision')))
     441        return revisions
     442
    430443    def conflicted_files(self):
    431444        return self.run_status_and_extract_filenames(self.status_command(), self._status_regexp("C"))
     
    654667        return self._changes_files_for_commit(commit_id)
    655668
     669    def revisions_changing_file(self, path, limit=5):
     670        commit_ids = self.run(["git", "log", "--pretty=format:%H", "-%s" % limit, path]).splitlines()
     671        return map(self.svn_revision_from_git_commit, commit_ids)
     672
    656673    def conflicted_files(self):
    657674        # We do not need to pass decode_output for this diff command
     
    688705            raise ScriptError(message='Failed to find git commit for revision %s, your checkout likely needs an update.' % revision)
    689706        return git_commit
     707
     708    def svn_revision_from_git_commit(self, commit_id):
     709        return int(self.run(['git', 'svn', 'find-rev', commit_id]).rstrip())
    690710
    691711    def contents_at_revision(self, path, revision):
  • trunk/WebKitTools/Scripts/webkitpy/common/checkout/scm_unittest.py

    r65572 r70014  
    353353        self.assertRaises(ScriptError, self.scm.contents_at_revision, "does_not_exist", 2)
    354354
     355    def _shared_test_revisions_changing_file(self):
     356        self.assertEqual(self.scm.revisions_changing_file("test_file"), [5, 4, 3, 2])
     357        self.assertRaises(ScriptError, self.scm.revisions_changing_file, "non_existent_file")
     358
    355359    def _shared_test_committer_email_for_revision(self):
    356360        self.assertEqual(self.scm.committer_email_for_revision(3), getpass.getuser())  # Committer "email" will be the current user
     
    697701        self._shared_test_contents_at_revision()
    698702
     703    def test_revisions_changing_file(self):
     704        self._shared_test_revisions_changing_file()
     705
    699706    def test_committer_email_for_revision(self):
    700707        self._shared_test_committer_email_for_revision()
     
    12001207        self._shared_test_contents_at_revision()
    12011208
     1209    def test_revisions_changing_file(self):
     1210        self._shared_test_revisions_changing_file()
     1211
    12021212    def test_added_files(self):
    12031213        self._shared_test_added_files()
Note: See TracChangeset for help on using the changeset viewer.