Bug 514587 - Add/Open Project activates SVN Discovery Dialog
Summary: Add/Open Project activates SVN Discovery Dialog
Status: RESOLVED FIXED
Alias: None
Product: Subversive
Classification: Technology
Component: UI (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows NT
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: Alexander Gurov CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-04-01 07:50 EDT by Ed Willink CLA
Modified: 2017-04-24 04:01 EDT (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Ed Willink CLA 2017-04-01 07:50:07 EDT
After installing Subversive as part of the 

https://dev.eclipse.org/mhonarc/lists/cross-project-issues-dev/msg14346.html

discussion, the OCL Plugin tests now stall because the Subversion Dialog opens even though Subversive is not in use.

It appears that the SVNFolderListener is listening without care to any project chnage and so invokes SVNTeamPlugin.instance() that triggers the discovery. Trace below.

(Repro: run the org.eclipse.ocl.examples.test.xtext.UsageTests subset of the org.eclipse.ocl.examples.xtext.tests (plugin) launch.)

Trace:

Thread [Worker-0] (Suspended (breakpoint at line 175 in SVNTeamUIPlugin))	
	owns: Class<T> (org.eclipse.team.svn.core.extension.CoreExtensionsManager) (id=768)	
	SVNTeamUIPlugin.discoveryConnectors() line: 175	
	SVNTeamUIPlugin.start(BundleContext) line: 147	
	BundleContextImpl$3.run() line: 779	
	BundleContextImpl$3.run() line: 1	
	AccessController.doPrivileged(PrivilegedExceptionAction<T>) line: not available [native method]	
	BundleContextImpl.startActivator(BundleActivator) line: 772	
	BundleContextImpl.start() line: 729	
	EquinoxBundle.startWorker0() line: 933	
	EquinoxBundle$EquinoxModule.startWorker() line: 309	
	EquinoxBundle$EquinoxModule(Module).doStart(Module$StartOptions...) line: 581	
	EquinoxBundle$EquinoxModule(Module).start(Module$StartOptions...) line: 449	
	SecureAction.start(Module, Module$StartOptions...) line: 468	
	EclipseLazyStarter.postFindLocalClass(String, Class<?>, ClasspathManager) line: 103	
	ClasspathManager.findLocalClass(String) line: 529	
	EquinoxClassLoader(ModuleClassLoader).findLocalClass(String) line: 328	
	BundleLoader.findLocalClass(String) line: 359	
	BundleLoader.findClassInternal(String, boolean) line: 437	
	BundleLoader.findClass(String, boolean) line: 386	
	BundleLoader.findClass(String) line: 378	
	EquinoxClassLoader(ModuleClassLoader).loadClass(String, boolean) line: 150	
	EquinoxClassLoader(ClassLoader).loadClass(String) line: 357	
	EquinoxBundle.loadClass(String) line: 564	
	EquinoxRegistryStrategy(RegistryStrategyOSGI).createExecutableExtension(RegistryContributor, String, String) line: 174	
	ExtensionRegistry.createExecutableExtension(RegistryContributor, String, String) line: 905	
	ConfigurationElement.createExecutableExtension(String) line: 243	
	ConfigurationElementHandle.createExecutableExtension(String) line: 55	
	CoreExtensionsManager.loadExtensions(String, String) line: 302	
	CoreExtensionsManager.loadCoreExtensions(String) line: 287	
	CoreExtensionsManager.instance() line: 66	
	SVNTeamPlugin.getOptionProvider() line: 116	
	SVNFolderListener$1$1.visit(IResourceDelta) line: 72	
	ResourceDelta.accept(IResourceDeltaVisitor, int) line: 64	
	ResourceDelta.accept(IResourceDeltaVisitor, int) line: 75	
	ResourceDelta.accept(IResourceDeltaVisitor) line: 48	
	SVNFolderListener$1.run(IProgressMonitor) line: 59	
	Workspace.run(ICoreRunnable, ISchedulingRule, int, IProgressMonitor) line: 2240	
	Workspace.run(IWorkspaceRunnable, ISchedulingRule, int, IProgressMonitor) line: 2267	
	SVNFolderListener.resourceChanged(IResourceChangeEvent) line: 57	
	NotificationManager$1.run() line: 299	
	SafeRunner.run(ISafeRunnable) line: 42	
	NotificationManager.notify(ResourceChangeListenerList$ListenerEntry[], ResourceChangeEvent, boolean) line: 289	
	NotificationManager.broadcastChanges(ElementTree, ResourceChangeEvent, boolean) line: 152	
	Workspace.broadcastBuildEvent(Object, int, int) line: 360	
	AutoBuildJob.doBuild(IProgressMonitor) line: 138	
	AutoBuildJob.run(IProgressMonitor) line: 232	
	Worker.run() line: 56
Comment 1 Alexander Gurov CLA 2017-04-23 05:10:30 EDT
(In reply to Ed Willink from comment #0)
> It appears that the SVNFolderListener is listening without care to any
> project chnage and so invokes SVNTeamPlugin.instance() that triggers the
> discovery. Trace below.
I don't think it is proper to say it is done "without care" since there is a reason for everything:
https://bugs.eclipse.org/bugs/show_bug.cgi?id=364569
If a proper API was provided 2 years ago (as it was suggested in bug 364569) there would be no need to "listen without care" in the first place. Then there is a matter of "any project change". It isn't any, it is exactly a project addition event that must be processed in order to provide the automatic project share functionality.

I'll try to find a way to reduce the chance of situation happening (and hope that changes will not cause a great amount of complaints), but the code is there for a reason, it was requested by many, so that they could manage to install connectors easily.
Comment 2 Alexander Gurov CLA 2017-04-23 05:49:47 EDT
(In reply to Ed Willink from comment #0)
> discussion, the OCL Plugin tests now stall because the Subversion Dialog
> opens even though Subversive is not in use.
Also what interest me here the most is that Subversive discovery feature won't activate at all if there are no SVN-related projects in the workspace:

	protected void initialDiscoveryActivation() throws Exception {
		IPreferenceStore store = this.getPreferenceStore();
		if (store.getBoolean(SVNTeamPreferences.FIRST_STARTUP) || 
			this.isConnectorsRequired()) {
			store.setValue(SVNTeamPreferences.FIRST_STARTUP, false);
			this.savePreferences();
			PlatformUI.getWorkbench().getDecoratorManager().
				setEnabled(SVNLightweightDecorator.ID, true);
			
			//run discovery connectors
			this.discoveryConnectors();	
		}
	}
	
	protected boolean isConnectorsRequired() {
		boolean svnProjectFound = false;
		IProject []projects = 
			ResourcesPlugin.getWorkspace().getRoot().getProjects();
		for (int i = 0; i < projects.length; i++) {
			svnProjectFound |= 
			projects[i].findMember(SVNUtility.getSVNFolderName()) != null || 
			FileUtility.isConnected(projects[i]);
			if (svnProjectFound) {
				break;
			}
		}
		return svnProjectFound && !CoreExtensionsManager.
		isExtensionsRegistered(CoreExtensionsManager.SVN_CONNECTOR);
	}

So, whatever I do from now on in order to not activate UI plug-in when it is unnecessary, won't help in this exact case, because THERE ARE SVN-related projects in workspace, some of them ARE ADDED and SVN team plug-in MUST check if they should be automatically SHARED and this is where the SVN connectors are required, right?
Comment 3 Ed Willink CLA 2017-04-23 06:12:55 EDT
(Now that GIT is becoming so dominant, SVN is less important. My only SVN projects are documentation projects hosted by the OMG which still uses an SVN 5 server which has a capability discovery incompatibility wrt SVN 8, so I have to make sure I use an old TortoiseSVN 7 for them.)

(Add Project is not an Eclipse startup activity and so an over-enthusiastic SVN dialog does not seem like a disaster. I only hit this bug because I was specifically investigating. If I actually needed SVN in my workspace again, I could re-instate a manual set-preference as part of my test preamble.)

However, it would seem possible to ensure that your analysis of whether a new project uses SVN could be done without needing the connectors. Surely a simple anayysis of file names gives you the clues you need?
Comment 4 Alexander Gurov CLA 2017-04-23 13:09:05 EDT
(In reply to Ed Willink from comment #3)
> However, it would seem possible to ensure that your analysis of whether a
> new project uses SVN could be done without needing the connectors. Surely a
> simple analysis of file names gives you the clues you need?

Yes. And that is what I'm getting at. The code that currently exists actually do prevents activation of connectors discovery feature in case there are no projects with related .svn folders. So, I kind of do not understand how is it that you've got a situation when you do not have SVN related projects at all but stumbled upon the dialog suggesting connectors installation.
Comment 5 Alexander Gurov CLA 2017-04-23 13:17:36 EDT
However, is it possible that you do actually have a project with .svn folder in your workspace, while the added project wasn't a SVN-related one? If this is the case, the change I'm making should help, since the SVN UI plug-in (which actually runs discovery feature) now won't be even activated if the added project is not related to SVN.
Comment 6 Alexander Gurov CLA 2017-04-23 13:39:58 EDT
Hmm, it seems I've found another issue with the activation condition :)
On first IDE start it'll activate even if there are no SVN-related projects, it seems. So, I'll fix it.
Comment 7 Alexander Gurov CLA 2017-04-23 14:11:49 EDT
1) Activation condition has been fixed. 
2) UI plug-in now won't start if the added project is not related to SVN.
Comment 8 Ed Willink CLA 2017-04-24 03:56:40 EDT
(In reply to Alexander Gurov from comment #5)
> if the added project is not related to SVN.

This is the key. I certainly had projects with .svn file names, but the added project did not. Seems like you've now caught this case.
Comment 9 Alexander Gurov CLA 2017-04-24 04:01:01 EDT
Yes, thank you for your help.