Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-01-29 02:22:17 +0000
committerjames2002-01-29 02:22:17 +0000
commit75f5475d980fe2239d88201301f9ef607a735183 (patch)
tree8b0c89953b37d76899614f60c45b0c0af262641e
parent94ec5d1006595c42b255b145df9e78bc86a4a9c0 (diff)
downloadeclipse.platform.team-75f5475d980fe2239d88201301f9ef607a735183.tar.gz
eclipse.platform.team-75f5475d980fe2239d88201301f9ef607a735183.tar.xz
eclipse.platform.team-75f5475d980fe2239d88201301f9ef607a735183.zip
7270: Support for back-out of deletions required
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitMergeAction.java46
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/GetMergeAction.java6
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java5
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncSet.java25
4 files changed, 64 insertions, 18 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitMergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitMergeAction.java
index 29f67d26f..9d9fc7dd8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitMergeAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitMergeAction.java
@@ -1,12 +1,14 @@
package org.eclipse.team.internal.ccvs.ui.sync;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
+
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
@@ -16,16 +18,16 @@ 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.ccvs.core.CVSTeamProvider;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.core.sync.IRemoteSyncElement;
+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.SyncView;
import org.eclipse.team.ui.sync.TeamFile;
import org.eclipse.team.ui.sync.UnchangedTeamContainer;
@@ -36,7 +38,7 @@ public class CommitMergeAction extends MergeAction {
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()) {
+ if (syncSet.hasConflicts() || syncSet.hasIncomingChanges()) {
String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
String question = Policy.bind("CommitMergeAction.questionRelease");
String title = Policy.bind("CommitMergeAction.titleRelease");
@@ -67,20 +69,31 @@ public class CommitMergeAction extends MergeAction {
}
}
ITeamNode[] changed = syncSet.getChangedNodes();
+ if (changed.length == 0) {
+ return syncSet;
+ }
IResource[] changedResources = new IResource[changed.length];
List additions = new ArrayList();
List deletions = new ArrayList();
List conflicts = new ArrayList();
+ List incoming = new ArrayList();
+
for (int i = 0; i < changed.length; i++) {
changedResources[i] = changed[i].getResource();
- // If it's an outgoing addition we need to 'add' it before comitting.
- // If it's an outgoing deletion we need to 'delete' it before committing.
- switch (changed[i].getKind() & Differencer.CHANGE_TYPE_MASK) {
+ int kind = changed[i].getKind();
+ switch (kind & Differencer.CHANGE_TYPE_MASK) {
case Differencer.ADDITION:
+ // Outgoing addition. 'add' it before committing.
additions.add(changed[i].getResource());
break;
case Differencer.DELETION:
- deletions.add(changed[i].getResource());
+ if ((kind & Differencer.DIRECTION_MASK) == ITeamNode.INCOMING) {
+ // Incoming deletion. makeOutgoing before committing.
+ incoming.add(changed[i]);
+ } else {
+ // Outgoing deletion. 'delete' it before committing.
+ deletions.add(changed[i].getResource());
+ }
break;
}
// If it's a conflicting change we need to mark it as merged before committing.
@@ -97,6 +110,19 @@ public class CommitMergeAction extends MergeAction {
// User cancelled. Remove the nodes from the sync set.
return null;
} else {
+ // Make any incoming deletions into outgoing changes before committing.
+ Iterator it = incoming.iterator();
+ while (it.hasNext()) {
+ ITeamNode node = (ITeamNode)it.next();
+ if (node instanceof TeamFile) {
+ CVSRemoteSyncElement element = (CVSRemoteSyncElement)((TeamFile)node).getMergeResource().getSyncElement();
+ element.makeOutgoing(monitor);
+ } else if (node instanceof ChangedTeamContainer) {
+ CVSRemoteSyncElement element = (CVSRemoteSyncElement)((ChangedTeamContainer)node).getMergeResource().getSyncElement();
+ element.makeOutgoing(monitor);
+ }
+ }
+
if (additions.size() != 0) {
manager.add((IResource[])additions.toArray(new IResource[0]), monitor);
}
@@ -124,9 +150,9 @@ public class CommitMergeAction extends MergeAction {
if (node instanceof TeamFile) {
int direction = kind & Differencer.DIRECTION_MASK;
if (direction == ITeamNode.OUTGOING || direction == Differencer.CONFLICTING) {
- return true;
+ return true;
}
- //allow to release over incoming deletions
+ // allow to release over incoming deletions
return (kind & Differencer.CHANGE_TYPE_MASK) == Differencer.DELETION;
}
if (node instanceof ChangedTeamContainer) {
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/GetMergeAction.java
index bcb086ab2..924bc6439 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/GetMergeAction.java
@@ -43,7 +43,7 @@ public class GetMergeAction extends MergeAction {
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()) {
+ 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");
@@ -74,12 +74,16 @@ public class GetMergeAction extends MergeAction {
}
}
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) {
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
index d165abf1f..8da1ff5e5 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncCompareInput.java
@@ -1,7 +1,7 @@
package org.eclipse.team.ui.sync;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
@@ -11,6 +11,7 @@ import org.eclipse.compare.CompareConfiguration;
import org.eclipse.compare.CompareEditorInput;
import org.eclipse.compare.structuremergeviewer.DiffContainer;
import org.eclipse.compare.structuremergeviewer.DiffNode;
+import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
@@ -156,7 +157,7 @@ public abstract class SyncCompareInput extends CompareEditorInput {
return false;
}
SyncSet set = new SyncSet(new StructuredSelection(diffRoot.getChildren()), 0);
- return set.hasIncomingChanges();
+ return set.hasIncomingChanges() || set.hasConflicts();
}
/**
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncSet.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncSet.java
index 4728ac590..81234ede9 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncSet.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncSet.java
@@ -1,7 +1,7 @@
package org.eclipse.team.ui.sync;
/*
- * (c) Copyright IBM Corp. 2000, 2001.
+ * (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
@@ -148,12 +148,24 @@ public class SyncSet {
/**
* Returns true if this sync set has incoming changes.
- * Note that conflicts are considered to have incoming changes.
+ * Note that conflicts are not considered to be incoming changes.
*/
public boolean hasIncomingChanges() {
for (Iterator it = set.iterator(); it.hasNext();) {
- int dir = ((ITeamNode)it.next()).getChangeDirection();
- if (dir == IRemoteSyncElement.INCOMING || dir == IRemoteSyncElement.CONFLICTING) {
+ if (((ITeamNode)it.next()).getChangeDirection() == IRemoteSyncElement.INCOMING) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Returns true if this sync set has outgoing changes.
+ * Note that conflicts are not considered to be outgoing changes.
+ */
+ public boolean hasOutgoingChanges() {
+ for (Iterator it = set.iterator(); it.hasNext();) {
+ if (((ITeamNode)it.next()).getChangeDirection() == IRemoteSyncElement.OUTGOING) {
return true;
}
}
@@ -200,7 +212,10 @@ public class SyncSet {
ITeamNode node = (ITeamNode)it.next();
int nodeDirection = node.getKind() & IRemoteSyncElement.DIRECTION_MASK;
if ((nodeDirection != IRemoteSyncElement.CONFLICTING) && (nodeDirection != direction)) {
- it.remove();
+ // Deletions always belong in the set.
+ if ((node.getKind() & IRemoteSyncElement.CHANGE_MASK) != Differencer.DELETION) {
+ it.remove();
+ }
}
}
}

Back to the top