Bug 516450 - Proposal for a set of consistent rules for what to show on the left and right sides of the compare viewer
Summary: Proposal for a set of consistent rules for what to show on the left and right...
Status: REOPENED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Compare (show other bugs)
Version: 4.6   Edit
Hardware: PC Linux
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-Compare-Inbox CLA
QA Contact:
URL:
Whiteboard: stalebug
Keywords: helpwanted
: 504474 (view as bug list)
Depends on:
Blocks: 508257
  Show dependency tree
 
Reported: 2017-05-11 00:50 EDT by Stefan Xenos CLA
Modified: 2022-11-13 15:36 EST (History)
9 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Stefan Xenos CLA 2017-05-11 00:50:51 EDT
The goal of the proposed rules is to make Compare viewer display consistent with popular code review systems, e.g. Gerrit, and with popular file comparison programs like meld or tkdiff. To the degree possible the rules also try to guarantee consistency between different comparison operations when the same change is viewed at different times in its life.

This draft proposal came from a number of discussion notes and emails between sprigogin and sxenos.

We believe that the reason other tools are unambiguous is because they always fall into one of two cases:
1. The user is viewing an existing change where someone already selected the before and after states.
2. The user explicitly selected which state goes on which side of the viewer.

Examples of 1:
- Viewing a .diff file
- Viewing a commit in gerrit
- Viewing an existing change in gitk
- Viewing your change in progress in "git gui"

Examples of 2:
- Any command-line tool where the order of command-line arguments controls the side where things appear (tkdiff, kdiff, p4merge)
- The dropdowns in gerrit that let you manually control what patch version shows up on each side of the diff viewer

In other words, the choice of before/after, left/right is always something that was explicitly chosen by someone. *This* is the rule that unifies most non-Eclipse tools, and that it's what we're promising to do when we say we're making Eclipse consistent with other tools. For example, it is our belief that most users wouldn't want their command-line tool to choose which file state goes on the left and right based on something like timestamp.

We only need three rules to apply this consistently in Eclipse.

Actions where the before/after states are unambiguous and were already selected (possibly by someone else) get a different verb ("Show") from ones where the user will select the left-right sides themselves ("Compare").
1. Context menu items named "Compare" or "Compare with" put the thing you right-clicked on on the left, and any other state on the right.
2. Double-click actions, preview windows, and actions named "Show" should only be used in places where a before and after state is unambiguous and meaningful. They put the before state on the left, and after state on the right.
3. In the case of a preview, the "before" state is the current state of the workspace and the "after" state is the hypothetical future state.

Concretely:

A) Refactoring preview. Proposed change is shown on the right (rule #2).
B) Replace With Local History. The history version is shown on the right (rule #2).
C) Compare Current with Local in the local history view. The workspace version is shown on the right (rule #2).
D) Compare with Each Other in local history view. See note N2, below.
E) Compare With Previous Version (EGit) (on IResource). Action renamed to "Show changes since previous commit". The workspace version is shown on the right (rule #2).
F) Compare With HEAD Revision (EGit) (on IResource). Action renamed to "Show uncommitted changes". The workspace version is shown on the right (rule #2).
G) Compare With Index (EGit). Action renamed to "Show unstaged changes". The workspace version is shown on the right (rule #2).
H) Compare With Branch, Tag, or Reference (EGit). The workspace version is shown on the left (rule #1).
I) Compare With Commit (EGit). The workspace version is shown on the left (rule #1).
J) Replace With Branch, Tag, or Reference (EGit). The selected version to be used as a replacement is shown on the right (rule #3).
K) Replace With Commit (EGit). The selected commit version to be used as a replacement is shown on the right (rule #3).
L) Compare With Index With HEAD (EGit). Action renamed to "Show staged changes". The index version is shown on the right (rule #2).
M) Compare with Previous Version in History view (EGit). Action renamed to "Show change". The later version is on the right (rule #2).
N) Compare with Working Tree in History view (EGit). The working tree version is shown on the right (rule #1).
O) Compare with Each Other in History view (EGit). See note N2, below.
P) Compare With Each Other in Navigator. See note N2, below.
Q) "Open" in History view (EGit). The later version is on the right (rule #2).
R) Compare with Workspace in History view (EGit). It will continue to keep its current name. The workspace version is shown on the right (rule #1).


Notes:
N1) For any action named "compare", there should always be two ways to invoke the action, allowing the user to view whatever state they want on the left or right. In both situations, the thing the user right-clicked on will always be on the left and the "other" state (which is sometimes implicit) goes on the right. So, for example, the "Compare with Branch, Tag, or Reference" action on IResource and the "Compare with Working Tree" action in the history view can be used to view the same two file states from opposite directions. This is analogous to command-line diff tools where the user may pass whatever state they want as the first and second arguments.

