diff options
author | Jean Michel-Lemieux | 2002-03-13 14:53:08 +0000 |
---|---|---|
committer | Jean Michel-Lemieux | 2002-03-13 14:53:08 +0000 |
commit | 00908821aceaf3367c1503915cdb9a8ae2b47d94 (patch) | |
tree | cd6e948b29809b6703e0591b693cf06072077bd0 | |
parent | e688dd4cbd7cf89ff7461f16a0f78501e825154b (diff) | |
download | eclipse.platform.team-00908821aceaf3367c1503915cdb9a8ae2b47d94.tar.gz eclipse.platform.team-00908821aceaf3367c1503915cdb9a8ae2b47d94.tar.xz eclipse.platform.team-00908821aceaf3367c1503915cdb9a8ae2b47d94.zip |
- Conflicting changes now properly categorized as conflicting
additions/deletions/change.
- ignore base tree becomes three way in the sync classes.
- EclipseFile handles cvs server reponses of create/update/changed correctly.
9 files changed, 52 insertions, 151 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java index e79b33fcc..b260b3235 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java @@ -40,5 +40,5 @@ public interface IRemoteSyncElement extends ILocalSyncElement { * comparisons and <code>false</code> if it should. If the base tree is ignored the * sync comparison can be based on isOutOfDate and isDirty methods only. */ - public boolean ignoreBaseTree(); + public boolean isThreeWay(); }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ISyncProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ISyncProvider.java deleted file mode 100644 index f5a0d40dc..000000000 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ISyncProvider.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.eclipse.team.core.sync; - -/* - * (c) Copyright IBM Corp. 2000, 2001. - * All Rights Reserved. - */ - -import org.eclipse.core.resources.IResource; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.team.core.TeamException; - -/** - * The <code>ISyncProvider</code> interface exposes a standard mechanism for retreiving - * local (e.g. checkedout, dirty) and remote (outOfDate) synchronization information from a - * provider. - * <p> - * Local synchronization information includes only state for local resources without considering the - * remote contents. The sync provider API suggests that local sync information should be cached by - * a provider whereas remote sync information may not.</p> - * <p> - * Remote synchronization information considers the remote contents and allows for determining - * incoming changes. - * - * @see ILocalSyncElement - * @see IRemoteSyncElement - */ -public interface ISyncProvider { - - /** - * Allows the provider to refresh the resource state information for a resource. This is mostly used - * to allow external provider tools to interoperate with the workbench provider. If an external tool - * modifies the state information for a resource this method can be called to update the provider's - * plug-in state information. - * <p> - * Some state information may be cached by the provider implementation to avoid server round - * trips and allow responsive API calls via the element tree returned from <code>getLocalSyncTree</code>. - * Where a caller is relying on this information being current, they should first explicitly refresh - * the resouce state. Of course, there are no guarantees that the refreshed information will not - * become stale immediately after the call to this method.</p> - * <p> - * When resource state changes occur the provider must broadcast state change events - * to allow all UI components the opportunity to update.</p> - * - * @param resources the local resource to be refreshed. - * @param depth the depth to traverse the given resources, taken from <code>IResource</code> - * constants. - * @param progress a progress monitor to indicate the duration of the operation, or - * <code>null</code> if progress reporting is not required. - * @throws TeamProviderException if there is a problem refreshing one or more of - * the resources. The exception will contain multiple statuses, one for each resource in the - * <code>resources</code> array. Possible status codes include: - * <ul> - * <li>IO_FAILED</li> - * <li>UNABLE</li> - * </ul> - */ - public void refreshLocalSync(IResource resource, int depth, IProgressMonitor progress) throws TeamException; - - /** - * Answers the local synchronization tree. This operation should be very responsive such that it can safely - * be called for UI decorations. - * - * @param resource the local resource for which to get local synchronization information. - * @param depth the depth to traverse the given resource, taken from <code>IResource</code> - * constants. - * - * @return the local sync element that describes the resources sync state. If a depth > 0 was - * provided the returned <code>ILocalSyncElement</code> is a tree of local sync elements - * rooted at the specified local resource. - */ - public ILocalSyncElement getLocalSyncTree(IResource resource, int depth); - - /** - * Answers the remote synchronization tree. This operation can be long running. - * - * @param resource the local resource for which to get remote synchronization information. - * @param depth the depth to traverse the given resource, taken from <code>IResource</code> - * constants. - * - * @return the remote sync element that describes the resources sync state. If a depth > 0 was - * provided the returned <code>IRemoteSyncElement</code> is a tree of remote sync elements - * rooted at the specified local resource. - * @throws TeamProviderException if there is a problem retrieving one or more of - * the remote resources. Possible status codes include: - * <ul> - * <li>IO_FAILED</li> - * <li>UNABLE</li> - * </ul> - */ - public IRemoteSyncElement getRemoteSyncTree(IResource resource, int depth, IProgressMonitor progress) throws TeamException; -}
\ No newline at end of file diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java index bbb89245b..6aef71f3f 100644 --- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java +++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java @@ -48,7 +48,7 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem * * @return a client specific sync element. */ - public abstract IRemoteSyncElement create(boolean ignoreBaseTree, IResource local, IRemoteResource base, IRemoteResource remote, Object data); + public abstract IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data); /* * @see ILocalSyncElement#members() @@ -63,7 +63,7 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem remote != null ? remote.members(progress) : new IRemoteResource[0]; IRemoteResource[] baseChildren = - base != null && !ignoreBaseTree() ? base.members(progress) : new IRemoteResource[0]; + base != null ? base.members(progress) : new IRemoteResource[0]; IResource[] localChildren; try { @@ -143,7 +143,7 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem } if(!localChild.exists() || !isIgnored(localChild)) { - syncChildren.add(create(ignoreBaseTree(), localChild, baseChild, remoteChild, getData())); + syncChildren.add(create(isThreeWay(), localChild, baseChild, remoteChild, getData())); } } return (IRemoteSyncElement[]) syncChildren.toArray(new IRemoteSyncElement[syncChildren.size()]); @@ -160,25 +160,14 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem int description = IN_SYNC; IResource local = getLocal(); - boolean localExists = getLocal().exists(); IRemoteResource remote = getRemote(); IRemoteResource base = getBase(); + boolean localExists = getLocal().exists(); boolean isDirty = isDirty(); boolean isOutOfDate = isOutOfDate(); - boolean threeWay = (base != null && !ignoreBaseTree() ? true : false); - - - // XXX projects are always in sync. - if(local.getType() == IResource.PROJECT) { - if (remote == null) - return OUTGOING | ADDITION; - else - return description; - } - - if (threeWay) { + if (isThreeWay()) { if (base == null) { if (remote == null) { if (!localExists) { @@ -374,4 +363,31 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem return ((IContainer) parent).getFile(new Path(childName)); } } + + /* + * @see Object#toString() + */ + public String toString() { + StringBuffer buffer = new StringBuffer(); + buffer.append(getName() + "["); + int kind = getSyncKind(GRANULARITY_TIMESTAMP, null); + if(kind==IN_SYNC) { + buffer.append("in-sync"); + } else { + switch(kind & DIRECTION_MASK) { + case CONFLICTING: buffer.append("conflicting"); break; + case OUTGOING: buffer.append("outgoing"); break; + case INCOMING: buffer.append("incoming"); break; + } + switch(kind & DIRECTION_MASK) { + case CHANGE: buffer.append("change"); break; + case ADDITION: buffer.append("addition"); break; + case DELETION: buffer.append("deletion"); break; + } + if((kind & MANUAL_CONFLICT) != 0) buffer.append("{manual}"); + if((kind & AUTOMERGE_CONFLICT) != 0) buffer.append("{auto}"); + } + buffer.append("]"); + return buffer.toString(); + } }
\ No newline at end of file diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java index 592e81f52..8708710fd 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java @@ -29,19 +29,19 @@ public class CVSRemoteSyncElement extends RemoteSyncElement { CVSLocalSyncElement localSync; IRemoteResource remote; - boolean ignoreBaseTree = true; + boolean isThreeWay = true; - public CVSRemoteSyncElement(boolean ignoreBaseTree, IResource local, IRemoteResource base, IRemoteResource remote) { + public CVSRemoteSyncElement(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote) { localSync = new CVSLocalSyncElement(local, base); this.remote = remote; - this.ignoreBaseTree = ignoreBaseTree; + this.isThreeWay = isThreeWay; } /* * @see RemoteSyncElement#create(IResource, IRemoteResource, IRemoteResource) */ - public IRemoteSyncElement create(boolean ignoreBaseTree, IResource local, IRemoteResource base, IRemoteResource remote, Object data) { - return new CVSRemoteSyncElement(ignoreBaseTree, local, base, remote); + public IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data) { + return new CVSRemoteSyncElement(isThreeWay, local, base, remote); } /* @@ -133,8 +133,8 @@ public class CVSRemoteSyncElement extends RemoteSyncElement { /* * @see IRemoteSyncElement#ignoreBaseTree() */ - public boolean ignoreBaseTree() { - return ignoreBaseTree; + public boolean isThreeWay() { + return isThreeWay; } /* @@ -276,16 +276,12 @@ public class CVSRemoteSyncElement extends RemoteSyncElement { // the server compared both text files and decided that it cannot merge // them without line conflicts. case Update.STATE_CONFLICT: - return ILocalSyncElement.CONFLICTING | - ILocalSyncElement.CHANGE | - ILocalSyncElement.MANUAL_CONFLICT; + return kind | ILocalSyncElement.MANUAL_CONFLICT; // the server compared both text files and decided that it can safely merge // them without line conflicts. case Update.STATE_MERGEABLE_CONFLICT: - return ILocalSyncElement.CONFLICTING | - ILocalSyncElement.CHANGE | - ILocalSyncElement.AUTOMERGE_CONFLICT; + return kind | ILocalSyncElement.AUTOMERGE_CONFLICT; } } @@ -296,8 +292,8 @@ public class CVSRemoteSyncElement extends RemoteSyncElement { } /* - * If the resource has a delete/delete conflict then ensure that the local is unmanaged so that the sync info - * can be properly flushed. + * If the resource has a delete/delete conflict then ensure that the local is unmanaged so that the + * sync info can be properly flushed. */ private int handleDeletionConflicts(int kind) { if(kind == (IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.DELETION | IRemoteSyncElement.PSEUDO_CONFLICT)) { diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java index c6a45e510..11360af5f 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSWorkspaceRoot.java @@ -111,7 +111,7 @@ public class CVSWorkspaceRoot { baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); } - return new CVSRemoteSyncElement(false, resource, baseTree, remote); + return new CVSRemoteSyncElement(true /*three way*/, resource, baseTree, remote); } public static ICVSRemoteResource getRemoteTree(IResource resource, CVSTag tag, IProgressMonitor progress) throws TeamException { diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java index d2b6f58f0..26352f208 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java @@ -74,10 +74,6 @@ class EclipseFile extends EclipseResource implements ICVSFile { try { IFile file = getIFile(); if (responseType == CREATED || (responseType == UPDATED && ! resource.exists())) { - // XXX Temporary deletion of existing resource - if (file.exists()) { - file.delete(true, true, null); - } file.create(new ByteArrayInputStream(toByteArray()), false /*force*/, null); } else if(responseType == UPDATE_EXISTING) { file.setContents(new ByteArrayInputStream(toByteArray()), false /*force*/, true /*keep history*/, null); diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java index d0319548c..be5535056 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseSynchronizer.java @@ -5,11 +5,6 @@ package org.eclipse.team.internal.ccvs.core.resources; * All Rights Reserved. */ -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -21,21 +16,14 @@ import java.util.Set; import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; -import org.eclipse.core.resources.IResourceVisitor; -import org.eclipse.core.resources.ISynchronizer; -import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.QualifiedName; import org.eclipse.team.ccvs.core.CVSProviderPlugin; -import org.eclipse.team.ccvs.core.CVSTag; -import org.eclipse.team.ccvs.core.ICVSFile; import org.eclipse.team.ccvs.core.ICVSFolder; -import org.eclipse.team.ccvs.core.ICVSResource; import org.eclipse.team.core.TeamPlugin; -import org.eclipse.team.core.sync.ISyncProvider; import org.eclipse.team.internal.ccvs.core.CVSException; import org.eclipse.team.internal.ccvs.core.Policy; import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java index c761429fc..93749c996 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java @@ -48,7 +48,7 @@ public class MergeEditorInput extends CVSSyncCompareInput { try { IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(project, start, Policy.subMonitorFor(monitor, 50)); IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(project, end, Policy.subMonitorFor(monitor, 50)); - return new IRemoteSyncElement[] {new CVSRemoteSyncElement(false, project, base, remote)}; + return new IRemoteSyncElement[] {new CVSRemoteSyncElement(true /*three way*/, project, base, remote)}; } finally { monitor.done(); } diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java index dbcf18838..fb52d9f59 100644 --- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java +++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/SyncElementTest.java @@ -32,10 +32,6 @@ import org.eclipse.team.tests.ccvs.core.CVSTestSetup; import org.eclipse.team.tests.ccvs.core.EclipseTest; import org.eclipse.team.tests.ccvs.core.JUnitTestCase; -/** - * @version 1.0 - * @author ${user} - */ public class SyncElementTest extends EclipseTest { /** @@ -368,10 +364,10 @@ public class SyncElementTest extends EclipseTest { new String[] { "file.txt", "add1a.txt", "add1b.txt", "add2a.txt", "add2b.txt", "add3.txt"}, new int[] { IRemoteSyncElement.IN_SYNC, - IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE, - IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE, - IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE, - IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE, + IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION, + IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION, + IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION, + IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION, IRemoteSyncElement.OUTGOING | IRemoteSyncElement.ADDITION }); // Release the conflict cases (MERGE is not required for add3.txt but we do it anyway to ensure it doesn't cause problems) @@ -583,7 +579,7 @@ public class SyncElementTest extends EclipseTest { new String[] { "file.txt", "folder1/", "folder1/file.txt", "folder2/", "folder2/file.txt"}, new int[] { IRemoteSyncElement.IN_SYNC, - IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.CHANGE, + IRemoteSyncElement.CONFLICTING | IRemoteSyncElement.ADDITION, IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION, IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION, IRemoteSyncElement.INCOMING | IRemoteSyncElement.ADDITION}); @@ -755,7 +751,7 @@ public class SyncElementTest extends EclipseTest { IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(project, new CVSTag("v1", CVSTag.VERSION), DEFAULT_MONITOR); IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(project, new CVSTag("branch1", CVSTag.BRANCH), DEFAULT_MONITOR); - IRemoteSyncElement tree = new CVSRemoteSyncElement(false, project, base, remote); + IRemoteSyncElement tree = new CVSRemoteSyncElement(true /*three way*/, project, base, remote); // watch for empty directories and the prune option!!! assertSyncEquals("testSimpleMerge sync check", tree, |