diff options
author | Allan Sandfeld Jensen <allan.jensen@digia.com> | 2013-09-13 12:51:20 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-09-19 20:50:05 +0200 |
commit | d441d6f39bb846989d95bcf5caf387b42414718d (patch) | |
tree | e367e64a75991c554930278175d403c072de6bb8 /Tools/Scripts/webkitpy/common/checkout/diff_parser.py | |
parent | 0060b2994c07842f4c59de64b5e3e430525c4b90 (diff) | |
download | qtwebkit-d441d6f39bb846989d95bcf5caf387b42414718d.tar.gz |
Import Qt5x2 branch of QtWebkit for Qt 5.2
Importing a new snapshot of webkit.
Change-Id: I2d01ad12cdc8af8cb015387641120a9d7ea5f10c
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@digia.com>
Diffstat (limited to 'Tools/Scripts/webkitpy/common/checkout/diff_parser.py')
-rw-r--r-- | Tools/Scripts/webkitpy/common/checkout/diff_parser.py | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py index 2ed552c45..3a9ea9224 100644 --- a/Tools/Scripts/webkitpy/common/checkout/diff_parser.py +++ b/Tools/Scripts/webkitpy/common/checkout/diff_parser.py @@ -58,7 +58,7 @@ def git_diff_to_svn_diff(line): # These regexp patterns should be compiled once instead of every time. conversion_patterns = (("^diff --git \w/(.+) \w/(?P<FilePath>.+)", lambda matched: "Index: " + matched.group('FilePath') + "\n"), ("^new file.*", lambda matched: "\n"), - ("^index [0-9a-f]{7}\.\.[0-9a-f]{7} [0-9]{6}", lambda matched: "===================================================================\n"), + ("^index (([0-9a-f]{7}\.\.[0-9a-f]{7})|([0-9a-f]{40}\.\.[0-9a-f]{40})) [0-9]{6}", lambda matched: "===================================================================\n"), ("^--- \w/(?P<FilePath>.+)", lambda matched: "--- " + matched.group('FilePath') + "\n"), ("^\+\+\+ \w/(?P<FilePath>.+)", lambda matched: "+++ " + matched.group('FilePath') + "\n")) @@ -69,19 +69,27 @@ def git_diff_to_svn_diff(line): return line +# This function exists so we can unittest get_diff_converter function +def svn_diff_to_svn_diff(line): + return line + + # FIXME: This method belongs on DiffParser -def get_diff_converter(first_diff_line): +def get_diff_converter(lines): """Gets a converter function of diff lines. Args: - first_diff_line: The first filename line of a diff file. - If this line is git formatted, we'll return a - converter from git to SVN. + lines: The lines of a diff file. + If this line is git formatted, we'll return a + converter from git to SVN. """ - if match(r"^diff --git \w/", first_diff_line): - return git_diff_to_svn_diff - return lambda input: input - + for i, line in enumerate(lines[:-1]): + # Stop when we find the first patch + if line[:3] == "+++" and lines[i + 1] == "---": + break + if match(r"^diff --git \w/", line): + return git_diff_to_svn_diff + return svn_diff_to_svn_diff _INITIAL_STATE = 1 _DECLARED_FILE_PATH = 2 @@ -142,10 +150,9 @@ 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") - if state == _INITIAL_STATE: - transform_line = get_diff_converter(line) line = transform_line(line) file_declaration = match(r"^Index: (?P<FilePath>.+)", line) |