summaryrefslogtreecommitdiff
path: root/chromium/tools/clang/scripts/apply_edits.py
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-12 14:27:29 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2020-10-13 09:35:20 +0000
commitc30a6232df03e1efbd9f3b226777b07e087a1122 (patch)
treee992f45784689f373bcc38d1b79a239ebe17ee23 /chromium/tools/clang/scripts/apply_edits.py
parent7b5b123ac58f58ffde0f4f6e488bcd09aa4decd3 (diff)
downloadqtwebengine-chromium-85-based.tar.gz
BASELINE: Update Chromium to 85.0.4183.14085-based
Change-Id: Iaa42f4680837c57725b1344f108c0196741f6057 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/tools/clang/scripts/apply_edits.py')
-rwxr-xr-xchromium/tools/clang/scripts/apply_edits.py26
1 files changed, 19 insertions, 7 deletions
diff --git a/chromium/tools/clang/scripts/apply_edits.py b/chromium/tools/clang/scripts/apply_edits.py
index f6e9dcb16c6..a49a739792b 100755
--- a/chromium/tools/clang/scripts/apply_edits.py
+++ b/chromium/tools/clang/scripts/apply_edits.py
@@ -76,7 +76,7 @@ def _ParseEditsFromStdin(build_directory):
if not os.path.isfile(path):
resolved_path = os.path.realpath(os.path.join(build_directory, path))
else:
- resolved_path = path
+ resolved_path = os.path.realpath(path)
if not os.path.isfile(resolved_path):
sys.stderr.write('Edit applies to a non-existent file: %s\n' % path)
@@ -197,12 +197,24 @@ def _InsertNonSystemIncludeHeader(filepath, header_line_to_add, contents):
def _ApplyReplacement(filepath, contents, edit, last_edit):
- if (last_edit is not None and edit.edit_type == last_edit.edit_type
- and edit.offset == last_edit.offset and edit.length == last_edit.length):
- raise ValueError(('Conflicting replacement text: ' +
- '%s at offset %d, length %d: "%s" != "%s"\n') %
- (filepath, edit.offset, edit.length, edit.replacement,
- last_edit.replacement))
+ assert (edit.edit_type == 'r')
+ assert ((last_edit is None) or (last_edit.edit_type == 'r'))
+
+ if last_edit is not None:
+ if edit.offset == last_edit.offset and edit.length == last_edit.length:
+ assert (edit.replacement != last_edit.replacement)
+ raise ValueError(('Conflicting replacement text: ' +
+ '%s at offset %d, length %d: "%s" != "%s"\n') %
+ (filepath, edit.offset, edit.length, edit.replacement,
+ last_edit.replacement))
+
+ if edit.offset + edit.length > last_edit.offset:
+ raise ValueError(
+ ('Overlapping replacements: ' +
+ '%s at offset %d, length %d: "%s" and ' +
+ 'offset %d, length %d: "%s"\n') %
+ (filepath, edit.offset, edit.length, edit.replacement,
+ last_edit.offset, last_edit.length, last_edit.replacement))
contents[edit.offset:edit.offset + edit.length] = edit.replacement
if not edit.replacement: