Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephane Bouchet2015-05-07 10:11:12 +0000
committerStephane Bouchet2015-12-16 13:50:49 +0000
commite846ffb0f21624687ae74bac4a366e95d584416c (patch)
tree9adf9c5c05241aa608bbc0b03753ab0959a46e51 /plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector
parent8dc98e1046a5dc0ec196b3965eb45b9c57cb231d (diff)
downloadorg.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.tar.gz
org.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.tar.xz
org.eclipse.emf.diffmerge.core-e846ffb0f21624687ae74bac4a366e95d584416c.zip
Eclipse Team integration for DiffMerge
[466706] Support Local history [466427] Support Git Scm [482287] Support SVN Scm [482288] Support Perforce Scm Added support for local history, git, svn and perforce. Updated test model. Change-Id: I9b9929bbb5a74220619d4fce55b251efd18f8631 Signed-off-by: Stephane Bouchet <stephane.bouchet@intel.com> Bug: https://bugs.eclipse.org/466706
Diffstat (limited to 'plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector')
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java47
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java57
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java85
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java91
-rw-r--r--plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java83
5 files changed, 363 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java
new file mode 100644
index 00000000..2d087005
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/EMFDiffmergeSVNConnectorPlugin.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector;
+
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+public class EMFDiffmergeSVNConnectorPlugin extends AbstractUIPlugin {
+
+ public static final String PLUGIN_ID="org.eclipse.emf.diffmerge.connector.svn";
+ private static EMFDiffmergeSVNConnectorPlugin instance;
+
+ public EMFDiffmergeSVNConnectorPlugin() {
+ super();
+ }
+
+ public static EMFDiffmergeSVNConnectorPlugin getInstance() {
+ return instance;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ instance=this;
+ }
+
+ /**
+ * @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+ */
+ @Override
+ public void stop(BundleContext context) throws Exception {
+ instance=null;
+ super.stop(context);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java
new file mode 100644
index 00000000..2747a86b
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNLocalScopeDefinitionFactory.java
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.LocalScopeDefinition;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.team.svn.ui.compare.ResourceCompareInput.ResourceElement;
+
+public class SVNLocalScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof ResourceElement && ((ResourceElement) entrypoint).isEditable();
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(Object entrypoint, String label, boolean editable) {
+ try {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ final URI uri = getUri(res);
+ return new LocalScopeDefinition(uri, label, editable);
+ } catch (SecurityException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalArgumentException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return null;
+ }
+
+ private URI getUri(ResourceElement res) {
+ return URI.createPlatformResourceURI(res.getLocalResource().getResource().getFullPath().toOSString(), true);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java
new file mode 100644
index 00000000..e3796839
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRemoteScopeDefinitionFactory.java
@@ -0,0 +1,85 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.diffmerge.connector.core.StreamScopeDefinition;
+import org.eclipse.emf.diffmerge.ui.gmf.GMFScopeDefinitionFactory;
+import org.eclipse.emf.diffmerge.ui.specification.IModelScopeDefinition;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.svn.core.connector.SVNConnectorException;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.ui.compare.ResourceCompareInput.ResourceElement;
+
+public class SVNRemoteScopeDefinitionFactory extends GMFScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>> singleton(GMFScopeDefinitionFactory.class);
+ }
+
+ @Override
+ public boolean isApplicableTo(Object entrypoint) {
+ return entrypoint instanceof ResourceElement && !((ResourceElement) entrypoint).isEditable();
+ }
+
+ @Override
+ public IModelScopeDefinition createScopeDefinition(Object entrypoint, String label, boolean editable) {
+ try {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ final URI uri = getUri(res);
+ return new StreamScopeDefinition(entrypoint, (label != null) ? label : getLabelFor(entrypoint), uri,
+ res.getContents(), getURIConverter(res));
+ } catch (SecurityException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ } catch (IllegalArgumentException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return null;
+ }
+
+ private URI getUri(ResourceElement res) {
+ return URI.createURI(res.getRepositoryResource().getUrl());
+
+ }
+
+ private URIConverter getURIConverter(ResourceElement res) {
+ return new SVNStreamURIConverter(res.getRepositoryResource().getRepositoryLocation(),
+ res.getRepositoryResource().getSelectedRevision());
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ final ResourceElement res = (ResourceElement) entrypoint;
+ SVNRevision rev = res.getRepositoryResource().getSelectedRevision();
+ try {
+ if (rev.equals(SVNRevision.BASE))
+ return res.getRepositoryResource().getUrl() + " [BASE]";
+ else if (rev.equals(SVNRevision.HEAD))
+ return res.getRepositoryResource().getUrl() + " [HEAD]";
+ else
+ return res.getRepositoryResource().getUrl() + " [Rev:"
+ + Long.toString(res.getRepositoryResource().getRevision()) + "]";
+ } catch (SVNConnectorException e) {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, e.getMessage(), e));
+ }
+ return res.getName();
+ }
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java
new file mode 100644
index 00000000..ea320328
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNRevisionScopeDefinitionFactory.java
@@ -0,0 +1,91 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.util.Collection;
+import java.util.Collections;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.core.resources.IStorage;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.core.FileRevisionScopeDefinitionFactory;
+import org.eclipse.emf.ecore.resource.URIConverter;
+import org.eclipse.team.core.history.IFileRevision;
+import org.eclipse.team.core.variants.IResourceVariant;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.core.resource.ILocalResource;
+import org.eclipse.team.svn.core.resource.IRepositoryLocation;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+import org.eclipse.team.svn.core.synchronize.variant.BaseFileVariant;
+
+public class SVNRevisionScopeDefinitionFactory extends FileRevisionScopeDefinitionFactory {
+
+ @Override
+ public Collection<? extends Class<?>> getOverridenClasses() {
+ return Collections.<Class<?>>singleton(FileRevisionScopeDefinitionFactory.class);
+ }
+
+ @Override
+ protected IFileRevision getFileRevision(ITypedElement entrypoint) {
+ IFileRevision revision=super.getFileRevision(entrypoint);
+ if (getVariant(revision) instanceof BaseFileVariant) {
+ return revision;
+ }
+ return null;
+ }
+
+ @Override
+ protected URI getUri(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ ILocalResource res=((BaseFileVariant)variant).getResource();
+ IRepositoryLocation location=SVNRemoteStorage.instance().getRepositoryLocation(res.getResource());
+ return URI.createURI(location.getRepositoryRootUrl() + ((BaseFileVariant)variant).getResource().getResource().getFullPath(), true);
+ }
+ return super.getUri(revision);
+ }
+
+ @Override
+ protected IStorage getStorage(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant != null) {
+ return variant.getStorage(new NullProgressMonitor());
+ }
+ else
+ return super.getStorage(revision);
+ }
+
+ @Override
+ protected URIConverter getURIConverter(IFileRevision revision) throws CoreException {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ ILocalResource res=((BaseFileVariant)variant).getResource();
+ IRepositoryLocation location=SVNRemoteStorage.instance().getRepositoryLocation(res.getResource());
+ return new SVNStreamURIConverter(location, SVNRevision.fromString(variant.getContentIdentifier()));
+ }
+ return super.getURIConverter(revision);
+ }
+
+ @Override
+ protected String getLabelFor(Object entrypoint) {
+ IFileRevision revision=getFileRevision((ITypedElement)entrypoint);
+ if (revision != null) {
+ IResourceVariant variant=getVariant(revision);
+ if (variant instanceof BaseFileVariant) {
+ return "Remote File [Rev:" + variant.getContentIdentifier() + "]";
+ }
+ }
+ return super.getLabelFor(entrypoint);
+ }
+
+}
diff --git a/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java
new file mode 100644
index 00000000..27bf6fe7
--- /dev/null
+++ b/plugins/org.eclipse.emf.diffmerge.connector.svn/src/org/eclipse/emf/diffmerge/connector/svn/SVNStreamURIConverter.java
@@ -0,0 +1,83 @@
+/*******************************************************************************
+ * Copyright (c) 2015 Intel Corporation.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Stephane Bouchet (Intel Corporation) - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.diffmerge.connector.svn;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.diffmerge.connector.EMFDiffmergeSVNConnectorPlugin;
+import org.eclipse.emf.ecore.resource.impl.ExtensibleURIConverterImpl;
+import org.eclipse.team.svn.core.connector.SVNRevision;
+import org.eclipse.team.svn.core.operation.AbstractGetFileContentOperation;
+import org.eclipse.team.svn.core.operation.IActionOperation;
+import org.eclipse.team.svn.core.operation.local.GetLocalFileContentOperation;
+import org.eclipse.team.svn.core.operation.remote.GetFileContentOperation;
+import org.eclipse.team.svn.core.resource.IRepositoryLocation;
+import org.eclipse.team.svn.core.resource.IRepositoryResource;
+import org.eclipse.team.svn.core.svnstorage.SVNRemoteStorage;
+
+public final class SVNStreamURIConverter extends ExtensibleURIConverterImpl {
+
+ private final IRepositoryLocation repoLocation;
+ private final SVNRevision revision;
+
+ public SVNStreamURIConverter(IRepositoryLocation repositoryLocation, SVNRevision revision) {
+ super();
+ this.repoLocation=repositoryLocation;
+ this.revision=revision;
+ }
+
+ @Override
+ public InputStream createInputStream(URI uri, Map<?, ?> options) throws IOException {
+ // strip the uri that contains the repolocation.
+ if ("svn".equals(uri.scheme())) {
+ //try to locate the file locally
+ String basepath=repoLocation.getRepositoryRootUrl();
+ List<String> basePathSegmentsList=URI.createURI(basepath).segmentsList();
+ List<String> newPathList=new ArrayList<String>(uri.segmentsList());
+ newPathList.removeAll(basePathSegmentsList);
+ IPath newPath=new Path(URI.createHierarchicalURI(newPathList.toArray(new String[] {}), uri.query(), uri.fragment()).devicePath());
+ IResource target=ResourcesPlugin.getWorkspace().getRoot().getFile(newPath);
+ if (target.exists()) {
+ AbstractGetFileContentOperation op;
+ if (revision.equals(SVNRevision.BASE)) {
+ op=new GetLocalFileContentOperation(target, SVNRevision.BASE.getKind());
+ }
+ else {
+ IRepositoryResource res=SVNRemoteStorage.instance().asRepositoryResource(target);
+ // gets the remote contents associated with the revision id
+ res.setSelectedRevision(revision);
+ op=new GetFileContentOperation(res);
+ }
+ op.run(new NullProgressMonitor());
+ if (op.getExecutionState() != IActionOperation.OK)
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog()
+ .log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, "Cannot load resource: " + op.getStatus().getMessage()));
+ return op.getContent();
+ }
+ else {
+ EMFDiffmergeSVNConnectorPlugin.getInstance().getLog().log(new Status(IStatus.ERROR, EMFDiffmergeSVNConnectorPlugin.PLUGIN_ID, "Cannot load resource at: " + uri));
+ }
+ }
+ return super.createInputStream(uri, options);
+ }
+} \ No newline at end of file

Back to the top