Bug 410534 - [regression] compare editor structure view shows additions as deletions and vice versa
Summary: [regression] compare editor structure view shows additions as deletions and v...
Status: RESOLVED FIXED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows 7
: P2 normal (vote)
Target Milestone: 2.0.1   Edit
Assignee: Miles Parker CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-06-11 16:16 EDT by Sam Davis CLA
Modified: 2013-07-18 19:42 EDT (History)
2 users (show)

See Also:


Attachments
mylyn/context/zip (19.38 KB, application/octet-stream)
2013-07-02 06:42 EDT, Tomasz Zarna CLA
no flags Details
mylyn/context/zip (165.34 KB, application/octet-stream)
2013-07-02 15:14 EDT, Miles Parker CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sam Davis CLA 2013-06-11 16:16:50 EDT
The compare editor structure view shows added methods with a - sign and deleted methods with a + sign.
Comment 1 Miles Parker CLA 2013-06-11 16:26:44 EDT
I could swear that we had this in a bug somewhere else. This must have happened with:

12242: 381265: compare editor shows changes on wrong side [I4cbaaaf6]
https://git.eclipse.org/r/#/c/12242/
Comment 2 Steffen Pingel CLA 2013-06-11 17:37:58 EDT
That's kind of funny. Let's look at that for 2.0.1.
Comment 3 Miles Parker CLA 2013-06-26 14:10:35 EDT
This one is harder than it looks! I thought I found a simple change to make this work, but it doesn't seem to accomplish anything.
Comment 4 Miles Parker CLA 2013-06-26 18:05:07 EDT
https://git.eclipse.org/r/#/c/14086/  <- This doesn't actually do anything except clean up some dead code.