N2) In the case of the two-selection "Compare with Each Other" actions (D, O, P), we have three options. 
N2A) We can either rename these actions to "Show differences" to avoid the verb of "compare", which now has more rigorous semantics.
N2B) The actions are replaced by a new action called "Compare with Version..."/"Compare with File...", etc. which opens a dialog for selecting the right-hand state.
N2C) All such actions can be removed and replaced with a new action called "Compare with Clipboard", combined with additional "Copy" actions that allow you to copy any file state that currently can be the target of one of these "Each other" actions. "Compare with Clipboard" would show the right-clicked version on the left and the clipboard version on the right.

We'd suggest N2C. This would 
- Resolve the ambiguity over which side of the compare viewer is which.
- Give the user control over which way they view their diff.
- Permit a bunch of useful comparisons that aren't currently possible (such as comparing a historical version of one file with the workspace version of another).
- Provide better keyboard accessibility, since nonconsecutive keyboard selections are difficult to do in large views.

N3) Issues with the "Show" actions:

This proposal suggests renaming a bunch of "Compare with XXX" actions to "Show YYY". Many of these actions currently appear below the "Compare With" dropdown on IResource and they have action names of the form XXX such that the sentence "Compare with XXX" parses as a valid English sentence. This could be seen as a flaw in this proposal. It can be resolved in three ways:

N3A) We can ignore it
- There is already precedent for actions in the Compare With submenu that don't form a valid English sentence when prefixed by "Compare With XXX" - namely, the "Index With HEAD" action.
- The fact that these actions work as sentences is a coincidence of English and languages with an English-like word order. Switching to action names that are meaningful in themselves would provide translation strings that are equally meaningful in all languages, even if the English versions would get more verbose.

N3B) The actions can move to the Team menu
- These same actions already appear outside the Compare With submenu when invoked from other contexts (such as the history view), so moving them to another menu is reasonable - particularly if they get new names starting with "Show". There are already other actions in the Team menu named Show that open new UI, and these would be consistent with that metaphor.

N3C) We rename the "Compare With" menu to "Compare"
- This removes the expectation that the elements in the dropdown are nouns that complete an English sentence and brings this menu in line with the rest of the Eclipse UI, where action names are expected to be verbs.

Summary:

The ambiguity of our current compare actions arises because we make use of properties of the selection to determine what side each file state appears on. We can't fix this by selecting a better set of properties. The sort of comparison that the user wants to perform depends entirely on what they are doing at the time, not the file states they've selected - so the determination of what goes on which side of the editor should be entirely under the user's control using only the user's gestures and no additional smarts.
Comment 1 Stefan Xenos CLA 2017-05-11 00:54:24 EDT
*** Bug 504474 has been marked as a duplicate of this bug. ***
Comment 2 Markus Keller CLA 2017-05-11 09:46:16 EDT
I have not checked the proposal in depth yet, but I agree with the direction.

Two points to keep in mind when implementing this:

1. APIs that talk about "left" and "right" must stay stable. No cheating / trying to be helpful for legacy code. Code that already follows the proposal must not need any change.

2. Start by defining an opt-out preference for users/products that prefer the current rules (team provider comparisons put the local workspace version on the left). The preference should initially be enabled by default. Once everything in the Eclipse SDK + EGit has adopted the preference, the default can be set to false and the feature can be announced.
Comment 3 Stefan Xenos CLA 2017-05-11 12:22:44 EDT
We should probably get someone who can speak for EGit on this cc list.
Comment 4 Dani Megert CLA 2017-05-11 12:31:42 EDT
(In reply to Stefan Xenos from comment #3)
> We should probably get someone who can speak for EGit on this cc list.

Adding Matthias.
Comment 5 Carsten Reckord CLA 2017-05-11 15:58:43 EDT
(In reply to Stefan Xenos from comment #0)
> H) Compare With Branch, Tag, or Reference (EGit). The workspace version is
> shown on the left (rule #1).
> I) Compare With Commit (EGit). The workspace version is shown on the left
> (rule #1).

I can understand how you come to this by your set of rules, but isn't this highly inconsistent with any tooling provided by command-line git? 

When I do a "git diff <revision>" on my working tree, the "before"-state is always the <revision> and the "after"-state is my working tree. I would argue that this is the natural way to do it (I want to see what happened in my working tree compared to some other state, hence it is the "after"-state)

Also, while it's "by the rules", it seems inconsistent to E), F) and G):

> E) Compare With Previous Version (EGit) (on IResource). Action renamed to
> "Show changes since previous commit". The workspace version is shown on the
> right (rule #2).
> F) Compare With HEAD Revision (EGit) (on IResource). Action renamed to "Show
> uncommitted changes". The workspace version is shown on the right (rule #2).
> G) Compare With Index (EGit). Action renamed to "Show unstaged changes". The
> workspace version is shown on the right (rule #2).

The only difference that I can see here between H) and I) on one hand, and E)-G) on the other is one of presumed intent, i.e. that for E)-G) the case would be stronger that it's about applying/reviewing an ongoing change, whereas H) and I) are "mere" comparisons.

