| Index: third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
|
| diff --git a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
|
| index 90fd961b660803ce5bf092fd537f4ba2bc19069f..739131fc4ac23aaaa124516f9ee2c43502a36005 100644
|
| --- a/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
|
| +++ b/third_party/WebKit/Tools/Scripts/webkitpy/common/checkout/diff_parser.py
|
| @@ -33,53 +33,9 @@ import re
|
|
|
| _log = logging.getLogger(__name__)
|
|
|
| -conversion_patterns = (
|
| - (re.compile(r"^diff --git \w/(.+) \w/(?P<FilePath>.+)"), lambda matched: "Index: " + matched.group('FilePath') + "\n"),
|
| - (re.compile(r"^new file.*"), lambda matched: "\n"),
|
| - (re.compile(r"^index (([0-9a-f]{7}\.\.[0-9a-f]{7})|([0-9a-f]{40}\.\.[0-9a-f]{40})) [0-9]{6}"),
|
| - lambda matched: ("=" * 67) + "\n"),
|
| - (re.compile(r"^--- \w/(?P<FilePath>.+)"), lambda matched: "--- " + matched.group('FilePath') + "\n"),
|
| - (re.compile(r"^\+\+\+ \w/(?P<FilePath>.+)"), lambda matched: "+++ " + matched.group('FilePath') + "\n"),
|
| -)
|
| +INDEX_PATTERN = re.compile(r'^diff --git \w/(.+) \w/(?P<FilePath>.+)')
|
| +LINES_CHANGED_PATTERN = re.compile(r"^@@ -(?P<OldStartLine>\d+)(,\d+)? \+(?P<NewStartLine>\d+)(,\d+)? @@")
|
|
|
| -index_pattern = re.compile(r"^Index: (?P<FilePath>.+)")
|
| -lines_changed_pattern = re.compile(r"^@@ -(?P<OldStartLine>\d+)(,\d+)? \+(?P<NewStartLine>\d+)(,\d+)? @@")
|
| -diff_git_pattern = re.compile(r"^diff --git \w/")
|
| -
|
| -
|
| -def git_diff_to_svn_diff(line):
|
| - """Converts a git formatted diff line to a svn formatted line.
|
| -
|
| - Args:
|
| - line: A string representing a line of the diff.
|
| - """
|
| - for pattern, conversion in conversion_patterns:
|
| - matched = pattern.match(line)
|
| - if matched:
|
| - return conversion(matched)
|
| - return line
|
| -
|
| -
|
| -# This function exists so we can unittest get_diff_converter function
|
| -def svn_diff_to_svn_diff(line):
|
| - return line
|
| -
|
| -
|
| -def get_diff_converter(lines):
|
| - """Gets a converter function of diff lines.
|
| -
|
| - Args:
|
| - lines: The lines of a diff file.
|
| - If this line is git formatted, we'll return a
|
| - converter from git to SVN.
|
| - """
|
| - for i, line in enumerate(lines[:-1]):
|
| - # Stop when we find the first patch
|
| - if line[:3] == "+++" and lines[i + 1] == "---":
|
| - break
|
| - if diff_git_pattern.match(line):
|
| - return git_diff_to_svn_diff
|
| - return svn_diff_to_svn_diff
|
|
|
| _INITIAL_STATE = 1
|
| _DECLARED_FILE_PATH = 2
|
| @@ -140,12 +96,10 @@ class DiffParser(object):
|
| current_file = None
|
| old_diff_line = None
|
| new_diff_line = None
|
| - transform_line = get_diff_converter(diff_input)
|
| for line in diff_input:
|
| - line = line.rstrip("\n")
|
| - line = transform_line(line)
|
| + line = line.rstrip('\n')
|
|
|
| - file_declaration = index_pattern.match(line)
|
| + file_declaration = INDEX_PATTERN.match(line)
|
| if file_declaration:
|
| filename = file_declaration.group('FilePath')
|
| current_file = DiffFile(filename)
|
| @@ -153,7 +107,7 @@ class DiffParser(object):
|
| state = _DECLARED_FILE_PATH
|
| continue
|
|
|
| - lines_changed = lines_changed_pattern.match(line)
|
| + lines_changed = LINES_CHANGED_PATTERN.match(line)
|
| if lines_changed:
|
| if state != _DECLARED_FILE_PATH and state != _PROCESSING_CHUNK:
|
| _log.error('Unexpected line change without file path declaration: %r', line)
|
|
|