Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-01-29 03:30:12 +0000
committerjames2002-01-29 03:30:12 +0000
commitac209c0dac1f34dbfdf111f8f351232659b20f4d (patch)
tree998b2076b28f4b0cbcda6d82d3d382952ffd6532
parent75f5475d980fe2239d88201301f9ef607a735183 (diff)
downloadeclipse.platform.team-ac209c0dac1f34dbfdf111f8f351232659b20f4d.tar.gz
eclipse.platform.team-ac209c0dac1f34dbfdf111f8f351232659b20f4d.tar.xz
eclipse.platform.team-ac209c0dac1f34dbfdf111f8f351232659b20f4d.zip
8637: Merging: can't merge incoming deletion
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/GetMergeAction.java127
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetSyncAction.java (renamed from bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetMergeAction.java)382
5 files changed, 334 insertions, 201 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
index 364d92f95..16f0ef36d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/RepositoryManager.java
@@ -520,7 +520,6 @@ public class RepositoryManager {
while (iterator.hasNext()) {
IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000);
CVSTeamProvider provider = (CVSTeamProvider)iterator.next();
- provider.setComment(previousComment);
List list = (List)table.get(provider);
IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
provider.update(providerResources, IResource.DEPTH_INFINITE, null, true, subMonitor);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/GetMergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/GetMergeAction.java
new file mode 100644
index 000000000..1e5d3a046
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/GetMergeAction.java
@@ -0,0 +1,127 @@
+package org.eclipse.team.internal.ccvs.ui.merge;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.RepositoryManager;
+import org.eclipse.team.internal.ccvs.ui.sync.*;
+import org.eclipse.team.ui.sync.ITeamNode;
+import org.eclipse.team.ui.sync.SyncSet;
+import org.eclipse.team.ui.sync.TeamFile;
+
+public class GetMergeAction extends GetSyncAction {
+ public GetMergeAction(CVSSyncCompareInput model, ISelectionProvider sp, int direction, String label, Shell shell) {
+ super(model, sp, direction, label, shell);
+ }
+ protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
+ // If there is a conflict in the syncSet, we need to prompt the user before proceeding.
+ if (syncSet.hasConflicts() || syncSet.hasOutgoingChanges()) {
+ String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
+ String question = Policy.bind("GetSyncAction.questionCatchup");
+ String title = Policy.bind("GetSyncAction.titleCatchup");
+ String[] tips = new String[] {
+ Policy.bind("GetSyncAction.catchupAll"),
+ Policy.bind("GetSyncAction.catchupPart"),
+ Policy.bind("GetSyncAction.cancelCatchup")
+ };
+ Shell shell = getShell();
+ final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0);
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ dialog.open();
+ }
+ });
+ switch (dialog.getReturnCode()) {
+ case 0:
+ // Yes, synchronize conflicts as well
+ break;
+ case 1:
+ // No, only synchronize non-conflicting changes.
+ syncSet.removeConflictingNodes();
+ break;
+ case 2:
+ default:
+ // Cancel
+ return null;
+ }
+ }
+ ITeamNode[] changed = syncSet.getChangedNodes();
+ if (changed.length == 0) {
+ return syncSet;
+ }
+
+ try {
+ for (int i = 0; i < changed.length; i++) {
+ switch (changed[i].getKind() & Differencer.CHANGE_TYPE_MASK) {
+ case Differencer.ADDITION:
+ IResource resource = changed[i].getResource();
+ if (resource instanceof IFile) {
+ createParentStructure(((IFile)resource).getParent(), monitor);
+ InputStream stream = ((TeamFile)changed[i]).getMergeResource().getSyncElement().getRemote().getContents(monitor);
+ ((IFile)resource).create(stream, true, monitor);
+ } else if (resource instanceof IFolder) {
+ createParentStructure((IFolder)resource, monitor);
+ }
+ break;
+ case Differencer.DELETION:
+ changed[i].getResource().delete(true, monitor);
+ break;
+ case Differencer.CHANGE:
+ resource = changed[i].getResource();
+ if (resource instanceof IFile) {
+ InputStream stream = ((TeamFile)changed[i]).getMergeResource().getSyncElement().getRemote().getContents(monitor);
+ ((IFile)resource).setContents(stream, true, true, monitor);
+ }
+ break;
+ }
+ }
+ } catch (TeamException e) {
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
+ return null;
+ } catch (CoreException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return null;
+ }
+ return syncSet;
+ }
+ /**
+ * Create the folder and all its parents
+ */
+ private void createParentStructure(IContainer container, IProgressMonitor monitor) throws CoreException {
+ Vector v = new Vector();
+ if (container.exists()) return;
+ while (!container.exists()) {
+ v.add(0, container);
+ container = container.getParent();
+ }
+ Iterator it = v.iterator();
+ while (it.hasNext()) {
+ ((IFolder)it.next()).create(true, true, monitor);
+ }
+ }
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 8ccbede43..e8ed188db 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -177,11 +177,11 @@ GenerateCVSDiff.working=Running CVS diff...
GenerateCVSDiff.noDiffsFoundMsg=No differences found.
GenerateCVSDiff.noDiffsFoundTitle=CVS diff
-GetMergeAction.questionCatchup=You have local changes which you are about to overwrite. Should the conflicting changes be added?
-GetMergeAction.titleCatchup=Catch up Over Conflicts?
-GetMergeAction.catchupAll=Catch up to all incoming changes, overriding any conflicting local changes.
-GetMergeAction.catchupPart=Only catch up to the changes that don't conflict with local changes.
-GetMergeAction.cancelCatchup=Cancel the catch up operation.
+GetSyncAction.questionCatchup=You have local changes which you are about to overwrite. Should the conflicting changes be added?
+GetSyncAction.titleCatchup=Catch up Over Conflicts?
+GetSyncAction.catchupAll=Catch up to all incoming changes, overriding any conflicting local changes.
+GetSyncAction.catchupPart=Only catch up to the changes that don't conflict with local changes.
+GetSyncAction.cancelCatchup=Cancel the catch up operation.
HistoryView.addToWorkspace=&Get
HistoryView.copy=&Copy
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
index e97a952ad..8fbfed3a7 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
@@ -18,15 +18,17 @@ import org.eclipse.team.core.sync.IRemoteResource;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.merge.GetMergeAction;
import org.eclipse.team.ui.sync.CatchupReleaseViewer;
import org.eclipse.team.ui.sync.MergeResource;
import org.eclipse.team.ui.sync.SyncView;
public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
// Actions
- private MergeAction getAction;
+ private GetSyncAction getAction;
private CommitMergeAction commitAction;
-
+ private GetMergeAction getMergeAction;
+
public CVSCatchupReleaseViewer(Composite parent, CVSSyncCompareInput model) {
super(parent, model);
initializeActions(model);
@@ -40,10 +42,14 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
commitAction.update();
manager.add(commitAction);
}
- if (syncMode == SyncView.SYNC_INCOMING || syncMode == SyncView.SYNC_BOTH || syncMode == SyncView.SYNC_MERGE) {
+ if (syncMode == SyncView.SYNC_INCOMING || syncMode == SyncView.SYNC_BOTH) {
getAction.update();
manager.add(getAction);
}
+ if (syncMode == SyncView.SYNC_MERGE) {
+ getMergeAction.update();
+ manager.add(getMergeAction);
+ }
}
/**
@@ -52,7 +58,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
private void initializeActions(final CVSSyncCompareInput diffModel) {
Shell shell = getControl().getShell();
commitAction = new CommitMergeAction(diffModel, this, IRemoteSyncElement.OUTGOING, Policy.bind("CVSCatchupReleaseViewer.checkIn"), shell);
- getAction = new GetMergeAction(diffModel, this, IRemoteSyncElement.INCOMING, Policy.bind("CVSCatchupReleaseViewer.get"), shell);
+ getAction = new GetSyncAction(diffModel, this, IRemoteSyncElement.INCOMING, Policy.bind("CVSCatchupReleaseViewer.get"), shell);
+ getMergeAction = new GetMergeAction(diffModel, this, IRemoteSyncElement.INCOMING, Policy.bind("CVSCatchupReleaseViewer.get"), shell);
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetMergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetSyncAction.java
index 924bc6439..bba2b3eb6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetMergeAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetSyncAction.java
@@ -1,191 +1,191 @@
-package org.eclipse.team.internal.ccvs.ui.sync;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.compare.structuremergeviewer.Differencer;
-import org.eclipse.compare.structuremergeviewer.IDiffContainer;
-import org.eclipse.compare.structuremergeviewer.IDiffElement;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.RepositoryManager;
-import org.eclipse.team.ui.sync.ChangedTeamContainer;
-import org.eclipse.team.ui.sync.ITeamNode;
-import org.eclipse.team.ui.sync.SyncSet;
-import org.eclipse.team.ui.sync.TeamFile;
-import org.eclipse.team.ui.sync.UnchangedTeamContainer;
-
-/**
- * GetMergeAction is run on a set of sync nodes when the "Get" menu item is performed
- * in the Synchronize view.
- */
-public class GetMergeAction extends MergeAction {
- public GetMergeAction(CVSSyncCompareInput model, ISelectionProvider sp, int direction, String label, Shell shell) {
- super(model, sp, direction, label, shell);
- }
-
- protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
- // If there is a conflict in the syncSet, we need to prompt the user before proceeding.
- if (syncSet.hasConflicts() || syncSet.hasOutgoingChanges()) {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
- String question = Policy.bind("GetMergeAction.questionCatchup");
- String title = Policy.bind("GetMergeAction.titleCatchup");
- String[] tips = new String[] {
- Policy.bind("GetMergeAction.catchupAll"),
- Policy.bind("GetMergeAction.catchupPart"),
- Policy.bind("GetMergeAction.cancelCatchup")
- };
- Shell shell = getShell();
- final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0);
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- switch (dialog.getReturnCode()) {
- case 0:
- // Yes, synchronize conflicts as well
- break;
- case 1:
- // No, only synchronize non-conflicting changes.
- syncSet.removeConflictingNodes();
- break;
- case 2:
- default:
- // Cancel
- return null;
- }
- }
- ITeamNode[] changed = syncSet.getChangedNodes();
- if (changed.length == 0) {
- return syncSet;
- }
- List changedResources = new ArrayList();
- List addedResources = new ArrayList();
- // A list of diff elements in the sync set which are incoming folder additions
- List parentCreationElements = new ArrayList();
- // A list of diff elements in the sync set which are folder conflicts
- List parentConflictElements = new ArrayList();
-
- for (int i = 0; i < changed.length; i++) {
- IDiffContainer parent = changed[i].getParent();
- if (parent != null) {
- int parentKind = changed[i].getParent().getKind();
- if (((parentKind & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) &&
- ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.INCOMING)) {
- parentCreationElements.add(parent);
- } else if ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.CONFLICTING) {
- parentConflictElements.add(parent);
- }
- }
- if ((changed[i].getKind() & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) {
- addedResources.add(changed[i].getResource());
- } else {
- changedResources.add(changed[i].getResource());
- }
- }
- try {
- RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- if (parentCreationElements.size() > 0) {
- // If a node has a parent that is an incoming folder creation, we have to
- // create that folder locally and set its sync info before we can get the
- // node itself. We must do this for all incoming folder creations (recursively)
- // in the case where there are multiple levels of incoming folder creations.
- Iterator it = parentCreationElements.iterator();
- while (it.hasNext()) {
- makeInSync((IDiffElement)it.next());
- }
- }
- if (parentConflictElements.size() > 0) {
- // If a node has a parent that is a folder conflict, that means that the folder
- // exists locally but has no sync info. In order to get the node, we have to
- // create the sync info for the folder (and any applicable parents) before we
- // get the node itself.
- Iterator it = parentConflictElements.iterator();
- while (it.hasNext()) {
- makeInSync((IDiffElement)it.next());
- }
- }
- if (addedResources.size() > 0) {
- manager.update((IResource[])addedResources.toArray(new IResource[0]), monitor);
- }
- if (changedResources.size() > 0) {
- manager.get((IResource[])changedResources.toArray(new IResource[0]), monitor);
- }
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- return null;
- }
- return syncSet;
- }
-
- private void makeInSync(IDiffElement parentElement) throws TeamException {
- // Recursively make the parent element (and its parents) in sync.
- // Walk up and find the parents which need to be made in sync too. (For
- // each parent that doesn't already have sync info.
- Vector v = new Vector();
- int parentKind = parentElement.getKind();
- while (((parentKind & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) &&
- ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.INCOMING)) {
- v.add(0, parentElement);
- parentElement = parentElement.getParent();
- parentKind = parentElement == null ? 0 : parentElement.getKind();
- }
- Iterator parentIt = v.iterator();
- while (parentIt.hasNext()) {
- IDiffElement next = (IDiffElement)parentIt.next();
- if (next instanceof ChangedTeamContainer) {
- CVSRemoteSyncElement syncElement = (CVSRemoteSyncElement)((ChangedTeamContainer)next).getMergeResource().getSyncElement();
- // Create the sync info
- syncElement.makeInSync(new NullProgressMonitor());
- }
- }
- }
- protected boolean isEnabled(ITeamNode node) {
- int kind = node.getKind();
- if (node instanceof TeamFile) {
- int direction = kind & Differencer.DIRECTION_MASK;
- if (direction == ITeamNode.INCOMING || direction == Differencer.CONFLICTING) {
- return true;
- }
- // allow to catchup outgoing deletions
- return (kind & Differencer.CHANGE_TYPE_MASK) == Differencer.DELETION;
- }
- if (node instanceof ChangedTeamContainer) {
- // first check for changes to this folder
- int direction = kind & Differencer.DIRECTION_MASK;
- if (direction == ITeamNode.INCOMING || direction == Differencer.CONFLICTING) {
- return true;
- }
- // Fall through to the UnchangedTeamContainer code
- }
- if (node instanceof UnchangedTeamContainer) {
- IDiffElement[] children = ((UnchangedTeamContainer)node).getChildren();
- for (int i = 0; i < children.length; i++) {
- ITeamNode child = (ITeamNode)children[i];
- if (isEnabled(child)) {
- return true;
- }
- }
- return false;
- }
- return false;
- }
-}
+package org.eclipse.team.internal.ccvs.ui.sync;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+import org.eclipse.compare.structuremergeviewer.Differencer;
+import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.Policy;
+import org.eclipse.team.internal.ccvs.ui.RepositoryManager;
+import org.eclipse.team.ui.sync.ChangedTeamContainer;
+import org.eclipse.team.ui.sync.ITeamNode;
+import org.eclipse.team.ui.sync.SyncSet;
+import org.eclipse.team.ui.sync.TeamFile;
+import org.eclipse.team.ui.sync.UnchangedTeamContainer;
+
+/**
+ * GetSyncAction is run on a set of sync nodes when the "Get" menu item is performed
+ * in the Synchronize view.
+ */
+public class GetSyncAction extends MergeAction {
+ public GetSyncAction(CVSSyncCompareInput model, ISelectionProvider sp, int direction, String label, Shell shell) {
+ super(model, sp, direction, label, shell);
+ }
+
+ protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
+ // If there is a conflict in the syncSet, we need to prompt the user before proceeding.
+ if (syncSet.hasConflicts() || syncSet.hasOutgoingChanges()) {
+ String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
+ String question = Policy.bind("GetSyncAction.questionCatchup");
+ String title = Policy.bind("GetSyncAction.titleCatchup");
+ String[] tips = new String[] {
+ Policy.bind("GetSyncAction.catchupAll"),
+ Policy.bind("GetSyncAction.catchupPart"),
+ Policy.bind("GetSyncAction.cancelCatchup")
+ };
+ Shell shell = getShell();
+ final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0);
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ dialog.open();
+ }
+ });
+ switch (dialog.getReturnCode()) {
+ case 0:
+ // Yes, synchronize conflicts as well
+ break;
+ case 1:
+ // No, only synchronize non-conflicting changes.
+ syncSet.removeConflictingNodes();
+ break;
+ case 2:
+ default:
+ // Cancel
+ return null;
+ }
+ }
+ ITeamNode[] changed = syncSet.getChangedNodes();
+ if (changed.length == 0) {
+ return syncSet;
+ }
+ List changedResources = new ArrayList();
+ List addedResources = new ArrayList();
+ // A list of diff elements in the sync set which are incoming folder additions
+ List parentCreationElements = new ArrayList();
+ // A list of diff elements in the sync set which are folder conflicts
+ List parentConflictElements = new ArrayList();
+
+ for (int i = 0; i < changed.length; i++) {
+ IDiffContainer parent = changed[i].getParent();
+ if (parent != null) {
+ int parentKind = changed[i].getParent().getKind();
+ if (((parentKind & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) &&
+ ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.INCOMING)) {
+ parentCreationElements.add(parent);
+ } else if ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.CONFLICTING) {
+ parentConflictElements.add(parent);
+ }
+ }
+ if ((changed[i].getKind() & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) {
+ addedResources.add(changed[i].getResource());
+ } else {
+ changedResources.add(changed[i].getResource());
+ }
+ }
+ try {
+ RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
+ if (parentCreationElements.size() > 0) {
+ // If a node has a parent that is an incoming folder creation, we have to
+ // create that folder locally and set its sync info before we can get the
+ // node itself. We must do this for all incoming folder creations (recursively)
+ // in the case where there are multiple levels of incoming folder creations.
+ Iterator it = parentCreationElements.iterator();
+ while (it.hasNext()) {
+ makeInSync((IDiffElement)it.next());
+ }
+ }
+ if (parentConflictElements.size() > 0) {
+ // If a node has a parent that is a folder conflict, that means that the folder
+ // exists locally but has no sync info. In order to get the node, we have to
+ // create the sync info for the folder (and any applicable parents) before we
+ // get the node itself.
+ Iterator it = parentConflictElements.iterator();
+ while (it.hasNext()) {
+ makeInSync((IDiffElement)it.next());
+ }
+ }
+ if (addedResources.size() > 0) {
+ manager.update((IResource[])addedResources.toArray(new IResource[0]), monitor);
+ }
+ if (changedResources.size() > 0) {
+ manager.get((IResource[])changedResources.toArray(new IResource[0]), monitor);
+ }
+ } catch (TeamException e) {
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
+ return null;
+ }
+ return syncSet;
+ }
+
+ protected void makeInSync(IDiffElement parentElement) throws TeamException {
+ // Recursively make the parent element (and its parents) in sync.
+ // Walk up and find the parents which need to be made in sync too. (For
+ // each parent that doesn't already have sync info.
+ Vector v = new Vector();
+ int parentKind = parentElement.getKind();
+ while (((parentKind & Differencer.CHANGE_TYPE_MASK) == Differencer.ADDITION) &&
+ ((parentKind & Differencer.DIRECTION_MASK) == ITeamNode.INCOMING)) {
+ v.add(0, parentElement);
+ parentElement = parentElement.getParent();
+ parentKind = parentElement == null ? 0 : parentElement.getKind();
+ }
+ Iterator parentIt = v.iterator();
+ while (parentIt.hasNext()) {
+ IDiffElement next = (IDiffElement)parentIt.next();
+ if (next instanceof ChangedTeamContainer) {
+ CVSRemoteSyncElement syncElement = (CVSRemoteSyncElement)((ChangedTeamContainer)next).getMergeResource().getSyncElement();
+ // Create the sync info
+ syncElement.makeInSync(new NullProgressMonitor());
+ }
+ }
+ }
+ protected boolean isEnabled(ITeamNode node) {
+ int kind = node.getKind();
+ if (node instanceof TeamFile) {
+ int direction = kind & Differencer.DIRECTION_MASK;
+ if (direction == ITeamNode.INCOMING || direction == Differencer.CONFLICTING) {
+ return true;
+ }
+ // allow to catchup outgoing deletions
+ return (kind & Differencer.CHANGE_TYPE_MASK) == Differencer.DELETION;
+ }
+ if (node instanceof ChangedTeamContainer) {
+ // first check for changes to this folder
+ int direction = kind & Differencer.DIRECTION_MASK;
+ if (direction == ITeamNode.INCOMING || direction == Differencer.CONFLICTING) {
+ return true;
+ }
+ // Fall through to the UnchangedTeamContainer code
+ }
+ if (node instanceof UnchangedTeamContainer) {
+ IDiffElement[] children = ((UnchangedTeamContainer)node).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ ITeamNode child = (ITeamNode)children[i];
+ if (isEnabled(child)) {
+ return true;
+ }
+ }
+ return false;
+ }
+ return false;
+ }
+}

Back to the top