Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2003-12-03 12:23:14 -0500
committerMichael Valenta2003-12-03 12:23:14 -0500
commit6d722bc601b2e70f6fb3e50f5aea7fa2364c9ef1 (patch)
tree2847ec3d1e6255fd4a5a3438c2342a4e9e6bacd8
parent5f99d331f258bc2c26cce23d8b9aa71355df5c85 (diff)
downloadeclipse.platform.team-6d722bc601b2e70f6fb3e50f5aea7fa2364c9ef1.tar.gz
eclipse.platform.team-6d722bc601b2e70f6fb3e50f5aea7fa2364c9ef1.tar.xz
eclipse.platform.team-6d722bc601b2e70f6fb3e50f5aea7fa2364c9ef1.zip
Fixed nested MarkAsMerged bug
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java11
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SubscriberConfirmMergedAction.java38
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java8
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java26
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java29
5 files changed, 88 insertions, 24 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
index 8b2068e5a..d907a414b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSSyncInfo.java
@@ -140,8 +140,11 @@ public class CVSSyncInfo extends SyncInfo {
*/
public void makeOutgoing(IProgressMonitor monitor) throws TeamException {
- // TODO: What is the impact of using whatever the current granularity is?
- // int syncKind = getSyncKind(GRANULARITY_TIMESTAMP , monitor);
+ // For folders, there is no outgoing, only in-sync
+ if (getLocal().getType() == IResource.FOLDER) {
+ makeInSync();
+ return;
+ }
int syncKind = getKind();
boolean incoming = (syncKind & DIRECTION_MASK) == INCOMING;
boolean outgoing = (syncKind & DIRECTION_MASK) == OUTGOING;
@@ -206,7 +209,9 @@ public class CVSSyncInfo extends SyncInfo {
}
}
if(info!=null) {
- info.setTag(local.getParent().getFolderSyncInfo().getTag());
+ FolderSyncInfo parentInfo = local.getParent().getFolderSyncInfo();
+ Assert.isNotNull(parentInfo);
+ info.setTag(parentInfo.getTag());
}
((ICVSFile)local).setSyncInfo(info, ICVSFile.UNKNOWN);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SubscriberConfirmMergedAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SubscriberConfirmMergedAction.java
index 7d93c8b96..e4bb26c5d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SubscriberConfirmMergedAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SubscriberConfirmMergedAction.java
@@ -11,10 +11,14 @@
package org.eclipse.team.internal.ccvs.ui.subscriber;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.subscribers.SyncInfo;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSSyncInfo;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter;
import org.eclipse.team.ui.synchronize.actions.SyncInfoSet;
@@ -41,13 +45,10 @@ public class SubscriberConfirmMergedAction extends CVSSubscriberAction {
monitor.beginTask(null, 100 * syncResources.length);
try {
for (int i = 0; i < syncResources.length; i++) {
- SyncInfo resource = syncResources[i];
-
- CVSSyncInfo cvsInfo = getCVSSyncInfo(resource);
- if (cvsInfo != null) {
- cvsInfo.makeOutgoing(Policy.subMonitorFor(monitor, 100));
- }
-
+ SyncInfo info = syncResources[i];
+ if (!makeOutgoing(info, Policy.subMonitorFor(monitor, 100))) {
+ // Failure was logged in makeOutgoing
+ }
}
} catch (TeamException e) {
handle(e);
@@ -56,4 +57,27 @@ public class SubscriberConfirmMergedAction extends CVSSubscriberAction {
}
}
+ private boolean makeOutgoing(SyncInfo info, IProgressMonitor monitor) throws CVSException, TeamException {
+ monitor.beginTask(null, 100);
+ try {
+ CVSSyncInfo cvsInfo = getCVSSyncInfo(info);
+ if (cvsInfo == null) {
+ CVSUIPlugin.log(IStatus.ERROR, "Synchronization information is missing for resource {0}" + cvsInfo.getLocal().getFullPath().toString(), null);
+ return false;
+ }
+ // Make sure the parent is managed
+ ICVSFolder parent = CVSWorkspaceRoot.getCVSFolderFor(cvsInfo.getLocal().getParent());
+ if (!parent.isCVSFolder()) {
+ // the parents must be made outgoing before the child can
+ SyncInfo parentInfo = cvsInfo.getSubscriber().getSyncInfo(parent.getIResource(), Policy.subMonitorFor(monitor, 10));
+ if (!makeOutgoing(parentInfo, Policy.subMonitorFor(monitor, 10))) {
+ return false;
+ }
+ }
+ cvsInfo.makeOutgoing(Policy.subMonitorFor(monitor, 80));
+ return true;
+ } finally {
+ monitor.done();
+ }
+ }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java
index 598b58f03..729094d9e 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSMergeSubscriberTest.java
@@ -74,14 +74,6 @@ public class CVSMergeSubscriberTest extends CVSSyncSubscriberTest {
action.getRunnable(new SyncInfoSet(infos)).run(DEFAULT_MONITOR);
}
-
- private void markAsMerged(CVSMergeSubscriber subscriber, IProject project, String[] resourcePaths) throws CoreException, TeamException, InvocationTargetException, InterruptedException {
- IResource[] resources = getResources(project, resourcePaths);
- SyncInfo[] infos = createSyncInfos(subscriber, resources);
- TestMarkAsMergedAction action = new TestMarkAsMergedAction();
- action.getRunnable(new SyncInfoSet(infos)).run(DEFAULT_MONITOR);
- }
-
/**
* Test the basic incoming changes cases
* - incoming addition
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
index 2c715cddf..c65d34f9b 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSSyncSubscriberTest.java
@@ -10,18 +10,31 @@
*******************************************************************************/
package org.eclipse.team.tests.ccvs.core.subscriber;
-import java.util.*;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
import junit.framework.AssertionFailedError;
-import org.eclipse.core.resources.*;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.subscribers.*;
+import org.eclipse.team.core.subscribers.ITeamResourceChangeListener;
+import org.eclipse.team.core.subscribers.SyncInfo;
+import org.eclipse.team.core.subscribers.TeamDelta;
+import org.eclipse.team.core.subscribers.TeamSubscriber;
import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSSyncTreeSubscriber;
import org.eclipse.team.tests.ccvs.core.EclipseTest;
import org.eclipse.team.tests.ccvs.ui.SynchronizeViewTestAdapter;
+import org.eclipse.team.ui.synchronize.actions.SyncInfoSet;
/**
* Provides test methods common to CVS sync subscribers
@@ -218,4 +231,11 @@ public abstract class CVSSyncSubscriberTest extends EclipseTest {
protected void assertProjectRemoved(TeamSubscriber subscriber, IProject project) throws TeamException {
getSyncInfoSource().assertProjectRemoved(subscriber, project);
}
+
+ protected void markAsMerged(CVSSyncTreeSubscriber subscriber, IProject project, String[] resourcePaths) throws CoreException, TeamException, InvocationTargetException, InterruptedException {
+ IResource[] resources = getResources(project, resourcePaths);
+ SyncInfo[] infos = createSyncInfos(subscriber, resources);
+ TestMarkAsMergedAction action = new TestMarkAsMergedAction();
+ action.getRunnable(new SyncInfoSet(infos)).run(DEFAULT_MONITOR);
+ }
}
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java
index 7d06341dd..72985d296 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java
@@ -62,8 +62,8 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest {
}
}
- protected TeamSubscriber getSubscriber() throws TeamException {
- return getWorkspaceSubscriber();
+ protected CVSSyncTreeSubscriber getSubscriber() throws TeamException {
+ return (CVSSyncTreeSubscriber)getWorkspaceSubscriber();
}
/* (non-Javadoc)
@@ -1250,6 +1250,29 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest {
if (syncBytes != null) {
assertTrue(ResourceSyncInfo.isBinary(syncBytes));
}
-
+ }
+
+ public void testNestedMarkAsMerged() throws CoreException, InvocationTargetException, InterruptedException {
+ // Create a project and checkout a copy
+ IProject project = createProject(new String[] { "file1.txt", "folder1/", "folder1/a.txt", "folder1/b.txt"});
+ IProject copy = checkoutCopy(project, "-copy");
+ // Add the same resources to both projects to create conflicting additions
+ buildResources(project, new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"}, false);
+ addResources(copy, new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"}, true);
+ assertSyncEquals("testNestedMarkAsMerged sync check", project,
+ new String[] { "folder2/", "folder2/file.txt", "folder2/file.txt"},
+ true, new int[] {
+ SyncInfo.CONFLICTING | SyncInfo.ADDITION,
+ SyncInfo.CONFLICTING | SyncInfo.ADDITION,
+ SyncInfo.CONFLICTING | SyncInfo.ADDITION
+ });
+ markAsMerged(getSubscriber(), project, new String[] {"folder2/file.txt"});
+ assertSyncEquals("testNestedMarkAsMerged sync check", project,
+ new String[] { "folder2/", "folder2/file.txt", "folder2/file2.txt"},
+ true, new int[] {
+ SyncInfo.IN_SYNC,
+ SyncInfo.OUTGOING | SyncInfo.CHANGE,
+ SyncInfo.CONFLICTING | SyncInfo.ADDITION
+ });
}
}

Back to the top