I would disagree with that interpretation. My use-case for comparing is pretty much the same in both cases: What's the change that my workspace version introduces?

> L) Compare With Index With HEAD (EGit). Action renamed to "Show staged
> changes". The index version is shown on the right (rule #2).
> N) Compare with Working Tree in History view (EGit). The working tree
> version is shown on the right (rule #1).
> R) Compare with Workspace in History view (EGit). It will continue to keep
> its current name. The workspace version is shown on the right (rule #1).

I agree with the result here, having the workspace on the right, although for different reasons: not because the thing I clicked on should be on the left (rule #1), but because the after-state should be on the right (rule #2).
Comment 6 Stefan Xenos CLA 2017-05-11 17:21:08 EDT
> I would argue that this is the natural way to do it (I want to see
> what happened in my working tree compared to some other state, hence it
> is the "after"-state)

That is one of the things the user might be trying to do. However, they might also be previewing a future revert to some other state, in which case the "after" state would be the historical state. Based on what the user intends to do with the information, either one might be the more intuitive presentation.

This is why I'm proposing that we make both presentations available to the user and give them a predictable way to select between them. If they want their workspace version on the left, they right-click on the file and then select the other state in a dialog box. If they want the other state on the left, they right-click in the history view and select "compare with workspace".

In both cases, the thing you right-clicked on goes on the left, which is a very simple rule for users to understand.

Even git diff lets the user choose which version goes on which side. From "git help diff":

> git diff [--options] <commit> <commit> [--] [<path>…​]
> This is to view the changes between two arbitrary <commit>.

In this case, the one the user lists first goes on the "left".

> Also, while it's "by the rules", it seems inconsistent to E), F) and G):

The actions in E, F, and G will be named "Show", not "Compare". That informs the user that the action doesn't follow the rules for a compare action. If you're arguing that the before and after states are unambiguous for E, F, and G, I'd agree with you. That's why I proposed renaming the actions.

However, with H and I, there is no one right answer since there are legitimate use cases for viewing the diff in both directions (understanding historical changes and preparing for a future revert).

My hope is that the rules will be simple enough for end-users to understand, and as long as users understand the rules, anything that is "by the rules" will also feel consistent to the user.

> My use-case for comparing is pretty much the same in both cases: What's
> the change that my workspace version introduces?

I'd completely agree in the case of E-G, where you're viewing your own changes in progress.

However, when we're talking about comparisons with historical versions, I've encountered just as many cases where I wanted to revert to an old version as cases where I wanted to understand the changes introduced since an old revision... and if we were to pick only one of these use-cases as being legitimate, it's going to seem inconsistent to any user with the other use-case. 

That's why I'm suggesting we offer both and give the user a consistent way to understand and control what goes on each side. Just as on the command line "the thing you type first goes on the left", in the UI "the thing you right-clicked on goes on the left". If you want to view the opposite diff, click on the other thing.

As you've probably seen in previous discussions about compare editors, what the user think of as the "after" state can be subjective and depend entirely on their intent. So let's get out of the business of trying to guess the user's most likely intent and just give them simple tools to view whatever diff they want to see.
Comment 7 Eclipse Genie CLA 2020-05-09 18:38:05 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet. As such, we're closing this bug.

If you have further information on the current state of the bug, please add it and reopen this bug. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.

--
The automated Eclipse Genie.
Comment 8 Stefan Xenos CLA 2020-06-19 11:33:15 EDT
Still relevant.
Comment 9 Petr Bodnar CLA 2022-11-13 07:31:45 EST
Looking at this topic and I can see there was a good piece of work done, but I guess it is really hard for anybody to grasp it and take some concrete actions.

IMHO it would help if there was a clear overview of what the current state is and what changes are proposed, together with linking all the related issues that already exist for this topic. Or maybe to break all the stuff into smaller, doable pieces? (Also, while Eclipse migrated from Bugzilla to GitHub, I wonder what is the best place for further discussion?)

(Not that I would have time for some deep discussions, but I have also tried to somewhat summarize the current state of things here: https://bugs.eclipse.org/bugs/show_bug.cgi?id=550896#c6.)
Comment 10 Lars Vogel CLA 2022-11-13 15:36:15 EST
Petr, if you have a patch to improve the situation please propose it as PR or issue via GitHub. I think it is fine to change our defaults as long as we also fix the corresponding unit tests for which I never found the time