| Summary: | Compare editor: Java Structure Compare considers left as remote and right as local | ||||||||
|---|---|---|---|---|---|---|---|---|---|
| Product: | z_Archived | Reporter: | Robert Munteanu <robert.munteanu> | ||||||
| Component: | Mylyn | Assignee: | Steffen Pingel <steffen.pingel> | ||||||
| Status: | RESOLVED FIXED | QA Contact: | |||||||
| Severity: | normal | ||||||||
| Priority: | P3 | ||||||||
| Version: | 0.8 | ||||||||
| Target Milestone: | 0.9 | ||||||||
| Hardware: | PC | ||||||||
| OS: | Linux | ||||||||
| Whiteboard: | |||||||||
| Attachments: |
|
||||||||
|
Description
Robert Munteanu
Created attachment 205018 [details]
Compare editor with incorrect java structure compare
On the left side the local file ( revision 3 ) has a skeleton content, and on the right side the file has no content.
Nevertheless, Java Structure Compare shows all structural elements as removed, not as added.
The relevant code snippet in my CompareEditorInput implementation is
pre..
private Object findDifferences(IProgressMonitor monitor, IFilePatchResult patchResult) throws IOException {
byte[] baseContent = IOUtils.toByteArray(patchResult.getOriginalContents());
byte[] targetContent = IOUtils.toByteArray(patchResult.getPatchedContents());
ByteArrayInput baseInput = new ByteArrayInput(baseContent, getFile().getBase().getPath());
ByteArrayInput targetInput = new ByteArrayInput(targetContent, getFile().getTarget().getPath());
Object differences = new Differencer().findDifferences(false, monitor, null, null, baseInput, targetInput);
monitor.worked(1);
return differences;
}
Thanks for the bug report. The same problem exists with the Gerrit connector. I swapped the inputs and fixed a number of bugs in ReviewAnnotationModel and ReviewCompareAnnotationModel. The compare editor should now follow the expected Eclipse behavior even though this is reverse from the layout in the Gerrit web UI. This has caused a regression in how comment annotations are added. Even though I add comment annotations to the target, they are displayed on the base. Reverting the commit fixes the problem. I have tested this with Gerrit and comments were added as expected. Can you check the implementation of your behavior? Created attachment 205191 [details]
Annotations reversed after patch
I'm unable to find the flaw ; I can easily reverse my logic, but I just wanted to verify that I'm not missing something obvious.
The code in question is
pre..
IFileRevision base = getFile().getBase();
IFileRevision target = getFile().getTarget();
ByteArrayInput baseInput = new ByteArrayInput(baseContent, base.getPath());
ByteArrayInput targetInput = new ByteArrayInput(targetContent, target.getPath());
System.out.println("Topics for BASE - " + base.getRevision() + " : " + base.getTopics().size());
System.out.println("Topics for TARGET - " + target.getRevision() +" : " + target.getTopics().size());
Object differences = new Differencer().findDifferences(false, monitor, null, null, baseInput, targetInput);
p.
The result is
pre..
Topics for BASE - 3 : 0
Topics for TARGET - (working copy) : 3
p.
The title of the compare editor shows that the base is displayed on the left and the target on the right, but the annotationsa are switched.
Do you see any problem with this implementation?
Based on your input I reverted the implementation in the framework. ReviewCompareEditorInput now computes the differences like this to find the right additions and removals: Differencer differencer = new Differencer(); Object diff = differencer.findDifferences(false, monitor, null, null, new ByteArrayInput(targetContent, targetPath), new ByteArrayInput(baseContent, basePath)); Did you push the change to git.eclipse.org? There seem to be no changes in the reviews repository. (In reply to comment #8) > Based on your input I reverted the implementation in the framework. > ReviewCompareEditorInput now computes the differences like this to find the > right additions and removals: Just to clarify, this was part of the change that I originally committed for this bug. I haven't made any further changes so far. After reviewing the behavior of CVS and Git my understanding is that Eclipse displays the newer content on the left be default hence it seems right to display the target content on the left. Does that make sense to you? Yes, it makes sense. I have changed my implementation to act the same. Feel free to close this again. Thanks! Please feel free to reopen if we should tweak this further. |