Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-06-06 21:11:13 -0400
committerMichael Valenta2002-06-06 21:11:13 -0400
commit8ba80adc8fb09bf29b44fba50a19a5c43c883fd8 (patch)
tree8c3f9abf44d5f2266eabacd383fc00dda8bb4fe0
parent84263f9b9316d2f852a6e4e4d1353539fb22f3fb (diff)
downloadeclipse.platform.team-MV_F3_Branch.tar.gz
eclipse.platform.team-MV_F3_Branch.tar.xz
eclipse.platform.team-MV_F3_Branch.zip
*** empty log message ***MV_F3_Branch
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java20
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java (renamed from bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java)61
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java12
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java25
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java4
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java4
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java25
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java18
-rw-r--r--tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java6
9 files changed, 120 insertions, 55 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
index a3d3e6928..b6ca9a1eb 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/target/TargetProvider.java
@@ -19,7 +19,7 @@ import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
-import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
public abstract class TargetProvider {
/**
@@ -136,8 +136,8 @@ public abstract class TargetProvider {
/**
* Answers true if the base identifier of the given resource is different to the
- * current released state of the resource. Also answer true if there was not
- * previously a correspondance between the local and remote resource.
+ * current released state of the resource. Answer false if there is no correspondence
+ * between the local and remote resources (i.e. hasBase(resource) returns false).
*
* @param resource the resource to test
* @param monitor a progress monitor
@@ -155,6 +155,14 @@ public abstract class TargetProvider {
* @param resource the resource to test
*/
public abstract boolean isDirty(IResource resource);
+
+ /**
+ * Answer true if the given resource at one time had a remote counterpart and still does
+ * to the knowledge of the provider.
+ *
+ * @param resource the resource to test
+ */
+ public abstract boolean hasBase(IResource resource);
public abstract void deregister(IProject project);
@@ -181,4 +189,10 @@ public abstract class TargetProvider {
throw new TeamException(e.getStatus());
}
}
+
+ /**
+ * Return an IRemoteSyncElement for the given resource. This element is used to
+ * compare the state of the local and remote resources.
+ */
+ public abstract IRemoteSyncElement getRemoteSyncElement(IResource resource);
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java
index a56297bb8..47649e149 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/RemoteTargetSyncElement.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/RemoteTargetSyncElement.java
@@ -8,7 +8,7 @@
* Contributors:
* IBM - Initial implementation
******************************************************************************/
-package org.eclipse.team.internal.ui.target;
+package org.eclipse.team.internal.core.target;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -20,8 +20,8 @@ import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.TargetManager;
import org.eclipse.team.core.target.TargetProvider;
-import org.eclipse.team.internal.ui.Policy;
-import org.eclipse.team.internal.ui.TeamUIPlugin;
+import org.eclipse.team.internal.core.Policy;
+import org.eclipse.team.internal.core.TeamPlugin;
/**
* Is a synchronization element that can calculate three-way sync
@@ -37,22 +37,17 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
private IResource local;
private TargetProvider provider;
- public RemoteTargetSyncElement(IResource local, IRemoteTargetResource remote) {
+ public RemoteTargetSyncElement(TargetProvider provider, IResource local, IRemoteTargetResource remote) {
this.local = local;
this.remote = remote;
- try {
- this.provider = TargetManager.getProvider(local.getProject());
- } catch (TeamException e) {
- TeamUIPlugin.log(e.getStatus());
- this.remote = null;
- }
+ this.provider = provider;
}
/**
* @see RemoteSyncElement#create(boolean, IResource, IRemoteResource, IRemoteResource, Object)
*/
public IRemoteSyncElement create(boolean isThreeWay, IResource local, IRemoteResource base, IRemoteResource remote, Object data) {
- return new RemoteTargetSyncElement(local, (IRemoteTargetResource)remote);
+ return new RemoteTargetSyncElement(provider, local, (IRemoteTargetResource)remote);
}
/**
@@ -73,7 +68,7 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
* @see LocalSyncElement#create(IResource, IRemoteResource, Object)
*/
public ILocalSyncElement create(IResource local, IRemoteResource base, Object data) {
- return new RemoteTargetSyncElement(local, remote);
+ return new RemoteTargetSyncElement(provider, local, (IRemoteTargetResource)base);
}
/**
@@ -125,15 +120,16 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
progress.beginTask(null, 100);
int description = IN_SYNC;
IResource local = getLocal();
- boolean isDirty = provider.isDirty(local);
- boolean isOutOfDate;
- try{
- isOutOfDate = provider.isOutOfDate(local, Policy.subMonitorFor(progress, 10));
- } catch(TeamException e) {
- isOutOfDate = true; // who knows?
- }
-
boolean localExists = local.exists();
+ boolean hasBase = provider.hasBase(local);
+ // isDirty and isOutOfDate only have meaning if there is a base
+ // XXX The defaults should give the same behavior as before
+ boolean isDirty = localExists;
+ boolean isOutOfDate = remote != null;
+ if (hasBase) {
+ isDirty = provider.isDirty(local);
+ isOutOfDate = isOutOfDate(Policy.subMonitorFor(progress, 10));
+ }
if (remote == null) {
if (!localExists) {
@@ -141,7 +137,7 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
// Assert.isTrue(false);
} else {
// no remote but a local
- if (!isDirty && isOutOfDate) {
+ if (!isDirty && hasBase) {
description = INCOMING | DELETION;
} else if (isDirty && isOutOfDate) {
description = CONFLICTING | CHANGE;
@@ -179,4 +175,27 @@ public class RemoteTargetSyncElement extends RemoteSyncElement {
}
return description;
}
+ /**
+ * Returns the provider.
+ * @return TargetProvider
+ */
+ protected TargetProvider getProvider() {
+ return provider;
+ }
+
+ /**
+ * Return true if the resource associated with the receiver is out-of-date
+ */
+ protected boolean isOutOfDate(IProgressMonitor monitor) {
+ IResource local = getLocal();
+ if (provider.hasBase(local)) {
+ try{
+ return provider.isOutOfDate(local, monitor);
+ } catch(TeamException e) {
+ return true; // who knows?
+ }
+ }
+ return false;
+ }
+
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
index 71f79de39..1795ddae0 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/ResourceState.java
@@ -274,8 +274,8 @@ public abstract class ResourceState {
* @see ITeamProvider#isDirty(IResource)
*/
public boolean isDirty() {
- if (!hasLocal())
- return hasPhantom();
+ if (!hasPhantom()) return false;
+ if (!hasLocal()) return true;
if (localBaseTimestamp == EMPTY_LOCALBASETS)
return localResource.getType() == IResource.FILE;
return localBaseTimestamp != localResource.getModificationStamp();
@@ -286,11 +286,9 @@ public abstract class ResourceState {
* current released state of the resource.
*/
public boolean isOutOfDate(IProgressMonitor monitor) throws TeamException {
- if (remoteBaseIdentifier.equals(EMPTY_REMOTEBASEID))
- return (localResource.getType() == IResource.FILE && hasRemote(monitor));
-
- String releasedIdentifier = null;
- releasedIdentifier = getReleasedIdentifier(monitor);
+ if (!hasPhantom()) return false;
+ if (remoteBaseIdentifier.equals(EMPTY_REMOTEBASEID)) return false;
+ String releasedIdentifier = getReleasedIdentifier(monitor);
return !remoteBaseIdentifier.equals(releasedIdentifier);
}
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java
index a86e310a4..cb7e5f2b3 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/internal/core/target/SynchronizedTargetProvider.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.core.target.IRemoteTargetResource;
import org.eclipse.team.core.target.ITargetRunnable;
import org.eclipse.team.core.target.Site;
@@ -208,4 +209,28 @@ public abstract class SynchronizedTargetProvider extends TargetProvider {
TeamPlugin.log(e.getStatus());
}
}
+
+ /**
+ * @see TargetProvider#getRemoteSyncElement(IResource)
+ */
+ public IRemoteSyncElement getRemoteSyncElement(IResource resource) {
+ return new RemoteTargetSyncElement(this, resource, getRemoteResourceFor(resource));
+ }
+
+
+ /**
+ * @see TargetProvider#hasBase(IResource)
+ */
+ public boolean hasBase(IResource resource) {
+ // the project always has a base
+ if (resource.getType() == IResource.PROJECT) return true;
+ try {
+ return getState(resource).hasPhantom();
+ } catch (TeamException e) {
+ TeamPlugin.log(e.getStatus());
+ return true;
+ }
+ }
+
+
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
index 3a34cd96a..fbc1d55ac 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/target/TargetSyncCompareInput.java
@@ -42,11 +42,11 @@ public class TargetSyncCompareInput extends SyncCompareInput {
monitor = Policy.monitorFor(monitor);
try {
monitor.beginTask(null, resources.length);
- RemoteTargetSyncElement[] elements = new RemoteTargetSyncElement[resources.length];
+ IRemoteSyncElement[] elements = new IRemoteSyncElement[resources.length];
for (int i = 0; i < resources.length; i++) {
IResource resource = resources[i];
TargetProvider provider = TargetManager.getProvider(resource.getProject());
- elements[i] = new RemoteTargetSyncElement(resources[i], provider.getRemoteResourceFor(resource));
+ elements[i] = provider.getRemoteSyncElement(resource);
monitor.worked(1);
}
return elements;
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
index 3eef2b1f8..43f096875 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/RemoteResourceTests.java
@@ -70,7 +70,7 @@ public class RemoteResourceTests extends TeamTest {
IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
TargetProvider target = getProvider(project);
IRemoteResource remote = target.getRemoteResourceFor(project.getFile("file1.txt"));
- InputStream jin = remote.getContents(null);
+ InputStream jin = remote.getContents(DEFAULT_MONITOR);
try {
while (jin.available() > 0) {
jin.read();
@@ -85,7 +85,7 @@ public class RemoteResourceTests extends TeamTest {
IProject project = createAndPut("getname", new String[] { "file1.txt", "folder1/", "folder1/b.txt" });
TargetProvider target = getProvider(project);
IRemoteResource remote = target.getRemoteResource();
- IRemoteResource[] altResources = remote.members(null);
+ IRemoteResource[] altResources = remote.members(DEFAULT_MONITOR);
for (int i = 0; i < altResources.length; i++) {
assertEquals(altResources[i], project.findMember(altResources[i].getName()));
}
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
index 5de7a53c8..ea3779427 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/SyncElementTest.java
@@ -12,17 +12,27 @@ package org.eclipse.team.tests.core;
import java.io.ByteArrayInputStream;
import java.io.IOException;
-import java.lang.reflect.Member;
-import junit.framework.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.core.runtime.*;
+import junit.framework.AssertionFailedError;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+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.team.core.TeamException;
-import org.eclipse.team.core.sync.*;
+import org.eclipse.team.core.sync.ILocalSyncElement;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.core.target.TargetManager;
import org.eclipse.team.core.target.TargetProvider;
import org.eclipse.team.internal.core.target.UrlUtil;
-import org.eclipse.team.internal.ui.target.RemoteTargetSyncElement;
public class SyncElementTest extends TeamTest {
/*
@@ -103,8 +113,7 @@ public class SyncElementTest extends TeamTest {
}
IRemoteSyncElement getRemoteSyncTree(IProject project, IProgressMonitor monitor) throws TeamException {
- IRemoteSyncElement result = new RemoteTargetSyncElement(project,getProvider(project).getRemoteResource());
- return result;
+ return getProvider(project).getRemoteSyncElement(project);
}
protected IProject checkoutCopy(IProject project, String postfix) throws CoreException,TeamException {
TargetProvider provider = getProvider(project);
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
index 46840a73e..951f63e92 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TargetProviderTests.java
@@ -75,14 +75,14 @@ public class TargetProviderTests extends TeamTest {
IProject project = getUniqueTestProject("get");
IResource[] resources = buildResources(project, new String[] { "file1.txt", "folder1/", "folder1/b.txt" }, false);
TargetProvider target = createProvider(project);
- target.put(resources, null);
+ target.put(resources, DEFAULT_MONITOR);
assertLocalEqualsRemote(project);
// test get on a new project
- project.delete(true, true, null);
- project.create(null);
- project.open(null);
+ project.delete(true, true, DEFAULT_MONITOR);
+ project.create(DEFAULT_MONITOR);
+ project.open(DEFAULT_MONITOR);
target = createProvider(project);
- target.get(new IResource[] { project }, null);
+ target.get(new IResource[] { project }, DEFAULT_MONITOR);
assertLocalEqualsRemote(project);
}
/**
@@ -97,10 +97,10 @@ public class TargetProviderTests extends TeamTest {
for (int i = 0; i < resources.length; i++) {
assertTrue(target.canPut(resources[i]));
}
- target.put(resources, null);
- project.delete(true, true, null);
- project.create(null);
- project.open(null);
+ target.put(resources, DEFAULT_MONITOR);
+ project.delete(true, true, DEFAULT_MONITOR);
+ project.create(DEFAULT_MONITOR);
+ project.open(DEFAULT_MONITOR);
target = createProvider(project);
for (int i = 0; i < resources.length; i++) {
assertTrue(target.canGet(resources[i]));
diff --git a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
index 28dec26c6..f7478e93f 100644
--- a/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
+++ b/tests/org.eclipse.team.tests.core/src/org/eclipse/team/tests/core/TeamTest.java
@@ -198,9 +198,9 @@ public class TeamTest extends EclipseWorkspaceTest {
// Ignore .project file
if (container2.getName().equals(".project"))
return;
- assertTrue(compareContent(container1.getContents(null), ((IFile) container2).getContents()));
+ assertTrue(compareContent(container1.getContents(DEFAULT_MONITOR), ((IFile) container2).getContents()));
} else {
- IRemoteResource[] remoteResources = container1.members(null);
+ IRemoteResource[] remoteResources = container1.members(DEFAULT_MONITOR);
IResource[] localResources = ((IFolder) container2).members();
for (int i = 0; i < localResources.length; i++) {
assertEquals(remoteResources[i], localResources[i]);
@@ -211,7 +211,7 @@ public class TeamTest extends EclipseWorkspaceTest {
IProject project = getUniqueTestProject(projectPrefix);
IResource[] resources = buildResources(project, resourceNames, false);
TargetProvider target = createProvider(project);
- target.put(resources, null);
+ target.put(resources, DEFAULT_MONITOR);
return project;
}

Back to the top