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
RevDiff: compare any two files #8193
RevDiff: compare any two files #8193
Conversation
b0f96ff
to
e8a9085
Compare
Codecov Report
@@ Coverage Diff @@
## master #8193 +/- ##
==========================================
+ Coverage 52.75% 52.81% +0.05%
==========================================
Files 855 857 +2
Lines 62092 62305 +213
Branches 11154 11190 +36
==========================================
+ Hits 32758 32905 +147
- Misses 26737 26799 +62
- Partials 2597 2601 +4
|
e8a9085
to
19a3d21
Compare
👍 Works well. I'll review the code later (edit: has already been rebased). I'd like to add a separator above the new menu items. I think it would be useful to have these context menu items in the file tree, too. E.g. if an unchanged file was cloned to a new one. Slightly off-topic for this PR: I still quarrel over the new position of the submenu |
I will rebase at least when there are conflicts, more often if I want to sync to other PRs.
Agree. I have to leave something for you too
Can this be separate or do we need a separate resolver that is common? I probably want to have an alternative for Save parent to selected for later comparison (nice and short? Should have the revision too). With a divider it may be OK to see these separate
(I do not like the position either, but found it better than an implementation that was inconsistent.) A bigger problem is to implement the fish-needs-bicycle tests for the controller. Edit: I have pushed an update for the comments to a private branch. Will update the PR later |
What does "Save selected file to later" mean? |
Save the file+commit so it can be compared later. Really similar to comparing the two commits, then compare, but it may be easier to find the files/commits to compare. |
Do they have the same wording? ...and even then it looks/sounds awkward. |
compareToExistingDifftoolToolStripMenuItem.Visible = diffFiles.Count == 1 && _savedCompareFileItem != null; | ||
compareToExistingDifftoolToolStripMenuItem.Enabled = diffFiles.Count == 1 && _revisionDiffContextMenuController.ShouldEnableSecondSpecialCompare(diffFiles?[0]); | ||
compareToExistingDifftoolToolStripMenuItem.Text = _savedCompareFileItem != null ? string.Format(_compareSelectedFile.Text, _savedCompareFileItem.Item.Name) : string.Empty; | ||
saveForLaterDifftoolToolStripMenuItem.Visible = diffFiles.Count == 1; | ||
saveForLaterDifftoolToolStripMenuItem.Enabled = diffFiles.Count == 1 && _revisionDiffContextMenuController.ShouldEnableFirstSpecialCompare(diffFiles?[0]); |
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.
I like the idea of being able to compare arbitrary files across revisions, but I'm finding the visual presentation of the feature confusing. I had to look at the code to understand the screenshots showed...
Few Qs that immediately popped up:
- how do I know which files from which revisions I marked?
- how do I unmark selected/all files?
- how do I change the order of files?
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.
how do I know which files from which revisions I marked?
The file name is shown in the menu item Compare selected file to "file"
.
Its revision is something for your short-term memory :)
how do I change the order of files?
Click
Or replace the selection using Save selected file for later comparison
and then choose Compare selected file to "file"
after selecting the first one again.
how do I unmark selected/all files?
It's all about comparing exactly two files.
No need to unmark, just start over with Save selected file for later comparison
.
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.
I want to have the previous selectable too
Diff the selected files
(when two selected)
Diff with "file"
(one selected, revision not included in text)
Save b/12345678 for later
(one selected, filename not included)
Save a/12345678 for later
Screenshots for other apps. No consistent description. The proposals are considerably longer...
DiffMerge can save several files, as well as clear them
Tortoise supports both git-diff and file system from the context menu
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.
Thank you, it's starting to make sense.
Now to pick and agree on the wording :) I think if I saw BC and TG menus I'd conceivably guess their intent.
Would "Remember file for compare" work? And then "Compare with <the remembered file>"?
Is "first" and "second" placement material?
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.
(I missed this comment, waiting with a merge)
The menu and Git uses diff rather than compare, so I prefer diff.
"Compare selected..." should be "Diff with " (dropping "selected file".
But "Remember Second for later" or "Remember Second" (similar to First) is possible. The shorter, the better is my preference (I constantly fail though.)
@mstv ?
I have pushed changes to private branches in my repo only (will test some more) This cleans up the the handling of assuming first rev when second rev cannot be used, including addig "Save first revision" to the context menu. Use case 1: Use case 2: Use case 3: 3a 3b |
19a3d21
to
4068565
Compare
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.
LGTM
Found an edge case: No matter whether the first or second of a renamed file is saved for later, the new name appears in the menu:
And: Should it be First -> Second
instead of First -> Selected
?
Should Second b/...
rather be the top item in order to match the order in the RevisionGrid and in the Reset file(s) to
menu?
/// <param name="firstGitCommit">commitish</param> | ||
/// <param name="secondGitCommit">commitish</param> | ||
/// <returns>empty string</returns> | ||
public string OpenFilesWithDifftool(string firstGitCommit, string secondGitCommit) |
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.
Why not make it return void
?
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.
It follows the pattern for OpenWithDifftool()
See the TODO there
As an empty string is always returned anyway, few callers try to use the data
This should be handled the same
I had ignored that, but since you are commenting on it I will change that
Yes
It should be the same as in Reset at least. That Selected was before First was natural, but First before Second may not be. |
👍 else I would have complained 😉 |
5c9bf87
to
a802050
Compare
a802050
to
0cd1ffc
Compare
Added a commit to align diff submenu with reset submenu, updated description and screenshot, also removed WIP |
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.
👍
I had a brief looked at the code, it looks good, I have no objections. |
0cd1ffc
to
fe5fbeb
Compare
@msftbot merge in 24 hours |
For the ease of navigation, continuation of the discussion in #8193 (comment) Something like this?
|
Adapted the proposal.
(No need to have a separator further down "Diff the selected" is only shown with two selected, the other only with one
Second and First is explained in the top of the menu, no need to do it again
No need for this one, forgotten if swiching repos. ...And the references to "saveForLater" in the code should be changed to remember file... |
👍 Thank you |
I agree.
It has been made consistent with the other submenus, and matches the order in the RevisionGrid. |
At this point, I say follow RevisionGrid "one selected" order Will squash latest commit in a day or so (no changes other than naming in the latest commit) #8239 will follow, then likely #8254 before #7825 can be resumed |
Works for me. Thanks
|
Working in some difftools
* If two items in the RevDiff list are selected, add menu item to diff them * If one item is selected, menu item to remember the file * If one item is selected and one item remembered, menu item to diff them This allows to compare refactored files, between commits
477c86f
to
b8f68cb
Compare
/// </summary> | ||
public FileStatusItem RememberedDiffFileItem { get; set; } | ||
|
||
// Note that the methods in this class are without side effects (static) |
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.
There's [Pure]
attribute for that.
Fixes #8048
Proposed changes
This allows to compare refactored files, between commits, currently you have to save temporary files and compare them
The primary use is refactoring, when files are renamed and changed without Git detecting the change or when the change is done over several commits. It also allows seeing the difference for images (like in p4merge) when files are renamed.
Viewing files requires that the file exist in the commit, the first item must not be work tree.
To simplify usage, the compared file is automatically selecting the first revision if the second revision does cannot be used for the diff.
See #8193 (comment) for some use cases.
The first and second revisions are not named, just First and Second as the revisions are explained in the top of the menu.
Refactoring:
DiffTool should always detect rename and copy
Hard to track that "-M -C" is always used, the parameters are passed around in some situations, in the Git command for others
RevDiff: Allow difftool menu for untracked
Working in some difftools, comparing to NUL
[New] Use Second instead of Selected in the Difftool submenu (should have been changed when the naming for the groups were changed).
[New] Keep Second above First in the difftool submenu (already this order in Reset submenu)
Possible enhancement:
Add Remember file and Diff with in FileTree
Screenshots
Before
After
(Change from Selected to Second, same as in Diff submenu)
Test methodology
Added tests
✒️ I contribute this code under The Developer Certificate of Origin.