Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-07 02:33:18 +0000
committerMichael Valenta2006-01-07 02:33:18 +0000
commitb4547d3d6ad96ad109c3bd9479706fc1bf40088e (patch)
tree50c08ed15cdb20906c5b6ce134d0b82aa96f8236
parentd1e5018ab08463fb621e9a9f06caf29be6312a84 (diff)
downloadeclipse.platform.team-b4547d3d6ad96ad109c3bd9479706fc1bf40088e.tar.gz
eclipse.platform.team-b4547d3d6ad96ad109c3bd9479706fc1bf40088e.tar.xz
eclipse.platform.team-b4547d3d6ad96ad109c3bd9479706fc1bf40088e.zip
Bug 114661 [Merge API] CVS Merge should use IResourceMappingMerger
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java8
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java3
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractModelMergeOperation.java54
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java61
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingMergeOperation.java106
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java66
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelMergeOperation.java48
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ReplaceWithRemoteOperation.java)4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingUpdateOperation.java)26
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSMergeContext.java)49
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java59
14 files changed, 309 insertions, 185 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java
index e2323e9bf..32d997650 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/subscribers/SubscriberMergeContext.java
@@ -102,4 +102,12 @@ public abstract class SubscriberMergeContext extends MergeContext {
handler.waitUntilIdle(monitor);
}
+ /**
+ * Return the subscriber associated with this context.
+ * @return the subscriber associated with this context
+ */
+ public Subscriber getSubscriber() {
+ return subscriber;
+ }
+
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
index e82a85a1e..144dad292 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSMergeSubscriber.java
@@ -127,7 +127,7 @@ public class CVSMergeSubscriber extends CVSSyncTreeSubscriber implements IResour
}
public CVSMergeSubscriber(QualifiedName id, IResource[] roots, CVSTag start, CVSTag end) {
- super(id, NLS.bind(CVSMessages.CVSMergeSubscriber_2, new String[] { start.getName(), end.getName() })); //
+ super(id, NLS.bind(CVSMessages.CVSMergeSubscriber_2, new String[] { start.getName(), end.getName() }));
this.start = start;
this.end = end;
this.roots = new ArrayList(Arrays.asList(roots));
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
index 70f955cc8..5030879fa 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java
@@ -13,6 +13,7 @@ package org.eclipse.team.internal.ccvs.ui.actions;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.wizards.MergeWizard;
@@ -25,7 +26,7 @@ public class MergeAction extends WorkspaceTraversalAction {
final Shell shell = getShell();
shell.getDisplay().syncExec(new Runnable() {
public void run() {
- MergeWizard wizard = new MergeWizard(getTargetPart(), getSelectedResources(), getCVSResourceMappings());
+ MergeWizard wizard = new MergeWizard(getTargetPart(), getSelectedResources(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId()));
WizardDialog dialog = new WizardDialog(shell, wizard);
dialog.open();
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
index e9be2661f..54dec9d07 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithRemoteAction.java
@@ -25,7 +25,7 @@ import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.mappings.ReplaceWithRemoteOperation;
+import org.eclipse.team.internal.ccvs.ui.mappings.ModelReplaceOperation;
import org.eclipse.team.internal.ccvs.ui.operations.ReplaceOperation;
import org.eclipse.team.internal.core.InfiniteSubProgressMonitor;
@@ -34,7 +34,7 @@ public class ReplaceWithRemoteAction extends WorkspaceTraversalAction {
public void execute(IAction action) throws InvocationTargetException, InterruptedException {
IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
if (store.getBoolean(ICVSUIConstants.PREF_ENABLEMODELUPDATE)){
- new ReplaceWithRemoteOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId()), getResourceMappingContext()).run();
+ new ModelReplaceOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId()), getResourceMappingContext()).run();
} else {
final ResourceMapping[][] resourceMappings = new ResourceMapping[][] {null};
run(new IRunnableWithProgress() {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java
index 3e09aab6a..195b293bb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/UpdateSilentAction.java
@@ -18,7 +18,7 @@ import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
-import org.eclipse.team.internal.ccvs.ui.mappings.MappingUpdateOperation;
+import org.eclipse.team.internal.ccvs.ui.mappings.ModelUpdateOperation;
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation;
/**
@@ -47,7 +47,7 @@ public class UpdateSilentAction extends WorkspaceTraversalAction {
//regular update action
IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
if (store.getBoolean(ICVSUIConstants.PREF_ENABLEMODELUPDATE)){
- new MappingUpdateOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId()), getResourceMappingContext()).run();
+ new ModelUpdateOperation(getTargetPart(), getSelectedResourceMappings(CVSProviderPlugin.getTypeId()), getResourceMappingContext()).run();
} else {
new UpdateOperation(getTargetPart(), getCVSResourceMappings(), Command.NO_LOCAL_OPTIONS, null /* no tag */).run();
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractModelMergeOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractModelMergeOperation.java
new file mode 100644
index 000000000..8873b3fd4
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/AbstractModelMergeOperation.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.mappings;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.mapping.IMergeContext;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.operations.CacheBaseContentsOperation;
+import org.eclipse.team.internal.ccvs.ui.operations.CacheRemoteContentsOperation;
+import org.eclipse.team.ui.operations.ResourceMappingMergeOperation;
+import org.eclipse.ui.IWorkbenchPart;
+
+public abstract class AbstractModelMergeOperation extends ResourceMappingMergeOperation {
+
+ protected AbstractModelMergeOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
+ super(part, selectedMappings, context);
+ }
+
+ protected void cacheContents(IWorkbenchPart part, IMergeContext context, IProgressMonitor monitor) throws CVSException {
+ // cache the base and remote contents
+ // TODO: Refreshing and caching now takes 3 round trips.
+ // OPTIMIZE: remote state and contents could be obtained in 1
+ // OPTIMIZE: Based could be avoided if we always cached base locally
+ try {
+ new CacheBaseContentsOperation(part, context.getScope().getMappings(), context.getDiffTree(), true).run(Policy.subMonitorFor(monitor, 25));
+ new CacheRemoteContentsOperation(part, context.getScope().getMappings(), context.getDiffTree()).run(Policy.subMonitorFor(monitor, 25));
+ } catch (InvocationTargetException e) {
+ throw CVSException.wrapException(e);
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
+ */
+ protected boolean canRunAsJob() {
+ return true;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java
new file mode 100644
index 000000000..dd340f3b8
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSSubscriberMergeContext.java
@@ -0,0 +1,61 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.mappings;
+
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.jobs.ISchedulingRule;
+import org.eclipse.team.core.diff.IDiffNode;
+import org.eclipse.team.core.mapping.IResourceMappingScope;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.core.subscribers.SubscriberMergeContext;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.ICVSRunnable;
+import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
+import org.eclipse.team.ui.operations.FileMerger;
+
+public abstract class CVSSubscriberMergeContext extends SubscriberMergeContext {
+
+ protected CVSSubscriberMergeContext(Subscriber subscriber, IResourceMappingScope scope) {
+ super(subscriber, scope);
+ setMerger(new FileMerger());
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.mapping.MergeContext#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.jobs.ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void run(final IWorkspaceRunnable runnable, final ISchedulingRule rule, int flags, IProgressMonitor monitor) throws CoreException {
+ super.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ EclipseSynchronizer.getInstance().run(rule, new ICVSRunnable(){
+ public void run(IProgressMonitor monitor) throws CVSException {
+ try {
+ runnable.run(monitor);
+ } catch (CoreException e) {
+ throw CVSException.wrapException(e);
+ }
+ }
+ }, monitor);
+ }
+
+ }, rule, flags, monitor);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.mapping.MergeContext#getMergeRule(org.eclipse.core.resources.IResource)
+ */
+ public ISchedulingRule getMergeRule(IDiffNode node) {
+ // Return the project since that is what the EclipseSynchronize needs
+ return getDiffTree().getResource(node).getProject();
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingMergeOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingMergeOperation.java
deleted file mode 100644
index ae77e3e9c..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingMergeOperation.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2005 IBM Corporation and others.
- * 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:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.mappings;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.mapping.*;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.dialogs.MessageDialogWithToggle;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.team.core.mapping.IMergeContext;
-import org.eclipse.team.internal.ccvs.core.CVSException;
-import org.eclipse.team.internal.ccvs.ui.*;
-import org.eclipse.team.internal.ccvs.ui.operations.CacheBaseContentsOperation;
-import org.eclipse.team.internal.ccvs.ui.operations.CacheRemoteContentsOperation;
-import org.eclipse.team.internal.ccvs.ui.subscriber.WorkspaceSynchronizeParticipant;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
-import org.eclipse.team.ui.TeamUI;
-import org.eclipse.team.ui.operations.ResourceMappingMergeOperation;
-import org.eclipse.team.ui.synchronize.*;
-import org.eclipse.ui.IWorkbenchPart;
-
-public class MappingMergeOperation extends ResourceMappingMergeOperation {
-
- protected static final String UPDATE_CLIENT_MERGE_INFO = "update_client_merge_info_prompt"; //$NON-NLS-1$
-
- public MappingMergeOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
- super(part, selectedMappings, context);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#buildMergeContext(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IMergeContext buildMergeContext(IProgressMonitor monitor) throws CoreException {
- monitor.beginTask(null, 100);
- IMergeContext context = CVSMergeContext.createContext(getScope(), Policy.subMonitorFor(monitor, 50));
- // cache the base and remote contents
- // TODO: Refreshing and caching now takes 3 round trips.
- // OPTIMIZE: remote state and contents could be obtained in 1
- // OPTIMIZE: Based could be avoided if we always cached base locally
- try {
- new CacheBaseContentsOperation(getPart(), getScope().getMappings(), context.getDiffTree(), true).run(Policy.subMonitorFor(monitor, 25));
- new CacheRemoteContentsOperation(getPart(), getScope().getMappings(), context.getDiffTree()).run(Policy.subMonitorFor(monitor, 25));
- } catch (InvocationTargetException e) {
- throw CVSException.wrapException(e);
- } catch (InterruptedException e) {
- // Ignore
- }
- monitor.done();
- return context;
- }
-
- protected void requiresManualMerge(ModelProvider[] providers, IMergeContext context) throws CoreException {
-
- // Sync Action
- ResourceScope scope = new ResourceScope(getScope().getRoots()); //create resource scope from here; sync
- final WorkspaceSynchronizeParticipant participant = new WorkspaceSynchronizeParticipant(scope);
- TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
-
- provideInfo();
-
- Display display = getShell().getDisplay();
- if (display != null && !display.isDisposed()) {
- display.asyncExec(new Runnable() {
- public void run() {
- ISynchronizeView view = TeamUI.getSynchronizeManager().showSynchronizeViewInActivePage();
- if (view != null) {
- view.display(participant);
- }
- }
- });
- }
- }
-
- private void provideInfo() {
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- IPreferenceStore store = TeamUIPlugin.getPlugin().getPreferenceStore();
-
- if (store.getBoolean(UPDATE_CLIENT_MERGE_INFO)) {
- return;
- }
- MessageDialogWithToggle dialog = MessageDialogWithToggle.openInformation(getShell(), CVSUIMessages.CVSMappingMergeOperation_MergeInfoTitle, CVSUIMessages.CVSMappingMergeOperation_MergeInfoText, CVSUIMessages.AvoidableMessageDialog_dontShowAgain, false, null, null);
- store.setValue(UPDATE_CLIENT_MERGE_INFO, dialog.getToggleState());
- }
- });
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.ui.TeamOperation#canRunAsJob()
- */
- protected boolean canRunAsJob() {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java
new file mode 100644
index 000000000..33ecc406d
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MergeSubscriberContext.java
@@ -0,0 +1,66 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.mappings;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.diff.IDiffNode;
+import org.eclipse.team.core.mapping.*;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
+
+public class MergeSubscriberContext extends CVSSubscriberMergeContext {
+
+ public static IMergeContext createContext(IResourceMappingScope scope, Subscriber subscriber, IProgressMonitor monitor) throws CoreException {
+ MergeSubscriberContext mergeContext = new MergeSubscriberContext(subscriber, scope);
+ mergeContext.initialize(monitor, true);
+ return mergeContext;
+ }
+
+ public MergeSubscriberContext(Subscriber subscriber, IResourceMappingScope scope) {
+ super(subscriber, scope);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.core.mapping.IMergeContext#markAsMerged(org.eclipse.team.core.diff.IDiffNode, boolean, org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public void markAsMerged(final IDiffNode node, boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
+ run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ ((CVSMergeSubscriber)getSubscriber()).merged(new IResource[] { ((IResourceDiff)node).getResource() });
+ }
+ }, getMergeRule(node), IResource.NONE, monitor);
+ }
+
+ public void markAsMerged(final IDiffNode[] nodes, boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
+ run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ List result = new ArrayList();
+ for (int i = 0; i < nodes.length; i++) {
+ IDiffNode node = nodes[i];
+ result.add(((IResourceDiff)node).getResource());
+ }
+ ((CVSMergeSubscriber)getSubscriber()).merged((IResource[]) result.toArray(new IResource[result.size()]));
+ }
+ }, getMergeRule(nodes), IResource.NONE, monitor);
+ }
+
+ public void dispose() {
+ ((CVSMergeSubscriber)getSubscriber()).cancel();
+ super.dispose();
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelMergeOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelMergeOperation.java
new file mode 100644
index 000000000..3aa4743ac
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelMergeOperation.java
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2006 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.team.internal.ccvs.ui.mappings;
+
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.mapping.IMergeContext;
+import org.eclipse.team.core.subscribers.Subscriber;
+import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.core.subscribers.SubscriberResourceMappingContext;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class ModelMergeOperation extends AbstractModelMergeOperation {
+
+ private final Subscriber subscriber;
+
+ public ModelMergeOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, Subscriber subscriber) {
+ super(part, selectedMappings, SubscriberResourceMappingContext.getCompareContext(subscriber));
+ this.subscriber = subscriber;
+ }
+
+ protected IMergeContext buildMergeContext(IProgressMonitor monitor)
+ throws CoreException {
+ monitor.beginTask(null, 100);
+ IMergeContext context = MergeSubscriberContext.createContext(getScope(), subscriber, Policy.subMonitorFor(monitor, 50));
+ cacheContents(getPart(), context, monitor);
+ monitor.done();
+ return context;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.TeamOperation#getJobName()
+ */
+ protected String getJobName() {
+ return CVSUIMessages.MergeUpdateAction_jobName;
+ }
+
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ReplaceWithRemoteOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java
index 7f7f00a24..ea52ba95d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ReplaceWithRemoteOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelReplaceOperation.java
@@ -22,9 +22,9 @@ import org.eclipse.team.core.diff.*;
import org.eclipse.team.core.mapping.IMergeContext;
import org.eclipse.ui.IWorkbenchPart;
-public class ReplaceWithRemoteOperation extends MappingMergeOperation {
+public class ModelReplaceOperation extends ModelUpdateOperation {
- public ReplaceWithRemoteOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
+ public ModelReplaceOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
super(part, selectedMappings, context);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
index e3c284da1..70903552d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/MappingUpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
@@ -12,17 +12,18 @@ package org.eclipse.team.internal.ccvs.ui.mappings;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.resources.mapping.ResourceMappingContext;
-import org.eclipse.team.internal.ccvs.ui.CVSUIMessages;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.team.core.mapping.IMergeContext;
+import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.ui.IWorkbenchPart;
-public class MappingUpdateOperation extends MappingMergeOperation {
-
- public MappingUpdateOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
+public class ModelUpdateOperation extends AbstractModelMergeOperation {
+
+ public ModelUpdateOperation(IWorkbenchPart part, ResourceMapping[] selectedMappings, ResourceMappingContext context) {
super(part, selectedMappings, context);
}
-
+
/* (non-Javadoc)
* @see org.eclipse.team.ui.TeamOperation#getJobName()
*/
@@ -36,4 +37,15 @@ public class MappingUpdateOperation extends MappingMergeOperation {
protected boolean isAttemptHeadlessMerge() {
return CVSUIPlugin.getPlugin().getPreferenceStore().getString(ICVSUIConstants.PREF_UPDATE_HANDLING).equals(ICVSUIConstants.PREF_UPDATE_HANDLING_PERFORM);
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.team.ui.operations.ResourceMappingMergeOperation#buildMergeContext(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IMergeContext buildMergeContext(IProgressMonitor monitor) throws CoreException {
+ monitor.beginTask(null, 100);
+ IMergeContext context = WorkspaceSubscriberContext.createContext(getScope(), Policy.subMonitorFor(monitor, 50));
+ cacheContents(getPart(), context, monitor);
+ monitor.done();
+ return context;
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSMergeContext.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java
index 123e36cb1..be07bffb2 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/CVSMergeContext.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/WorkspaceSubscriberContext.java
@@ -12,7 +12,6 @@ package org.eclipse.team.internal.ccvs.ui.mappings;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.osgi.util.NLS;
import org.eclipse.team.core.diff.IDiffNode;
import org.eclipse.team.core.diff.IThreeWayDiff;
@@ -20,7 +19,6 @@ import org.eclipse.team.core.history.IFileRevision;
import org.eclipse.team.core.history.IFileState;
import org.eclipse.team.core.mapping.*;
import org.eclipse.team.core.subscribers.Subscriber;
-import org.eclipse.team.core.subscribers.SubscriberMergeContext;
import org.eclipse.team.core.synchronize.SyncInfo;
import org.eclipse.team.core.synchronize.SyncInfoFilter;
import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter;
@@ -28,22 +26,19 @@ import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.PruneFolderVisitor;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.ui.operations.FileMerger;
-public class CVSMergeContext extends SubscriberMergeContext {
+public class WorkspaceSubscriberContext extends CVSSubscriberMergeContext {
public static IMergeContext createContext(IResourceMappingScope scope, IProgressMonitor monitor) throws CoreException {
Subscriber subscriber = CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber();
- CVSMergeContext mergeContext = new CVSMergeContext(subscriber, scope);
+ WorkspaceSubscriberContext mergeContext = new WorkspaceSubscriberContext(subscriber, scope);
mergeContext.initialize(monitor, true);
return mergeContext;
}
- protected CVSMergeContext(Subscriber subscriber, IResourceMappingScope scope) {
+ protected WorkspaceSubscriberContext(Subscriber subscriber, IResourceMappingScope scope) {
super(subscriber, scope);
- setMerger(new FileMerger());
}
public void markAsMerged(final IDiffNode node, final boolean inSyncHint, IProgressMonitor monitor) throws CoreException {
@@ -128,16 +123,6 @@ public class CVSMergeContext extends SubscriberMergeContext {
}
return status;
}
-
- private boolean equals(IDiffNode currentState, IDiffNode delta) {
- if (currentState.getKind() != delta.getKind())
- return false;
- if (!currentState.getPath().equals(delta.getPath()))
- return false;
- if (((IThreeWayDiff)currentState).getDirection() != ((IThreeWayDiff)delta).getDirection())
- return false;
- return true;
- }
private void pruneEmptyParents(IDiffNode[] deltas) throws CVSException {
// TODO: A more explicit tie in to the pruning mechanism would be preferable.
@@ -151,33 +136,5 @@ public class CVSMergeContext extends SubscriberMergeContext {
CVSWorkspaceRoot.getCVSFolderFor(ResourcesPlugin.getWorkspace().getRoot()),
cvsResources);
}
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.mapping.MergeContext#run(org.eclipse.core.resources.IWorkspaceRunnable, org.eclipse.core.runtime.jobs.ISchedulingRule, int, org.eclipse.core.runtime.IProgressMonitor)
- */
- public void run(final IWorkspaceRunnable runnable, final ISchedulingRule rule, int flags, IProgressMonitor monitor) throws CoreException {
- super.run(new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- EclipseSynchronizer.getInstance().run(rule, new ICVSRunnable(){
- public void run(IProgressMonitor monitor) throws CVSException {
- try {
- runnable.run(monitor);
- } catch (CoreException e) {
- throw CVSException.wrapException(e);
- }
- }
- }, monitor);
- }
-
- }, rule, flags, monitor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.team.core.mapping.MergeContext#getMergeRule(org.eclipse.core.resources.IResource)
- */
- public ISchedulingRule getMergeRule(IDiffNode node) {
- // Return the project since that is what the EclipseSynchronize needs
- return getDiffTree().getResource(node).getProject();
- }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java
index de48babb4..7c41bbdce 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/MergeWizard.java
@@ -12,12 +12,12 @@ package org.eclipse.team.internal.ccvs.ui.wizards;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.List;
+import java.util.*;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.wizard.Wizard;
import org.eclipse.team.internal.ccvs.core.CVSMergeSubscriber;
@@ -26,6 +26,7 @@ import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Update;
import org.eclipse.team.internal.ccvs.ui.*;
import org.eclipse.team.internal.ccvs.ui.actions.WorkspaceTraversalAction;
+import org.eclipse.team.internal.ccvs.ui.mappings.ModelMergeOperation;
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOperation;
import org.eclipse.team.internal.ccvs.ui.subscriber.MergeSynchronizeParticipant;
import org.eclipse.team.internal.ccvs.ui.tags.TagSource;
@@ -73,25 +74,47 @@ public class MergeWizard extends Wizard {
// Ignore
}
} else {
- // First check if there is an existing matching participant, if so then re-use it
- try {
- resources = getAllResources(startTag, endTag);
- } catch (InvocationTargetException e) {
- // Log and continue with the original resources
- CVSUIPlugin.log(IStatus.ERROR, "An error occurred while detemrining if extra resources should be included in the merge", e.getTargetException()); //$NON-NLS-1$
- }
- MergeSynchronizeParticipant participant = MergeSynchronizeParticipant.getMatchingParticipant(resources, startTag, endTag);
- if(participant == null) {
- CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag);
- participant = new MergeSynchronizeParticipant(s);
- TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
- }
- participant.refresh(resources, null, null, null);
+ IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
+ if (store.getBoolean(ICVSUIConstants.PREF_ENABLEMODELUPDATE)){
+ CVSMergeSubscriber s = new CVSMergeSubscriber(getProjects(resources), startTag, endTag);
+ try {
+ new ModelMergeOperation(getPart(), mappings, s).run();
+ } catch (InvocationTargetException e) {
+ CVSUIPlugin.log(IStatus.ERROR, "Internal error", e.getTargetException()); //$NON-NLS-1$
+ } catch (InterruptedException e) {
+ // Ignore
+ }
+ } else {
+ // First check if there is an existing matching participant, if so then re-use it
+ try {
+ resources = getAllResources(startTag, endTag);
+ } catch (InvocationTargetException e) {
+ // Log and continue with the original resources
+ CVSUIPlugin.log(IStatus.ERROR, "An error occurred while detemrining if extra resources should be included in the merge", e.getTargetException()); //$NON-NLS-1$
+ }
+ MergeSynchronizeParticipant participant = MergeSynchronizeParticipant.getMatchingParticipant(resources, startTag, endTag);
+ if(participant == null) {
+ CVSMergeSubscriber s = new CVSMergeSubscriber(resources, startTag, endTag);
+ participant = new MergeSynchronizeParticipant(s);
+ TeamUI.getSynchronizeManager().addSynchronizeParticipants(new ISynchronizeParticipant[] {participant});
+ }
+ participant.refresh(resources, null, null, null);
+ }
+
}
return true;
}
-
- private IResource[] getAllResources(CVSTag startTag, CVSTag endTag) throws InvocationTargetException {
+
+ private IResource[] getProjects(IResource[] resources) {
+ Set projects = new HashSet();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ projects.add(resource.getProject());
+ }
+ return (IResource[]) projects.toArray(new IResource[projects.size()]);
+ }
+
+ private IResource[] getAllResources(CVSTag startTag, CVSTag endTag) throws InvocationTargetException {
// Only do the extra work if the model is a logical model (i.e. not IResource)
if (!WorkspaceTraversalAction.isLogicalModel(mappings))
return resources;

Back to the top