mirror of
https://github.com/morgan9e/helium
synced 2026-04-14 00:14:20 +09:00
@@ -106,16 +106,21 @@ def unmerge_platform_patches(platform_patches_dir):
|
||||
get_logger().error('Unable to find series.orig at: %s', platform_patches_dir / _SERIES_ORIG)
|
||||
return False
|
||||
orig_series = (platform_patches_dir / _SERIES_ORIG).read_text(encoding=ENCODING).splitlines()
|
||||
# patch path -> number of following blank lines
|
||||
path_spaces = dict()
|
||||
# patch path -> list of lines after patch path and before next patch path
|
||||
path_comments = dict()
|
||||
# patch path -> inline comment for patch
|
||||
path_inline_comments = dict()
|
||||
previous_path = None
|
||||
for partial_path in orig_series:
|
||||
if partial_path:
|
||||
previous_path = partial_path
|
||||
elif previous_path in path_spaces:
|
||||
path_spaces[previous_path] += 1
|
||||
if not partial_path or partial_path.startswith('#'):
|
||||
if partial_path not in path_comments:
|
||||
path_comments[previous_path] = list()
|
||||
path_comments[previous_path].append(partial_path)
|
||||
else:
|
||||
path_spaces[previous_path] = 1
|
||||
path_parts = partial_path.split(' #', maxsplit=1)
|
||||
previous_path = path_parts[0]
|
||||
if len(path_parts) == 2:
|
||||
path_inline_comments[path_parts[0]] = path_parts[1]
|
||||
|
||||
# Apply changes on series.merged into a modified version of series.orig
|
||||
if not (platform_patches_dir / _SERIES_MERGED).exists():
|
||||
@@ -128,8 +133,11 @@ def unmerge_platform_patches(platform_patches_dir):
|
||||
new_series = list(new_series)
|
||||
series_index = 0
|
||||
while series_index < len(new_series):
|
||||
if new_series[series_index] in path_spaces:
|
||||
new_series.insert(series_index + 1, '\n' * (path_spaces[new_series[series_index]] - 1))
|
||||
current_path = new_series[series_index]
|
||||
if current_path in path_inline_comments:
|
||||
new_series[series_index] = current_path + ' #' + path_inline_comments[current_path]
|
||||
if current_path in path_comments:
|
||||
new_series.insert(series_index + 1, '\n'.join(path_comments[current_path]) + '\n')
|
||||
series_index += 1
|
||||
series_index += 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user