Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-01-30 16:23:14 +0000
committerMichael Valenta2002-01-30 16:23:14 +0000
commit9b0f51b3f4bef582b145ec212a5ac7d10c4150f2 (patch)
treefd9f74f9f51080a4e7098f2d7ca39fe0b2bf5ddd
parentb712681ab2695bf4e31555aa71874f6611e370fb (diff)
downloadeclipse.platform.team-9b0f51b3f4bef582b145ec212a5ac7d10c4150f2.tar.gz
eclipse.platform.team-9b0f51b3f4bef582b145ec212a5ac7d10c4150f2.tar.xz
eclipse.platform.team-9b0f51b3f4bef582b145ec212a5ac7d10c4150f2.zip
Slight refactoring
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java5
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java34
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java4
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java12
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java2
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java15
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java91
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java7
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java11
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java21
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java2
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java13
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java5
-rw-r--r--tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java18
22 files changed, 183 insertions, 101 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
index 0fc89ef9f..2f176f702 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSProvider.java
@@ -33,7 +33,6 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSTag;
import org.eclipse.team.ccvs.core.CVSTeamProvider;
@@ -59,9 +58,7 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
-import org.eclipse.team.internal.ccvs.core.syncinfo.FileSystemSynchronizer;
import org.eclipse.team.internal.ccvs.core.util.Util;
public class CVSProvider implements ICVSProvider {
@@ -228,7 +225,7 @@ public class CVSProvider implements ICVSProvider {
RemoteFolder resource = (RemoteFolder)resources[i];
if (projects != null)
project = projects[i];
- checkout(resource.getRepository(), project, resource.getRemotePath(), resource.getTag(), Policy.subMonitorFor(pm, 1000));
+ checkout(resource.getRepository(), project, resource.getRepositoryRelativePath(), resource.getTag(), Policy.subMonitorFor(pm, 1000));
}
}
catch (TeamException e) {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
index 11c28e1ad..96256ff62 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteResource.java
@@ -38,7 +38,7 @@ public interface ICVSRemoteResource extends IRemoteResource {
/**
* Answers the repository relative path of this remote folder.
*/
- public String getRelativePath();
+ public String getRepositoryRelativePath();
/**
* Compares two objects for equality; for cvs remote resources, equality is defined in
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
index 04ff3f80a..4baa88039 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Checkout.java
@@ -6,10 +6,14 @@ package org.eclipse.team.internal.ccvs.core.client;
*/
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.Option;
+import org.eclipse.team.internal.ccvs.core.client.listeners.ModuleDefinitionsListener;
+import org.eclipse.team.internal.ccvs.core.client.listeners.ModuleExpansion;
+import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.ICVSResourceVisitor;
import org.eclipse.team.internal.ccvs.core.util.Assert;
@@ -21,14 +25,20 @@ public class Checkout extends Command {
return new LocalOption("-d", moduleName);
}
+ /** Command options found in the CVSROOT/modules file */
+ public static LocalOption ALIAS = new LocalOption("-a");
+ public static LocalOption makeStatusOption(String status) {
+ return new LocalOption("-s", status);
+ }
+
protected Checkout() { }
protected String getCommandId() {
return "co";
}
- protected ICVSResource[] computeWorkResources(Session session, String[] arguments)
+ protected ICVSResource[] computeWorkResources(Session session, String[] arguments, LocalOption[] localOptions)
throws CVSException {
- if (arguments.length < 1) throw new IllegalArgumentException();
+ if (arguments.length < 1 && ! FETCH_MODULE_ALIASES.isElementOf(localOptions)) throw new IllegalArgumentException();
return new ICVSResource[0];
}
@@ -81,5 +91,23 @@ public class Checkout extends Command {
}
}
}
-
+
+ /**
+ * Perform a checkout to get the module expansions defined in the CVSROOT/modules file
+ */
+ public ModuleExpansion[] getModuleExpansions(Session session, IProgressMonitor monitor)
+ throws CVSException {
+
+ ModuleDefinitionsListener moduleDefinitionListener = new ModuleDefinitionsListener();
+
+ IStatus status = execute(session, NO_GLOBAL_OPTIONS, new LocalOption[] {FETCH_MODULE_ALIASES}, NO_ARGUMENTS,
+ moduleDefinitionListener, monitor);
+
+ if (status.getCode() == CVSException.SERVER_ERROR) {
+ // XXX diff errors??
+ throw new CVSServerException(status);
+ }
+
+ return moduleDefinitionListener.getModuleExpansions();
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
index 167b4a5d5..3858e3da6 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Command.java
@@ -197,7 +197,7 @@ public abstract class Command {
* can be more easily manipulated. Subclasses must override this method
* if this assumption is false.
*/
- protected ICVSResource[] computeWorkResources(Session session, String[] arguments)
+ protected ICVSResource[] computeWorkResources(Session session, String[] arguments, LocalOption[] localOptions)
throws CVSException {
ICVSFolder localRoot = session.getLocalRoot();
@@ -310,7 +310,7 @@ public abstract class Command {
// Ensure that the commands run with the latest contents of the CVS subdirectory sync files
// and not the cached values. Allow 10% of work.
- resources = computeWorkResources(session, arguments);
+ resources = computeWorkResources(session, arguments, localOptions);
reloadSyncInfo(resources, Policy.subMonitorFor(monitor, 10));
Policy.checkCanceled(monitor);
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
index 111922730..508e65d12 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Import.java
@@ -23,7 +23,7 @@ public class Import extends Command {
return "import";
}
- protected ICVSResource[] computeWorkResources(Session session, String[] arguments)
+ protected ICVSResource[] computeWorkResources(Session session, String[] arguments, LocalOption[] localOptions)
throws CVSException {
if (arguments.length < 3) throw new IllegalArgumentException();
return new ICVSResource[0];
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
index d177a2d09..2a5b8d5cc 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Tag.java
@@ -20,12 +20,12 @@ public class Tag extends Command {
return "tag";
}
- protected ICVSResource[] computeWorkResources(Session session, String[] arguments)
+ protected ICVSResource[] computeWorkResources(Session session, String[] arguments, LocalOption[] localOptions)
throws CVSException {
if (arguments.length < 1) throw new IllegalArgumentException();
String[] allButFirst = new String[arguments.length - 1];
System.arraycopy(arguments, 1, allButFirst, 0, arguments.length - 1);
- return super.computeWorkResources(session, allButFirst);
+ return super.computeWorkResources(session, allButFirst, localOptions);
}
protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions,
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
index 85cda3835..ff566028a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/IStatusListener.java
@@ -12,11 +12,9 @@ public interface IStatusListener {
public static final String FOLDER_REVISION = "";
/**
- * provides access to the revision of a file through
- * the use of the Status command.
+ * Provides access to the revision of a file through the use of the Status command.
*
- * @see StatusMessageHandler
- * @see StatusErrorHandler
+ * The provided path is the absoulte remote path of the resource including the repository root directory
*/
public void fileStatus(IPath path, String remoteRevision);
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
index a3dc5df5e..519bebc6a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/listeners/StatusListener.java
@@ -25,6 +25,7 @@ public class StatusListener implements ICommandOutputListener {
public IStatus messageLine(String line, ICVSFolder commandRoot,
IProgressMonitor monitor) {
+
// We're only concerned about file revisions.
if (line.startsWith(" Repository revision:")) {
if (!line.startsWith(" Repository revision: No revision control file")) {
@@ -34,15 +35,8 @@ public class StatusListener implements ICommandOutputListener {
// This is the full location on the server (e.g. /home/cvs/repo/project/file.txt)
String fileLocation = line.substring(separatingTabIndex + 1, line.length() - 2);
- // This is the path relative to the ICVSResource used as the root of the command
- IPath fullPath;
- try {
- fullPath = new Path(fileLocation.substring(
- commandRoot.getRemoteLocation(commandRoot).length() + 1));
- } catch (CVSException e) {
- return new Status(IStatus.ERROR, CVSProviderPlugin.ID, CVSException.IO_FAILED,
- "could not get remote location of resource", e);
- }
+ // This is the absolute remote pathincluding the repository root directory
+ IPath fullPath = new Path(fileLocation);
// If the status returns that the file is in the Attic, then remove the
// Attic segment. This is because files added to a branch that are not in
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java
index e3c54919b..3ea3c5417 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/ICVSResource.java
@@ -75,7 +75,7 @@ public interface ICVSResource {
public boolean exists() throws CVSException;
/**
- * Answers a relative path to the given ancestor.
+ * Answers the local relative path from the given ancestor to the receiver.
*
* @return the ancestor relative path for this resource.
*/
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
index 5a41bfeae..1413b9d18 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/LocalResource.java
@@ -60,7 +60,7 @@ public abstract class LocalResource implements ICVSResource {
}
result = Util.getRelativePath(rootFolder.getPath(),getPath());
- return result.replace('\\', '/');
+ return result;
}
/**
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index 2798e6269..8b02e0624 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -144,7 +144,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
return null;
}
}
-
+
/**
* @see ICVSRemoteFile#getLogEntries()
*/
@@ -185,7 +185,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
* Therefore, we need a new parent so that we can fecth the contents of the remote file revision
*/
public RemoteFile toRevision(String revision) {
- RemoteFolder newParent = new RemoteFolder(null, parent.getRepository(), new Path(parent.getRemotePath()), parent.getTag());
+ RemoteFolder newParent = new RemoteFolder(null, parent.getRepository(), new Path(parent.getRepositoryRelativePath()), parent.getTag());
RemoteFile file = new RemoteFile(newParent, getName(), revision, CVSTag.DEFAULT);
newParent.setChildren(new ICVSRemoteResource[] {file});
return file;
@@ -221,13 +221,6 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
}
/**
- * @see ICVSRemoteFolder#getRelativePath()
- */
- public String getRelativePath() {
- return getRemotePath();
- }
-
- /**
* @see ICVSResource#getRemoteLocation(ICVSFolder)
*/
public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
@@ -237,8 +230,8 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
/**
* Get the remote path for the receiver relative to the repository location path
*/
- public String getRemotePath() {
- String parentPath = parent.getRemotePath();
+ public String getRepositoryRelativePath() {
+ String parentPath = parent.getRepositoryRelativePath();
return parentPath + Session.SERVER_SEPARATOR + getName();
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
index 7be17c5c9..1b423204a 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolder.java
@@ -34,30 +34,48 @@ import org.eclipse.team.internal.ccvs.core.client.listeners.IStatusListener;
import org.eclipse.team.internal.ccvs.core.client.listeners.IUpdateMessageListener;
import org.eclipse.team.internal.ccvs.core.client.listeners.StatusListener;
import org.eclipse.team.internal.ccvs.core.client.listeners.UpdateListener;
-import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
-import org.eclipse.team.internal.ccvs.core.syncinfo.*;
+import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
+import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
+import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* This class provides the implementation of ICVSRemoteFolder
+ *
+ * The parent of the RemoteFolder represents the folders parent in a local configuration.
+ * For instance, the parent may correspond to the remote parent or may be a folder in the
+ * same repository that has no physical relationship to the RemoteFolder (resulting from the use
+ * of a module definition, for instance). A RemoteFolder may not have a parent, indicating that it is
+ * the root of the local configuration it represents.
+ *
+ * A RemoteFolder has the following:
+ * A name in the folder's local configuration
+ *
*/
public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, ICVSFolder {
+ public static final String VIRTUAL_DIRECTORY = "CVSROOT/Emptydir";
+
+ private FolderSyncInfo folderInfo;
private ICVSRemoteResource[] children;
- private CVSRepositoryLocation repository;
- private IPath repositoryRelativePath;
- private CVSTag tag;
+ private ICVSRepositoryLocation repository;
/**
* Constructor for RemoteFolder.
*/
public RemoteFolder(RemoteFolder parent, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
- String name = repositoryRelativePath.lastSegment() == null ? "" : repositoryRelativePath.lastSegment();
+ this(parent,
+ repositoryRelativePath.lastSegment() == null ? "" : repositoryRelativePath.lastSegment(),
+ repository,
+ repositoryRelativePath,
+ tag);
+ }
+
+ public RemoteFolder(RemoteFolder parent, String name, ICVSRepositoryLocation repository, IPath repositoryRelativePath, CVSTag tag) {
this.info = new ResourceSyncInfo(name);
this.parent = parent;
- this.tag = tag;
- this.repository = (CVSRepositoryLocation)repository;
- this.repositoryRelativePath = repositoryRelativePath;
+ this.folderInfo = new FolderSyncInfo(repositoryRelativePath.toString(), repository.getLocation(), tag, false);
+ this.repository = repository;
}
// Get the file revisions for the given filenames
@@ -246,7 +264,7 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
result.add(new RemoteFile(this, (String)newRemoteFiles.get(i), tag));
}
for (int i=0;i<newRemoteDirectories.size();i++)
- result.add(new RemoteFolder(this, getRepository(), repositoryRelativePath.append((String)newRemoteDirectories.get(i)), tag));
+ result.add(new RemoteFolder(this, getRepository(), new Path(getRepositoryRelativePath()).append((String)newRemoteDirectories.get(i)), tag));
children = (ICVSRemoteResource[])result.toArray(new ICVSRemoteResource[0]);
// Get the revision numbers for the files
@@ -333,19 +351,31 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
}
- public String getRemotePath() {
- return repositoryRelativePath.toString();
+ protected String getLocalPath() {
+ throw new UnsupportedOperationException();
+ }
+
+ public String getRepositoryRelativePath() {
+ // The REPOSITORY property of the folder info is the repository relative path
+ return getFolderSyncInfo().getRepository();
}
/**
* @see ICVSResource#getRelativePath(ICVSFolder)
*/
public String getRelativePath(ICVSFolder ancestor) throws CVSException {
+
if (ancestor == this)
return ".";
- // NOTE: This is a quick and dirty way.
- return this.getRemotePath().substring(((RemoteFolder)ancestor).getRemotePath().length() + 1);
- // throw new CVSException(Policy.bind("RemoteFolder.invalidOperation"));
+
+ RemoteResource rootFolder;
+ try {
+ rootFolder = (RemoteResource)ancestor;
+ } catch (ClassCastException e) {
+ throw new CVSException(0,0,"two different implementations of ICVSResource used",e);
+ }
+
+ return Util.getRelativePath(rootFolder.getLocalPath(), getLocalPath());
}
public ICVSRepositoryLocation getRepository() {
@@ -360,18 +390,6 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
}
/**
- * Return true if the exception from the cvs server is the no tag error, and false
- * otherwise.
- */
- public static boolean isNoTagException(List errors) {
- if (errors.size() != 1)
- return false;
- if (((IStatus)errors.get(0)).getMessage().startsWith("cvs [server aborted]: no such tag"))
- return true;
- return false;
- }
-
- /**
* @see ICVSFolder#childExists(String)
*/
public boolean childExists(String path) {
@@ -429,15 +447,15 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
/**
* @see ICVSFolder#getFolderInfo()
*/
- public FolderSyncInfo getFolderSyncInfo() throws CVSException {
- return new FolderSyncInfo(getRemotePath(), getRepository().getLocation(), getTag(), false);
+ public FolderSyncInfo getFolderSyncInfo() {
+ return folderInfo;
}
/**
* @see ICVSResource#getRemoteLocation(ICVSFolder)
*/
public String getRemoteLocation(ICVSFolder stopSearching) throws CVSException {
- return getRepository().getRootDirectory() + Session.SERVER_SEPARATOR + getRemotePath();
+ return folderInfo.getRemoteLocation();
}
/**
@@ -492,19 +510,22 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
* @see ICVSRemoteFolder#setTag(String)
*/
public void setTag(CVSTag tag) {
- this.tag = tag;
+ this.folderInfo = new FolderSyncInfo(folderInfo.getRepository(), folderInfo.getRoot(), tag, folderInfo.getIsStatic());
}
/*
* @see ICVSRemoteFolder#getTag()
*/
public CVSTag getTag() {
- return tag;
+ return folderInfo.getTag();
}
/*
* @see ICVSFolder#setFolderInfo(FolderSyncInfo)
*/
public void setFolderSyncInfo(FolderSyncInfo folderInfo) throws CVSException {
+ this.folderInfo = folderInfo;
+ // XXX temporary to see if this ever occurs
+ throw new CVSException(Policy.bind("RemoteResource.invalidOperation"));
}
/**
@@ -565,10 +586,4 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC
children = oldChildren;
}
}
- /*
- * @see ICVSRemoteFolder#getRelativePath()
- */
- public String getRelativePath() {
- return getRemotePath();
- }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
index 5b0fbeb13..21a451009 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTree.java
@@ -12,6 +12,7 @@ import org.eclipse.team.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.ccvs.core.ICVSRepositoryLocation;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* Whereas the RemoteFolder class provides access to a remote hierarchy using
@@ -51,5 +52,11 @@ public class RemoteFolderTree extends RemoteFolder {
((ICVSResource)children[i]).accept(visitor);
}
}
+
+ protected String getLocalPath() {
+ if (parent == null)
+ return "";
+ return Util.appendPath(parent.getLocalPath(), getName());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
index 85192e071..69e93c2c2 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteResource.java
@@ -5,8 +5,6 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
-import java.io.PrintStream;
-
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.PlatformObject;
import org.eclipse.team.ccvs.core.ICVSRemoteResource;
@@ -15,7 +13,7 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.team.internal.ccvs.core.util.NullOutputStream;
+import org.eclipse.team.internal.ccvs.core.util.Util;
/**
* The purpose of this class and its subclasses is to implement the corresponding
@@ -35,6 +33,9 @@ public abstract class RemoteResource extends PlatformObject implements ICVSRemot
return info.getName();
}
+ protected String getLocalPath() {
+ return Util.appendPath(parent.getLocalPath(), getName());
+ }
/*
* @see ICVSRemoteResource#getParent()
*/
@@ -42,7 +43,7 @@ public abstract class RemoteResource extends PlatformObject implements ICVSRemot
return parent;
}
- public abstract String getRemotePath();
+ public abstract String getRepositoryRelativePath();
public abstract ICVSRepositoryLocation getRepository();
@@ -118,6 +119,6 @@ public abstract class RemoteResource extends PlatformObject implements ICVSRemot
if (!(target instanceof RemoteResource))
return false;
RemoteResource remote = (RemoteResource) target;
- return remote.isContainer() == isContainer() && remote.getRelativePath().equals(getRelativePath());
+ return remote.isContainer() == isContainer() && remote.getRepositoryRelativePath().equals(getRepositoryRelativePath());
}
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
index ea4aa6ec2..84df4ed8b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/RemoteFolderTreeBuilder.java
@@ -36,7 +36,6 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFile;
import org.eclipse.team.internal.ccvs.core.resources.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
-import org.eclipse.team.internal.ccvs.core.resources.RemoteFolder;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFolderTree;
import org.eclipse.team.internal.ccvs.core.resources.RemoteResource;
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
@@ -59,6 +58,7 @@ public class RemoteFolderTreeBuilder {
private Map fileDeltas;
private List changedFiles;
+ private Map remoteFolderTable;
private ICVSFolder root;
private RemoteFolderTree remoteRoot;
@@ -83,6 +83,7 @@ public class RemoteFolderTreeBuilder {
this.tag = tag;
this.fileDeltas = new HashMap();
this.changedFiles = new ArrayList();
+ this.remoteFolderTable = new HashMap();
// Build the local options
List localOptions = new ArrayList();
@@ -141,7 +142,7 @@ public class RemoteFolderTreeBuilder {
try {
buildRemoteTree(session, root, remoteRoot, Path.EMPTY, monitor);
if (!changedFiles.isEmpty())
- fetchFileRevisions(session, remoteRoot, (String[])changedFiles.toArray(new String[changedFiles.size()]), monitor);
+ fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), monitor);
return remoteRoot;
} finally {
session.close();
@@ -201,6 +202,9 @@ public class RemoteFolderTreeBuilder {
*/
private void buildRemoteTree(Session session, ICVSFolder local, RemoteFolderTree remote, IPath localPath, IProgressMonitor monitor) throws CVSException {
+ // Add the remote folder to the remote folder lookup table (used to update file revisions)
+ remoteFolderTable.put(remote.getFolderSyncInfo().getRemoteLocation(), remote);
+
// Create a map to contain the created children
Map children = new HashMap();
@@ -257,7 +261,7 @@ public class RemoteFolderTreeBuilder {
if (revision == FOLDER) {
// XXX should getRemotePath() return an IPath instead of a String?
children.put(name, new RemoteFolderTree(remote, repository,
- new Path(remote.getRemotePath()).append(name),
+ new Path(remote.getRepositoryRelativePath()).append(name),
tagForRemoteFolder(remote, tag)));
} else if (revision == ADDED) {
children.put(name, new RemoteFile(remote, name, tagForRemoteFolder(remote, tag)));
@@ -408,7 +412,7 @@ public class RemoteFolderTreeBuilder {
};
// NOTE: Should use the path relative to the remoteRoot
- IPath path = new Path(newFolder.getRemotePath());
+ IPath path = new Path(newFolder.getRepositoryRelativePath());
IStatus status = Command.UPDATE.execute(session,
new GlobalOption[] { Command.DO_NOT_CHANGE },
updateLocalOptions,
@@ -437,7 +441,7 @@ public class RemoteFolderTreeBuilder {
}
// Get the file revisions for the given filenames
- private void fetchFileRevisions(Session session, final RemoteFolder root, String[] fileNames, IProgressMonitor monitor) throws CVSException {
+ private void fetchFileRevisions(Session session, String[] fileNames, IProgressMonitor monitor) throws CVSException {
// Create a listener for receiving the revision info
final int[] count = new int[] {0};
@@ -445,7 +449,7 @@ public class RemoteFolderTreeBuilder {
IStatusListener listener = new IStatusListener() {
public void fileStatus(IPath path, String remoteRevision) {
try {
- updateRevision(root, path, remoteRevision);
+ updateRevision(path, remoteRevision);
count[0]++;
} catch (CVSException e) {
// The count will be off which will trigger another exception
@@ -493,8 +497,9 @@ public class RemoteFolderTreeBuilder {
deltas.put(path.lastSegment(), revision);
}
- private void updateRevision(RemoteFolder root, IPath path, String revision) throws CVSException {
- ((RemoteFile)root.getFile(path.toString())).setRevision(revision);
+ private void updateRevision(IPath path, String revision) throws CVSException {
+ RemoteFolderTree folder = (RemoteFolderTree)remoteFolderTable.get(path.removeLastSegments(1).toString());
+ ((RemoteFile)folder.getFile(path.lastSegment())).setRevision(revision);
}
/*
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
index 808e0d741..310229b3b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/util/Util.java
@@ -5,14 +5,11 @@ package org.eclipse.team.internal.ccvs.core.util;
* All Rights Reserved.
*/
-import org.eclipse.team.internal.ccvs.core.util.Assert;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSException;
+import org.eclipse.team.internal.ccvs.core.client.Session;
/**
* Unsorted static helper-methods
@@ -264,7 +261,22 @@ public class Util {
// Get rid of the seperator, that would be in the
// beginning, if we did not go from +1
- return resourceName.substring(rootName.length() + 1);
+ return resourceName.substring(rootName.length() + 1).replace('\\', '/');
+ }
+
+ /**
+ * Append the prefix and suffix to form a valid CVS path.
+ */
+ public static String appendPath(String prefix, String suffix) {
+ if (prefix.endsWith(Session.SERVER_SEPARATOR)) {
+ if (suffix.startsWith(Session.SERVER_SEPARATOR))
+ return prefix + suffix.substring(1);
+ else
+ return prefix + suffix;
+ } else if (suffix.startsWith(Session.SERVER_SEPARATOR))
+ return prefix + suffix;
+ else
+ return prefix + Session.SERVER_SEPARATOR + suffix;
}
/*
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
index 9f091e362..e4ec1730e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
@@ -315,7 +315,7 @@ public class CVSCompareEditorInput extends CompareEditorInput {
ResourceSyncInfo leftInfo = ((ICVSResource)leftEdition).getSyncInfo();
ResourceSyncInfo rightInfo = ((ICVSResource)rightEdition).getSyncInfo();
- if (leftEdition.getRelativePath().equals(rightEdition.getRelativePath()) &&
+ if (leftEdition.getRepositoryRelativePath().equals(rightEdition.getRepositoryRelativePath()) &&
leftInfo.getRevision().equals(rightInfo.getRevision())) {
return NODE_EQUAL;
} else {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
index 1cc6133c7..1c050d91d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSPropertiesPage.java
@@ -185,7 +185,7 @@ public class CVSPropertiesPage extends PropertyPage {
portLabel.setText("" + port);
}
pathLabel.setText(location.getRootDirectory());
- moduleLabel.setText(resource.getRelativePath());
+ moduleLabel.setText(resource.getRepositoryRelativePath());
} catch (TeamException e) {
handle(e);
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
index 6c0cae39d..d39580264 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/model/RemoteModule.java
@@ -62,7 +62,7 @@ public class RemoteModule extends CVSModelElement implements IAdaptable {
CVSTag[] tags = CVSUIPlugin.getPlugin().getRepositoryManager().getKnownVersionTags(folder, new NullProgressMonitor());
Object[] versions = new Object[tags.length];
for (int i = 0; i < versions.length; i++) {
- versions[i] = folder.getRepository().getRemoteFolder(folder.getRelativePath(), tags[i]);
+ versions[i] = folder.getRepository().getRemoteFolder(folder.getRepositoryRelativePath(), tags[i]);
}
result[0] = versions;
} catch (TeamException e) {
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
index 2e1878b61..ee3e3c1ab 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/EclipseTest.java
@@ -160,6 +160,10 @@ public class EclipseTest extends EclipseWorkspaceTest {
getProvider(project).update(new IResource[] {project}, IResource.DEPTH_INFINITE, tag, ignoreLocalChanges, DEFAULT_MONITOR);
}
+ public void commitProject(IProject project) throws TeamException {
+ getProvider(project).checkin(new IResource[] {project}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
+ }
+
/**
* Commit the resources from an existing container to the CVS repository
*/
@@ -215,6 +219,15 @@ public class EclipseTest extends EclipseWorkspaceTest {
return copy;
}
+
+ protected IProject checkoutProject(IProject project, String moduleName, CVSTag tag) throws TeamException {
+ if (project == null)
+ project = getWorkspace().getRoot().getProject(moduleName);
+ if (moduleName == null)
+ moduleName = project.getName();
+ CVSProviderPlugin.getProvider().checkout(getRepository(), project, moduleName, tag, DEFAULT_MONITOR);
+ return project;
+ }
/*
* This method creates a project with the given resources, imports
* it to CVS and checks it out
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
index e8036e658..326af5b29 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/compatible/ConflictTest.java
@@ -3,7 +3,6 @@ package org.eclipse.team.tests.ccvs.core.compatible;
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
-import junit.awtui.TestRunner;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.team.internal.ccvs.core.CVSException;
@@ -14,6 +13,10 @@ public class ConflictTest extends JUnitTestCase {
SameResultEnv env1;
SameResultEnv env2;
+ public ConflictTest() {
+ this(null);
+ }
+
public ConflictTest(String arg) {
super(arg);
env1 = new SameResultEnv(arg, getFile("checkout1"));
diff --git a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
index e832f6f54..5c04e1a87 100644
--- a/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
+++ b/tests/org.eclipse.team.tests.cvs.core/src/org/eclipse/team/tests/ccvs/core/provider/CVSProviderTest.java
@@ -39,7 +39,7 @@ public class CVSProviderTest extends EclipseTest {
public static Test suite() {
TestSuite suite = new TestSuite(CVSProviderTest.class);
return new CVSTestSetup(suite);
- //return new CVSTestSetup(new CVSProviderTest("testVersionTag"));
+ //return new CVSTestSetup(new CVSProviderTest("testGet"));
}
public void testAddAndDelete() throws TeamException, CoreException {
@@ -145,6 +145,22 @@ public class CVSProviderTest extends EclipseTest {
CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(true);
}
+ public void testGet() throws TeamException, CoreException, IOException {
+
+ // Create a project
+ IProject project = createProject("testGet", new String[] { "changed.txt", "deleted.txt", "folder1/", "folder1/a.txt" });
+
+ // Checkout a copy and modify locally
+ IProject copy = checkoutCopy(project, "-copy");
+ addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, false);
+ deleteResources(copy, new String[] {"deleted.txt"}, false);
+ IFile file = copy.getFile("changed.txt");
+ file.setContents(getRandomContents(), false, false, null);
+
+ // get the remote conetns
+ getProvider(copy).get(new IResource[] {copy}, IResource.DEPTH_INFINITE, DEFAULT_MONITOR);
+ assertEquals("Get failed to retrieve proper contents", project, copy);
+ }
}

Back to the top