-
Notifications
You must be signed in to change notification settings - Fork 270
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
#384 View alternate parent changes at merge commits #488
base: develop
Are you sure you want to change the base?
#384 View alternate parent changes at merge commits #488
Conversation
Users can now press ctrl key + parent hash (from the details view) to switch the commit we see the diff with. The parents are presented on separate lines, and the chosen parent is in bold. This is done by saving the current parent we view the diff with in the frontend and each time we request commit details we send the parent we want to diff with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dan1994,
Thank you for raising this pull request, based on our ongoing discussion on Discord. It's great to have a working proof-of-concept of this feature request.
I've tried it out, and agree with you that your current CTRL + Click parent selector isn't obvious enough to users. It would be great if you can experiment with some other approaches, to explore what would work best.
An alternative approach that I'd thought of, is to display a new action "View Changes with this Parent" on the right-click context menu on the parent commit hashes. It would be great if you could try this out, in addition to any other idea's you have. If this approach was to be used:
- Keep the bolding behaviour you've implemented, I think that it's a nice & clear way to indicate which parent is currently being used.
- Keep all the parents on a single line, like the existing UI. This was done to save some lines, and maximise the space available to display the commit body (without needing to scroll the Commit Details View).
- The existing implementation only adds internal links to parent commits that are loaded in the view. For this approach to be used, I think we'd have to make it so that all parents are linked, and show an error message if the user tries to follow the link when the parent can't be found in the loaded commits.
- This context menu action could be done in addition to your current CTRL + Click behaviour - users can use whichever they prefer.
FYI: Stashes are handled separately in the back-end, so some minor adjustments need to be made to properly handle them with the changes made with this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GitHub duplicated my review - please ignore this comment, as it's a duplicate of what I'd written above.
I hope to come up with a solution that is immediately visible to users, so that they can learn about this feature intuitively, but given the size constraints you mentioned, I'm not sure I'll have something better than the context menu. I just think that when I see a link I don't think "let's see what happens when I right click this".
Don't you think a better approach would be to load more commits, and show an error only as a last resort? I try to imagine myself getting this error, and I think it will be confusing.
I'll take a look, and try to perform the adjustments. |
…te-parent-changes-at-merge-commits
I completely agree. I'm keen to see what you come up with! The only alternative that I could think of, that would be immediately visible to users, would be to add a button the Commit Details View Control Bar (right side). For example, the icon could be "^1" (number is the parent index), and the action displays a context menu of parents to choose from. The button would only need to be shown if the commit has multiple parents.
I've discussed this on GitHub before, but in summary:
In the context my alternative approach, and how it would impact the internal links, it's possibly still a better solution than the existing behaviour, as at least the user would be shown an error message explaining the situation (e.g. "The commit could not be found in the loaded commits, either: load more commits, or check any filtering that has been applied"), instead of wondering why one parent doesn't have a link, when almost all of them do. The error dialog could even provide an action to "Load More Commits". |
That's actually a pretty good idea. I kept thinking about how I integrate it inside the parents line, but having a button on the sidebar can be great. Now I only need to find the right button (P.S.: already have a PoC for a context menu action). Regarding the behavior when a commit can't be found, I'll try to make the error message as informative as possible as you have suggested. |
A new class was added to each parent hash element in the form `parent-<id>`, where id is the index of the parent. Then, in the context menu, we check if the class exists and if it does we add an action to allow viewing diff with the parent.
I've taken a look, and am trying to figure out the correct course of action. Here are my observations so far:
Please let me know which observations are correct, and which are not, and what you think would be the best course of action. |
I’d considered that when I first implemented stashes, however ultimately I decided against it, as I thought some users would complain and think it was a bug if only some of the parents are shown. There’s even some rare use cases I’ve encountered where it’s actually quite useful to know all the internal commits within a stash.
I don’t think we need to allow alternative parents to be selected for stashes, however it depends on how it’s implemented in the UI as to whether we should do it. If we stay with the Ctrl + Click / Context Menu on the parent commits, for consistency we’d need to support alternate parents for stashes. However, if we decide to just have a button on the Commit Details View Control Bar, then we can just only show the button when the commit has multiple parents, and they’re not a stash.
You should just need to replace |
I based my changes on the original functionality, which decided if the commit should be a link by checking if it can be found in the lookup table. From what I've seen, stash internal commits are never styled as links according to this logic. This means you will always see one parent (the actual one) as a link, and the others as text. According to that, even given my ctrl click mechanism, the user can never display diffs to internal commits. In my opinion we should consistently not allow to show diffs with internal commits, and maybe open another issue if you think it's worth it.
This is the problem. I don't need the parent, but rather the hash of the stash itself. Applying my mechanism to the base hash will get me to the grandparents. |
That's true only when the stash is shown as a single commit. If the user enables "Include commits only mentioned by reflogs" in the Repository Settings Widget, then all the internal commits are shown in the view.
For now you can just ignore the stash case. We can circle back to stashes once everything else is handled, and can decide what we'll do then. (That's why I only mentioned it as an FYI in my original response)
The hash of the stash itself is |
Cool, I just keep learning new things about this extension :). I'll enable this setting and test things out.
Given that there are relevant use cases, I think I will implement it in this issue, but I will start with the standard use case.
I wasn't sure how |
Added the `loadedParents` variable which is used to deduce how to render each parent and to make sure that toggling is done only between loaded parents.
when a commit is clicked on.
Change Summary: Frontend:
Backend:
|
Hey @mhutchie, I've noticed you haven't reviewed my branch yet. Would you have time for that soon? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @dan1994,
Thanks for making all those changes, this feature is progressing nicely!
Please specifically ask for a review in the future when you're wanting one. I just assumed your "Change Summary" comment was giving a progress-update, alongside the recent commit's you'd made (I'd even liked it two weeks ago) - I didn't know you wanted me to do a code review.
My bad then, I'll ask next time. |
instead of toggle.
Go back to using the parents. We'll need to show an error message in cases where links of parents that aren't loaded are clicked.
Hey @mhutchie, I've made all the requested changes. Please review :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes, it's looking really good!
I've made some additional comments, that I'd appreciate you resolving.
Additionally:
- Please merge the current
develop
branch into your PR's branch. This last week I added complete unit test coverage for./src/gitGraphView.ts
, which was long overdue. You'll now be able to properly unit test your changes to./src/gitGraphView.ts
. - In several places in this pull request you use template literals. It's really important for the extension's codebase to be as consistent as possible, so that it's easy to understand for all current and future contributors. I acknowledge that the codebase still isn't as consistent as I'd like, so it's a constant effort of mine that whenever I work on some code, I improve it, and make it more consistent. Throughout the entire codebase, I only use template literals in a single place in the extension (to be consistent with Visual Studio Code's sample implementation), everywhere else uses standard string concatenation. Please use standard string concatenation instead of template literals (purely for consistency).
…te-parent-changes-at-merge-commits
I've added the missing field in some tests, but they are not passing because of a timeout. |
concatenation for consistency
Hi @dan1994, The test are failing because the |
Oh, yeah, I see it now. The error message misled me to believe that functions weren't called at all, when they were actually called with the wrong parameters. Thanks for the pointer. |
Currently filtering is assumed to always be on. Pending maintainer's decision.
parent index.
that the line about filtering is always present.
Switch from "Toggle Parent" to "View Changes with an Alternate Parent...".
and put a check mark by the current parent.
I've addressed your requests, please review. |
Hi @dan1994, I've reviewed your changes, and I'm really happy with how this feature has turned out. Thanks for all your hard work! I'm going to use it for a few days just to see if there's anything else I can think of. I'll merge it, and include it in the next beta release. FYI: Since our last messages on the unit tests timing out when async expectations aren't met, I've tweaked |
Glad to hear that! |
Hi @dan1994, After further testing this last week, I noticed:
Both of these are quite tricky to resolve, so I've been working on them this weekend. I'll push the changes to your branch and merge this PR as soon as I've completed them. |
Thanks fur the update! Let me know if you need any help. |
Closes #384