Skip to content

Merge editor now compare incoming changes with common ancestor commit #2203

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 2, 2023

Conversation

amolenaar
Copy link
Member

@amolenaar amolenaar commented Apr 1, 2023

PR Type

What kind of change does this PR introduce?

  • Bug fix
  • Feature
  • Chore (refactoring, formatting, local variables, other cleanup)
  • Documentation content changes

What is the current behavior?

The list of changes in the merge editor is long and not easy to comprehend.

Issue Number: #388

What is the new behavior?

Instead of comparing the incoming with the current model, the incoming model is compared with a common ancestor node. As a result, the change set only contains the changes made in the incoming branch. Those changes can be applied to the model.

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

@amolenaar amolenaar requested a review from danyeaw April 1, 2023 14:09
@github-actions github-actions bot added the python Pull requests that update Python code label Apr 1, 2023
@amolenaar amolenaar added this to the 2.18 milestone Apr 1, 2023
@amolenaar amolenaar marked this pull request as draft April 1, 2023 14:46
It can happen that an element existed in the incoming branch,
and has been removed in the current branch. In that case we
should not fail.
@amolenaar amolenaar marked this pull request as ready for review April 1, 2023 15:09
@amolenaar amolenaar added the feature A new feature label Apr 1, 2023
@@ -182,7 +182,7 @@ def test_applied_stereotype(element_factory, modeling_language, create):
apply_stereotype(class_item.subject, stereotype)

current = ElementFactory()
all(compare(current, element_factory))
all(compare(current, current, element_factory))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For my understanding, are these tests now comparing the current against itself?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They conpare current against element_factory. The resulting changes are created in the current model.

I have to admit, the api is still a bit messy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the explanation!

Copy link
Member

@danyeaw danyeaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice update 👍

@danyeaw danyeaw merged commit 4047ec5 into main Apr 2, 2023
@danyeaw danyeaw deleted the compare-with-ancestor branch April 2, 2023 20:51
@bayerl
Copy link
Contributor

bayerl commented Dec 7, 2023

@danyeaw @amolenaar I'm trying to figure out how to exercise and use this functionality, but it's not obvious to me. I have a local git repo with my <name>.gaphor model file committed. From the terminal, I've created a branch, opened the branch model in the gaphor GUI, and made a change (added a new element). I've tried things like changing my branch back to main while the model remains open in the gaphor GUI, and saving the model, but it just overwrites the <name>.gaphor file in my local repository. I thought it might be git-aware and open the merge editor or something.

Can you describe steps to invoke the merge editor? Once I'm pointed in the right direction I'd be happy to contribute an example for the documentation if that'd be helpful

@amolenaar
Copy link
Member Author

amolenaar commented Dec 7, 2023

Hi @bayerl,

This behavior is activated when you have a merge conflict in git. So if you make changes on your branch, then open the model on the main branch and make some changes. If you merge the branch into main, and there are merge conflicts, you can still open the model woth Gaphor. This merge editor will show up and allow you to selectively add changes from your branch to the main branch.

The docs are here: https://docs.gaphor.org/en/latest/merge_conflicts.html. Please let me know if (and where) it needs clarification.

@bayerl bayerl mentioned this pull request Dec 8, 2023
8 tasks
@bayerl
Copy link
Contributor

bayerl commented Dec 8, 2023

@amolenaar thanks for the fast response! Ok I got it. This approach makes sense. Very cool feature! I will be experimenting with this further.

I did see the docs, which helped me discover this feature in the first place. I've suggested a slight modification that would've made it clear to me in PR #2914

@amolenaar
Copy link
Member Author

@bayerl Thanks. I merge the PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation feature A new feature python Pull requests that update Python code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants