summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/common/checkout
diff options
context:
space:
mode:
authorSteve Block <steveblock@google.com>2011-05-06 11:45:16 +0100
committerSteve Block <steveblock@google.com>2011-05-12 13:44:10 +0100
commitcad810f21b803229eb11403f9209855525a25d57 (patch)
tree29a6fd0279be608e0fe9ffe9841f722f0f4e4269 /Tools/Scripts/webkitpy/common/checkout
parent121b0cf4517156d0ac5111caf9830c51b69bae8f (diff)
downloadexternal_webkit-cad810f21b803229eb11403f9209855525a25d57.zip
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.gz
external_webkit-cad810f21b803229eb11403f9209855525a25d57.tar.bz2
Merge WebKit at r75315: Initial merge by git.
Change-Id: I570314b346ce101c935ed22a626b48c2af266b84
Diffstat (limited to 'Tools/Scripts/webkitpy/common/checkout')
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/__init__.py2
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/api.py12
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/diff_parser.py13
-rw-r--r--Tools/Scripts/webkitpy/common/checkout/scm.py7
4 files changed, 19 insertions, 15 deletions
diff --git a/Tools/Scripts/webkitpy/common/checkout/__init__.py b/Tools/Scripts/webkitpy/common/checkout/__init__.py
index 597dcbd..ef65bee 100644
--- a/Tools/Scripts/webkitpy/common/checkout/__init__.py
+++ b/Tools/Scripts/webkitpy/common/checkout/__init__.py
@@ -1,3 +1 @@
# Required for Python to search this directory for module files
-
-from api import Checkout
diff --git a/Tools/Scripts/webkitpy/common/checkout/api.py b/Tools/Scripts/webkitpy/common/checkout/api.py
index 6357982..29e43d3 100644
--- a/Tools/Scripts/webkitpy/common/checkout/api.py
+++ b/Tools/Scripts/webkitpy/common/checkout/api.py
@@ -39,14 +39,14 @@ from webkitpy.common.system.executive import Executive, run_command, ScriptError
from webkitpy.common.system.deprecated_logging import log
-# This class represents the WebKit-specific parts of the checkout (like
-# ChangeLogs).
+# This class represents the WebKit-specific parts of the checkout (like ChangeLogs).
# FIXME: Move a bunch of ChangeLog-specific processing from SCM to this object.
+# NOTE: All paths returned from this class should be absolute.
class Checkout(object):
def __init__(self, scm):
self._scm = scm
- def _is_path_to_changelog(self, path):
+ def is_path_to_changelog(self, path):
return os.path.basename(path) == "ChangeLog"
def _latest_entry_for_changelog_at_revision(self, changelog_path, revision):
@@ -59,7 +59,7 @@ class Checkout(object):
def changelog_entries_for_revision(self, revision):
changed_files = self._scm.changed_files_for_revision(revision)
- return [self._latest_entry_for_changelog_at_revision(path, revision) for path in changed_files if self._is_path_to_changelog(path)]
+ return [self._latest_entry_for_changelog_at_revision(path, revision) for path in changed_files if self.is_path_to_changelog(path)]
@memoized
def commit_info_for_revision(self, revision):
@@ -96,10 +96,10 @@ class Checkout(object):
return [path for path in absolute_paths if predicate(path)]
def modified_changelogs(self, git_commit, changed_files=None):
- return self._modified_files_matching_predicate(git_commit, self._is_path_to_changelog, changed_files=changed_files)
+ return self._modified_files_matching_predicate(git_commit, self.is_path_to_changelog, changed_files=changed_files)
def modified_non_changelogs(self, git_commit, changed_files=None):
- return self._modified_files_matching_predicate(git_commit, lambda path: not self._is_path_to_changelog(path), changed_files=changed_files)
+ return self._modified_files_matching_predicate(git_commit, lambda path: not self.is_path_to_changelog(path), changed_files=changed_files)
def commit_message_for_this_commit(self, git_commit, changed_files=None):
changelog_paths = self.modified_changelogs(git_commit, changed_files)
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
index a6ea756..5a5546c 100644
--- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
+++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
@@ -118,6 +118,8 @@ class DiffFile(object):
self.lines.append((deleted_line_number, new_line_number, line))
+# If this is going to be called DiffParser, it should be a re-useable parser.
+# Otherwise we should rename it to ParsedDiff or just Diff.
class DiffParser(object):
"""A parser for a patch file.
@@ -125,16 +127,18 @@ class DiffParser(object):
a DiffFile object.
"""
- # FIXME: This function is way too long and needs to be broken up.
def __init__(self, diff_input):
"""Parses a diff.
Args:
diff_input: An iterable object.
"""
- state = _INITIAL_STATE
+ self.files = self._parse_into_diff_files(diff_input)
- self.files = {}
+ # FIXME: This function is way too long and needs to be broken up.
+ def _parse_into_diff_files(self, diff_input):
+ files = {}
+ state = _INITIAL_STATE
current_file = None
old_diff_line = None
new_diff_line = None
@@ -148,7 +152,7 @@ class DiffParser(object):
if file_declaration:
filename = file_declaration.group('FilePath')
current_file = DiffFile(filename)
- self.files[filename] = current_file
+ files[filename] = current_file
state = _DECLARED_FILE_PATH
continue
@@ -179,3 +183,4 @@ class DiffParser(object):
else:
_log.error('Unexpected diff format when parsing a '
'chunk: %r' % line)
+ return files
diff --git a/Tools/Scripts/webkitpy/common/checkout/scm.py b/Tools/Scripts/webkitpy/common/checkout/scm.py
index c54fb42..3f77043 100644
--- a/Tools/Scripts/webkitpy/common/checkout/scm.py
+++ b/Tools/Scripts/webkitpy/common/checkout/scm.py
@@ -172,14 +172,15 @@ class SCM:
return os.path.join(self.scripts_directory(), script_name)
def ensure_clean_working_directory(self, force_clean):
- if not force_clean and not self.working_directory_is_clean():
+ if self.working_directory_is_clean():
+ return
+ if not force_clean:
# FIXME: Shouldn't this use cwd=self.checkout_root?
print self.run(self.status_command(), error_handler=Executive.ignore_error)
raise ScriptError(message="Working directory has modifications, pass --force-clean or --no-clean to continue.")
-
log("Cleaning working directory")
self.clean_working_directory()
-
+
def ensure_no_local_commits(self, force):
if not self.supports_local_commits():
return