DESCRIPTION

Use the source revision instead of local data for synchronizations

EGit allows for comparisons with three remote revisions (notably through
"synchronize with each other" with two branches selected in the
repository explorer). However, Team always uses the local data as the
"source" (or left) side of a comparison. This patch allows us to use the
actual source commit instead of the local file when needed.

This also changes GitModelSynchronizeParticipant#asCompareInput() since
we can use the cached content fetched by the subscriber context instead
of re-fetching it from the remote.

Bug: 403363
Change-Id: I23e0f1e75b9c6d476f8ed5a24deac7cc7b64dd42


COMMENTS

author: Gustavo Green
date: 2013-03-25 12:48:38.000000000

Uploaded patch set 3.

-------------------------------------
author: Brenden Conley
date: 2013-03-25 12:48:44.000000000

Patch Set 3:

Build Started https://hudson.eclipse.org/sandbox/job/egit.gerrit/4330/ 

-------------------------------------
author: Brenden Conley
date: 2013-03-25 12:51:52.000000000

Patch Set 3: Fails

Build Failed 

https://hudson.eclipse.org/sandbox/job/egit.gerrit/4330/ : FAILURE

-------------------------------------
author: Gustavo Green
date: 2013-03-25 12:57:15.000000000

Patch Set 3:

That was one of the "random" failures... could you kick another build?

-------------------------------------
author: Brenden Conley
date: 2013-03-26 21:18:01.000000000

Patch Set 3: No score

Build Started https://hudson.eclipse.org/sandbox/job/egit.gerrit/4331/ 

-------------------------------------
author: Brenden Conley
date: 2013-03-26 21:33:36.000000000

Patch Set 3: Verified

Build Successful 

https://hudson.eclipse.org/sandbox/job/egit.gerrit/4331/ : SUCCESS

-------------------------------------
author: Douglas Trujillo
date: 2013-04-09 22:14:37.000000000

Patch Set 3: I would prefer that you didn't submit this

(7 inline comments)

Trying different scenarios I didn't find any wrong behavior so far but came across the following exceptions, don't know yet which exact use case is causing them

!ENTRY org.eclipse.ui 4 0 2013-04-10 00:09:42.744
!MESSAGE Unhandled event loop exception
!STACK 0
org.eclipse.swt.SWTException: Failed to execute runnable (java.lang.ClassCastException: org.eclipse.egit.ui.internal.FileRevisionTypedElement cannot be cast to org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement)
	at org.eclipse.swt.SWT.error(SWT.java:4392)
	at org.eclipse.swt.SWT.error(SWT.java:4307)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:138)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:3974)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3651)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1108)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:992)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:137)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:600)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)
Caused by: java.lang.ClassCastException: org.eclipse.egit.ui.internal.FileRevisionTypedElement cannot be cast to org.eclipse.team.internal.ui.synchronize.LocalResourceTypedElement
	at org.eclipse.team.internal.ui.mapping.ResourceDiffCompareInput.update(ResourceDiffCompareInput.java:279)
	at org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier.fireChange(CompareInputChangeNotifier.java:389)
	at org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier.fireChanges(CompareInputChangeNotifier.java:295)
	at org.eclipse.team.internal.ui.mapping.CompareInputChangeNotifier$1.run(CompareInputChangeNotifier.java:253)
	at org.eclipse.ui.internal.UILockListener.doPendingWork(UILockListener.java:164)
	at org.eclipse.ui.internal.UISynchronizer$3.run(UISynchronizer.java:158)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:135)
	... 24 more

!ENTRY org.eclipse.jface 4 2 2013-04-10 00:10:21.090
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jface".
!STACK 0
org.eclipse.core.runtime.AssertionFailedException: null argument:
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:85)
	at org.eclipse.core.runtime.Assert.isNotNull(Assert.java:73)
	at org.eclipse.egit.ui.internal.FileRevisionTypedElement.<init>(FileRevisionTypedElement.java:45)
	at org.eclipse.egit.ui.internal.synchronize.GitModelSynchronizeParticipant.asCompareInput(GitModelSynchronizeParticipant.java:240)
	at org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction.openCompareEditor(OpenInCompareAction.java:113)
	at org.eclipse.team.internal.ui.synchronize.actions.OpenInCompareAction.run(OpenInCompareAction.java:68)
	at org.eclipse.team.ui.synchronize.ModelSynchronizeParticipantActionGroup$1.run(ModelSynchronizeParticipantActionGroup.java:103)
	at org.eclipse.egit.ui.internal.synchronize.action.GitOpenInCompareAction.run(GitOpenInCompareAction.java:71)
	at org.eclipse.team.internal.ui.synchronize.StructuredViewerAdvisor.handleOpen(StructuredViewerAdvisor.java:189)
	at org.eclipse.team.internal.ui.synchronize.StructuredViewerAdvisor.access$0(StructuredViewerAdvisor.java:185)
	at org.eclipse.team.internal.ui.synchronize.StructuredViewerAdvisor$3.open(StructuredViewerAdvisor.java:146)
	at org.eclipse.ui.OpenAndLinkWithEditorHelper$InternalListener.open(OpenAndLinkWithEditorHelper.java:47)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:866)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:864)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1152)
	at org.eclipse.ui.navigator.CommonViewer.handleOpen(CommonViewer.java:462)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1256)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:275)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:269)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:309)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4164)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1466)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1489)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1474)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4010)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3649)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$9.run(PartRenderingEngine.java:1108)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:992)
	at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:137)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:600)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:555)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:124)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:354)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:181)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:636)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:591)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1450)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1426)

Line:44, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitLocalResourceVariant.java -> style nit: no braces here

Line:245, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java -> shouldn't we log the exception ?

Line:285, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> style nit: no braces around single line blocks

Line:312, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> style nit: no braces

Line:349, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> we should log the exception

Line:366, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> style nit: no braces here

Line:406, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> typo: s/Gir/Git/

-------------------------------------
author: Gustavo Green
date: 2013-04-10 08:37:05.000000000

Patch Set 3: (7 inline comments)



Line:44, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitLocalResourceVariant.java -> Done

Line:245, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/synchronize/GitModelSynchronizeParticipant.java -> Now that I think about it a little more, yes, it should be logged. We're falling back to the "super" input... which will have the local IResource for "left" instead of the desired remote. Though this will work, it's still better to tell users about it.

Done.

Line:285, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> Done

Line:312, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> Done

Line:349, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> Done

Line:366, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> I can't believe I still leave so many of these in....

Anyway, Done.

Line:406, org.eclipse.egit.core/src/org/eclipse/egit/core/synchronize/GitResourceVariantTreeSubscriber.java -> Done

-------------------------------------