Sebastien, any ideas about what the issue here might be?
Comment 5 Sebastien Dubois CLA 2013-06-27 11:22:45 EDT
(In reply to comment #4)
> https://git.eclipse.org/r/#/c/14086/  <- This doesn't actually do anything
> except clean up some dead code.
> 
> Sebastien, any ideas about what the issue here might be?

Hmm, no I do not remember this one, sorry.

/Sebas
Comment 6 Sam Davis CLA 2013-06-27 14:04:05 EDT
Tomek, do you know what would cause this?
Comment 7 Tomasz Zarna CLA 2013-07-02 06:42:09 EDT
After having a glimpse at the code, my _guess_ would be that StructureDiffViewer [1] swaps sides of the comparison if you have the old version (Base) of the file in your workspace. If you're way behind, i.e. have neither old nor new version checked out, the diff should be displayed correctly.

[1] https://git.eclipse.org/c/platform/eclipse.platform.team.git/tree/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/StructureDiffViewer.java#n477
Comment 8 Tomasz Zarna CLA 2013-07-02 06:42:13 EDT
Created attachment 232975 [details]
mylyn/context/zip
Comment 9 Miles Parker CLA 2013-07-02 15:14:46 EDT
(In reply to comment #7)
> After having a glimpse at the code, my _guess_ would be that StructureDiffViewer
> [1] swaps sides of the comparison if you have the old version (Base) of the file
> in your workspace. If you're way behind, i.e. have neither old nor new version
> checked out, the diff should be displayed correctly.

Thanks for the hint. After playing around with this a bit, the code seems a bit crazy. ;) While DiffTreeViewer respects the "LEFT_IS_LOCAL" property [1], it actually seems to be ignored in the configuration itself. In CompareConfiguration [2] is a static value for fLeftIsLocal. That is used to swap the sides for the comparison kind in a static method. So there is no way to change the value for the swap! Further, if I change the value from default of true, the Java Structure Compare (right) is correct, but the Structure Side (left) is now wrong!

[1] https://git.eclipse.org/c/platform/eclipse.platform.team.git/tree/bundles/org.eclipse.compare/compare/org/eclipse/compare/structuremergeviewer/DiffTreeViewer.java#n186
[2] https://git.eclipse.org/c/platform/eclipse.platform.team.git/tree/bundles/org.eclipse.compare/compare/org/eclipse/compare/CompareConfiguration.java#n75
Comment 10 Miles Parker CLA 2013-07-02 15:14:50 EDT
Created attachment 233002 [details]
mylyn/context/zip
Comment 11 Miles Parker CLA 2013-07-02 16:11:46 EDT
https://git.eclipse.org/r/#/c/14086/4 Fixes with a relatively straightforward hack. This seems to be the simplest way to retrieve the desired behavior w/o getting too deeply into compare internals.

Tomek, please Review. https://git.eclipse.org/r/#/c/14086/4/org.eclipse.mylyn.reviews.ui/src/org/eclipse/mylyn/internal/reviews/ui/compare/ReviewItemSetCompareEditorInput.java are the relevant changes.
Comment 12 Tomasz Zarna CLA 2013-07-03 06:24:12 EDT
If you think it's a bug in Platform/Compare I would recommend at least filing a bug against them. I'm aware that even having them* fix this, will mean we have to wait for Luna to consume it, but at the same time it's going to allow us to understand what's going on there, and potentially provide a proper workaround (instead of a hack).

* that includes me as I'm a committer on that project
Comment 13 Miles Parker CLA 2013-07-03 19:41:04 EDT
(In reply to comment #12)
> If you think it's a bug in Platform/Compare I would recommend at least filing a
> bug against them. I'm aware that even having them* fix this, will mean we have
> to wait for Luna to consume it, but at the same time it's going to allow us to
> understand what's going on there, and potentially provide a proper workaround
> (instead of a hack).
> 
> * that includes me as I'm a committer on that project

I'm not sure it's a bug so much as kind of sub-optimal implementation. Anyway, I managed to get it working through this hack. We just need to ensure that there aren't any cases where the original implementation actualy worked. I haven't seen any. Has anyone else?
Comment 14 Sam Davis CLA 2013-07-08 14:43:34 EDT
I haven't either. But it does seem like a bug in Platform/Compare that the structure compare is not consistent with the status line. What will happen if we apply this change and then that is fixed?
Comment 15 Miles Parker CLA 2013-07-08 14:49:32 EDT
(In reply to comment #14)
> What will happen if we apply this change and then that is fixed?

It'll mean that we're just as broken as every other Compare Editor consumer then will be. ;D Seriously, I have no idea what form a useful fix might take and considering the number of consumers out there, I imaginve platform would be esitant to fix it at this point if the broken behaviour is going to change. Perhaps we can leave that to Tomek as to whether to pursue that one further.
Comment 16 Sam Davis CLA 2013-07-09 14:54:40 EDT
I am OK with applying this fix.
Comment 17 Miles Parker CLA 2013-07-09 15:03:37 EDT
(In reply to comment #16)
> I am OK with applying this fix.

Just for the sake of process then, could you +1 on review please?
Comment 18 Sam Davis CLA 2013-07-09 16:17:20 EDT
Done.
Comment 19 Miles Parker CLA 2013-07-09 16:40:06 EDT
Thanks Sam. That's my anal process guy comment of the month. Got to turn it over every once in a while or it gets rusty.

Merged https://git.eclipse.org/r/#/c/14086/
Comment 20 Miles Parker CLA 2013-07-09 16:46:11 EDT
[I lied: now I'm finding myself commenting on Commit messages which I swore I'd never do. ;D https://git.eclipse.org/r/#/c/14232/5//COMMIT_MSG]
Comment 21 Sam Davis CLA 2013-07-17 00:00:07 EDT
This fixed the problem for the compare with action, but it did not fix it when an individual compare editor is opened from the review.
Comment 22 Miles Parker CLA 2013-07-18 13:25:58 EDT
(In reply to comment #21)
> This fixed the problem for the compare with action, but it did not fix it when
> an individual compare editor is opened from the review.

That's interesting / annoying. I'll take a look.
Comment 23 Miles Parker CLA 2013-07-18 13:58:59 EDT
Please review: https://git.eclipse.org/r/14664 This was an oversight -- I made change to ReviewItemSetCompareEditorInput but not the File version.
Comment 24 Miles Parker CLA 2013-07-18 19:42:17 EDT
(re) fixed with https://git.eclipse.org/r/14664