diff --git a/edkrepo/common/common_repo_functions.py b/edkrepo/common/common_repo_functions.py index eabbd5c..fa42375 100644 --- a/edkrepo/common/common_repo_functions.py +++ b/edkrepo/common/common_repo_functions.py @@ -941,13 +941,27 @@ def apply_patchset_operations(repo, operations_list, global_manifest_path, remot else: raise EdkrepoPatchNotFoundException(PATCHFILE_DOES_NOT_EXIST.format(operation.file)) elif operation.type == REVERT: + revert_command = ['git', 'revert', operation.sha, '--no-edit'] + if operation.merge_strategy == "ort_ignore-all-space": + revert_command.extend(['--strategy', 'ort', '--strategy-option', 'ignore-all-space']) + elif operation.merge_strategy == "ort_theirs": + revert_command.extend(['--strategy', 'ort', '--strategy-option', 'theirs']) + elif operation.merge_strategy == "ort_ours": + revert_command.extend(['--strategy', 'ort', '--strategy-option', 'ours']) try: - repo.git.execute(['git', 'revert', operation.sha, '--no-edit']) + repo.git.execute(revert_command) except: if is_merge_conflict(repo): repo.git.execute(['git', 'revert', '--abort']) raise EdkrepoRevertFailedException(APPLYING_REVERT_FAILED.format(operation.sha)) else: + cherrypick_command = ['git', 'cherry-pick', operation.sha, '-x'] + if operation.merge_strategy == "ort_ignore-all-space": + cherrypick_command.extend(['--strategy', 'ort', '--strategy-option', 'ignore-all-space']) + elif operation.merge_strategy == "ort_theirs": + cherrypick_command.extend(['--strategy', 'ort', '--strategy-option', 'theirs']) + elif operation.merge_strategy == "ort_ours": + cherrypick_command.extend(['--strategy', 'ort', '--strategy-option', 'ours']) if operation.source_remote: REMOTE_FOUND = False for remote in remote_list: @@ -962,7 +976,7 @@ def apply_patchset_operations(repo, operations_list, global_manifest_path, remot except: raise EdkrepoFetchBranchNotFoundException(FETCH_BRANCH_DOES_NOT_EXIST.format(operation.source_branch)) try: - repo.git.execute(['git', 'cherry-pick', operation.sha, '-x']) + repo.git.execute(cherrypick_command) except: if is_merge_conflict(repo): repo.git.execute(['git', 'cherry-pick', '--abort']) @@ -979,7 +993,7 @@ def apply_patchset_operations(repo, operations_list, global_manifest_path, remot except: raise EdkrepoFetchBranchNotFoundException(FETCH_BRANCH_DOES_NOT_EXIST.format(operation.source_branch)) try: - repo.git.execute(['git', 'cherry-pick', operation.sha, '-x']) + repo.git.execute(cherrypick_command) except: if is_merge_conflict(repo): repo.git.execute(['git', 'cherry-pick', '--abort']) diff --git a/edkrepo_manifest_parser/edk_manifest.py b/edkrepo_manifest_parser/edk_manifest.py index 8488c16..e778b5b 100644 --- a/edkrepo_manifest_parser/edk_manifest.py +++ b/edkrepo_manifest_parser/edk_manifest.py @@ -29,7 +29,7 @@ RepoSource = namedtuple('RepoSource', ['root', 'remote_name', 'remote_url', 'branch', 'commit', 'sparse', 'enable_submodule', 'tag', 'venv_cfg', 'patch_set']) PatchSet = namedtuple('PatchSet', ['remote', 'name', 'parent_sha', 'fetch_branch']) -PatchOperation = namedtuple('PatchOperation',['type', 'file', 'sha', 'source_remote', 'source_branch']) +PatchOperation = namedtuple('PatchOperation',['type', 'file', 'sha', 'source_remote', 'source_branch', 'merge_strategy']) SparseSettings = namedtuple('SparseSettings', ['sparse_by_default']) SparseData = namedtuple('SparseData', ['combination', 'remote_name', 'always_include', 'always_exclude']) @@ -906,10 +906,14 @@ def __init__(self, element): self.source_branch = element.attrib['sourceBranch'] except KeyError as k: self.source_branch = None + try: + self.merge_strategy = element.attrib['mergeStrategy'] + except KeyError as k: + self.merge_strategy = None @property def tuple(self): - return PatchOperation(self.type, self.file, self.sha, self.source_remote, self.source_branch) + return PatchOperation(self.type, self.file, self.sha, self.source_remote, self.source_branch, self.merge_strategy) class _ProjectInfo(): def __init__(self, element):