From fb45f089b0b9c7e822904aaf6b1a499382659b80 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 24 Jun 2022 15:57:45 +0200 Subject: [PATCH] [FIX] forwardport: use diff3 for conflict style Existing conflict style is the local default ("merge", most likely). `diff3` is a lot more informative as it provides the common ancestor's code for the hunk, which helps see how the two branches diverged and thus resolve the conflict. Even better would be zdiff3 but that's a bit too recent... Fixes #619 --- forwardport/changelog/2022-06/conflict-diff3.md | 1 + forwardport/models/project.py | 2 +- forwardport/tests/test_conflicts.py | 6 ++++-- forwardport/tests/test_updates.py | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 forwardport/changelog/2022-06/conflict-diff3.md diff --git a/forwardport/changelog/2022-06/conflict-diff3.md b/forwardport/changelog/2022-06/conflict-diff3.md new file mode 100644 index 00000000..7dc4b4c0 --- /dev/null +++ b/forwardport/changelog/2022-06/conflict-diff3.md @@ -0,0 +1 @@ +IMP: use the `diff3` conflict style, should make forward port conflicts clearer and easier to fix diff --git a/forwardport/models/project.py b/forwardport/models/project.py index af22ef46..f9653cbb 100644 --- a/forwardport/models/project.py +++ b/forwardport/models/project.py @@ -870,7 +870,7 @@ This PR targets %s and is part of the forward-port chain. Further PRs will be cr # switch back to the PR branch conf.checkout(fp_branch_name) # cherry-pick the squashed commit to generate the conflict - conf.with_params('merge.renamelimit=0')\ + conf.with_params('merge.renamelimit=0', 'merge.conflictstyle=diff3')\ .with_config(check=False)\ .cherry_pick(squashed, no_commit=True) status = conf.stdout().status(short=True, untracked_files='no').stdout.decode() diff --git a/forwardport/tests/test_conflicts.py b/forwardport/tests/test_conflicts.py index ea6c2844..0dd1c1c5 100644 --- a/forwardport/tests/test_conflicts.py +++ b/forwardport/tests/test_conflicts.py @@ -60,9 +60,10 @@ def test_conflict(env, config, make_repo, users): 'g': 'a', 'h': re_matches(r'''<<<\x3c<<< HEAD a +|||||||| parent of [\da-f]{7,}.* ======= xxx ->>>\x3e>>> [0-9a-f]{7,}.* +>>>\x3e>>> [\da-f]{7,}.* '''), } prb = prod.get_pr(prb_id.number) @@ -323,9 +324,10 @@ def test_multiple_commits_different_authorship(env, config, make_repo, users, ro assert re.match(r'''<<<\x3c<<< HEAD b +|||||||| parent of [\da-f]{7,}.* ======= 2 ->>>\x3e>>> [0-9a-f]{7,}.* +>>>\x3e>>> [\da-f]{7,}.* ''', prod.read_tree(c)['g']) # I'd like to fix the conflict so everything is clean and proper *but* diff --git a/forwardport/tests/test_updates.py b/forwardport/tests/test_updates.py index 4f689246..cc7de7c2 100644 --- a/forwardport/tests/test_updates.py +++ b/forwardport/tests/test_updates.py @@ -374,9 +374,10 @@ def test_subsequent_conflict(env, make_repo, config, users): 'g': 'a', 'h': re_matches(r'''<<<\x3c<<< HEAD a +|||||||| parent of [\da-f]{7,}.* ======= conflict! ->>>\x3e>>> [0-9a-f]{7,}.* +>>>\x3e>>> [\da-f]{7,}.* '''), 'x': '0', }