DESCRIPTION

Disable "Replace with" and "Compare with" <version> for untracked files

Replace with and compare with HEAD, index, previous version, branch,
tag, reference or commit don't make sense for untracked files. Hence
these operations should be disabled on untracked files. Use cached
IndexDiff to avoid performance problems.

Bug: 384602
Change-Id: I808f9a4f3ce8380c2790754cff6dcaf7e8e56af2
Signed-off-by: Douglas Trujillo xxx@xxx.xxx

COMMENTS

author: Douglas Trujillo
date: 2015-03-11 04:03:51.000000000

Uploaded patch set 1.

-------------------------------------
author: Brenden Conley
date: 2015-03-11 04:03:57.000000000

Patch Set 1:

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

-------------------------------------
author: Douglas Trujillo
date: 2015-03-11 04:05:13.000000000

Patch Set 1:

Andrey: can you try this on your large repo, using the cached indexdiff should be pretty fast

-------------------------------------
author: Brenden Conley
date: 2015-03-11 04:26:43.000000000

Patch Set 1: Verified+1

Build Successful 

https://hudson.eclipse.org/egit/job/egit.gerrit/6792/ : SUCCESS

-------------------------------------
author: Jayvion Booth
date: 2015-03-11 05:41:31.000000000

Patch Set 1:

I *will* check it, please don''t integrate yet.

-------------------------------------
author: Jayvion Booth
date: 2015-03-11 15:33:11.000000000

Patch Set 1: Code-Review-1

(3 comments)

Matthias, please see the comments. I haven't chance to test in the debugger yet (I have to update my target platform now but this takes time), but the main issue is that the diff can not be calculated yet (diff time is between 30 and 8 seconds, depending on IO load and file cache for our repo).

After securing the obvious NPE places the patch looks OK for me, but I would like to see it in the debugger first.

Line:520, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java -> We must check here if indexDiff is not null, see comment to the getIndexDiff() method.

Line:530, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/RepositoryActionHandler.java -> The method should have javadoc stating that the return value can be null if the index diff tata is not calculated yet, and that the caller must check it!

Line:167, org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/actions/CompareIndexWithHeadActionHandler.java -> We must check here if indexDiff is not null, see comment to the getIndexDiff() method.

In case it is null, and we are called from the diff job, we should partly revert the  code (for "enablement" we can just say we don't care, but for the actual diff we *must* know the real state).

-------------------------------------
author: Jayvion Booth
date: 2015-03-11 15:46:56.000000000

Patch Set 1:

As expected, I saw lot of NPE's like this below in debugger:

java.lang.NullPointerException
	at org.eclipse.egit.ui.internal.actions.RepositoryActionHandler.selectionContainsTrackedFiles(RepositoryActionHandler.java:522)
	at org.eclipse.egit.ui.internal.actions.DiscardChangesActionHandler.isEnabled(DiscardChangesActionHandler.java:87)
	at org.eclipse.egit.ui.internal.actions.RepositoryAction.isEnabled(RepositoryAction.java:149)
	at org.eclipse.egit.ui.internal.actions.RepositoryAction.selectionChanged(RepositoryAction.java:123)
	at org.eclipse.ui.internal.PluginAction.refreshEnablement(PluginAction.java:206)
	at org.eclipse.ui.internal.PluginAction.selectionChanged(PluginAction.java:277)
	at org.eclipse.ui.internal.ObjectActionContributor$1.run(ObjectActionContributor.java:157)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.ObjectActionContributor.contributeObjectActions(ObjectActionContributor.java:160)
	at org.eclipse.ui.internal.ObjectActionContributorManager.contributeObjectActions(ObjectActionContributorManager.java:97)
	at org.eclipse.ui.internal.PopupMenuExtender.addObjectActions(PopupMenuExtender.java:262)
	at org.eclipse.ui.internal.PopupMenuExtender.menuAboutToShow(PopupMenuExtender.java:339)
	at org.eclipse.jface.action.MenuManager.fireAboutToShow(MenuManager.java:342)
	at org.eclipse.jface.action.MenuManager.handleAboutToShow(MenuManager.java:473)
	at org.eclipse.jface.action.MenuManager.access$1(MenuManager.java:469)
	at org.eclipse.jface.action.MenuManager$2.menuShown(MenuManager.java:495)
	at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:255)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1276)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1300)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1281)
	at org.eclipse.swt.widgets.Menu._setVisible(Menu.java:198)
	at org.eclipse.swt.widgets.Display.runPopups(Display.java:3596)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3169)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
	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:353)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:180)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:629)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:584)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1438)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1414)

-------------------------------------
author: Jayvion Booth
date: 2015-03-11 15:52:27.000000000

Patch Set 1:

Hmm. "Compare Index with Head" is always disabled and "Compare with Index" is always enabled, independently what I do with the file, as if someone would cache the data... I will debug it later.

-------------------------------------
author: Douglas Trujillo
date: 2015-03-11 20:49:48.000000000

Patch Set 1: Code-Review-1

besides the NPEs this needs more work, e.g. compare with index makes sense for a freshly added file, but compare with HEAD does not

-------------------------------------
author: Douglas Trujillo
date: 2016-11-28 08:42:49.000000000

Abandoned

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