diff options
author | Michael Valenta | 2003-11-27 19:14:41 +0000 |
---|---|---|
committer | Michael Valenta | 2003-11-27 19:14:41 +0000 |
commit | 325b4933e94248b1f6ce38ef60383fd7973e925c (patch) | |
tree | 93bba80f80e0c176f11072461e0ad165a850dc0e | |
parent | b90a0d219f8ebced02a245dc922c351fba34f77e (diff) | |
download | eclipse.platform.team-325b4933e94248b1f6ce38ef60383fd7973e925c.tar.gz eclipse.platform.team-325b4933e94248b1f6ce38ef60383fd7973e925c.tar.xz eclipse.platform.team-325b4933e94248b1f6ce38ef60383fd7973e925c.zip |
47560: No warning when updating binary resources from CVS server
2 files changed, 73 insertions, 29 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateAction.java index e885ca707..b8145a7ec 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateAction.java @@ -11,11 +11,7 @@ package org.eclipse.team.internal.ccvs.ui.subscriber; 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 java.util.*; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; @@ -25,16 +21,18 @@ import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.team.core.TeamException; import org.eclipse.team.core.subscribers.SyncInfo; import org.eclipse.team.core.sync.IRemoteResource; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.ICVSFile; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; +import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; +import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.ui.Policy; import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation; import org.eclipse.team.internal.ui.TeamUIPlugin; import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter; import org.eclipse.team.ui.synchronize.actions.SyncInfoSet; -import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter.AndSyncInfoFilter; -import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter.OrSyncInfoFilter; -import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter.SyncInfoDirectionFilter; +import org.eclipse.team.ui.synchronize.actions.SyncInfoFilter.*; /** * This update action will update all mergable resources first and then prompt the @@ -234,6 +232,31 @@ public abstract class SafeUpdateAction extends CVSSubscriberAction { } } }), + // Conflicts where the file type is binary will work but are not merged + // so they should be skipped + new AndSyncInfoFilter(new SyncInfoFilter[] { + SyncInfoFilter.getDirectionAndChangeFilter(SyncInfo.CONFLICTING, SyncInfo.CHANGE), + new SyncInfoFilter() { + public boolean select(SyncInfo info) { + IResource local = info.getLocal(); + if (local.getType() == IResource.FILE) { + try { + ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local); + byte[] syncBytes = file.getSyncBytes(); + if (syncBytes != null) { + return ResourceSyncInfo.isBinary(syncBytes); + } + } catch (CVSException e) { + // There was an error obtaining or interpreting the sync bytes + // Log it and skip the file + CVSProviderPlugin.log(e); + return true; + } + } + return false; + } + } + }), // Outgoing changes may not fail but they are skipped as well new SyncInfoDirectionFilter(SyncInfo.OUTGOING) }); 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 58a631b88..6db4cf792 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 @@ -13,38 +13,22 @@ package org.eclipse.team.tests.ccvs.core.subscriber; import java.io.ByteArrayInputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; +import java.util.*; import junit.framework.Test; import junit.framework.TestSuite; -import org.eclipse.core.resources.IContainer; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.resources.IProjectDescription; -import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.resources.*; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.Path; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.subscribers.ContentComparisonCriteria; -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.internal.ccvs.core.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.internal.ccvs.core.CVSTag; -import org.eclipse.team.internal.ccvs.core.CVSTeamProvider; -import org.eclipse.team.internal.ccvs.core.ICVSFolder; -import org.eclipse.team.internal.ccvs.core.ICVSResource; +import org.eclipse.team.core.subscribers.*; +import org.eclipse.team.internal.ccvs.core.*; import org.eclipse.team.internal.ccvs.core.client.Command; import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; +import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; import org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberAction; import org.eclipse.team.tests.ccvs.core.CVSTestSetup; import org.eclipse.team.ui.synchronize.actions.SyncInfoSet; @@ -1231,4 +1215,41 @@ public class CVSWorkspaceSubscriberTest extends CVSSyncSubscriberTest { project.close(null); assertProjectRemoved(getWorkspaceSubscriber(), project); } + + public void testUpdateBinaryConflict() throws TeamException, CoreException, InvocationTargetException, InterruptedException { + // Create a shared project with a binary file + IProject project = createProject(new String[] { "binary.gif"}); + assertIsBinary(project.getFile("binary.gif")); + + // Checkout a copy, modify the binary file and commit + IProject copy = checkoutCopy(project, "-copy"); + assertIsBinary(copy.getFile("binary.gif")); + setContentsAndEnsureModified(copy.getFile("binary.gif")); + commitProject(copy); + + // Modify the same binary file and ensure sync is correct + setContentsAndEnsureModified(project.getFile("binary.gif")); + assertSyncEquals("testProjectClose sync check", project, + new String[] { "binary.gif"}, + true, new int[] { + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + }); + + // Perform an update and ensure the binary conflict is skipped + update(project, new String[] { "binary.gif"}); + assertSyncEquals("testProjectClose sync check", project, + new String[] { "binary.gif"}, + true, new int[] { + SyncInfo.CONFLICTING | SyncInfo.CHANGE, + }); + } + + private void assertIsBinary(IFile local) throws CVSException { + ICVSFile file = CVSWorkspaceRoot.getCVSFileFor((IFile)local); + byte[] syncBytes = file.getSyncBytes(); + if (syncBytes != null) { + assertTrue(ResourceSyncInfo.isBinary(syncBytes)); + } + + } } |