diff options
10 files changed, 228 insertions, 177 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java index 161aee9c1..eb71760b5 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RTag.java @@ -1,10 +1,15 @@ +/******************************************************************************* + * Copyright (c) 2000, 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ package org.eclipse.team.internal.ccvs.core.client; -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ - import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -19,7 +24,7 @@ import org.eclipse.team.internal.ccvs.core.Policy; import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption; import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; -public class RTag extends Command { +public class RTag extends RemoteCommand { /*** Local options: specific to tag ***/ public static final LocalOption CREATE_BRANCH = Tag.CREATE_BRANCH; @@ -42,7 +47,6 @@ public class RTag extends Command { } } - protected RTag() { } protected String getRequestId() { return "rtag"; //$NON-NLS-1$ } @@ -50,17 +54,7 @@ public class RTag extends Command { protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, String[] arguments) throws CVSException { if (arguments.length < 2) throw new IllegalArgumentException(); - return new ICVSResource[0]; - } - - protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions, - LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) - throws CVSException { - // do nothing - } - - protected void sendLocalWorkingDirectory(Session session) throws CVSException { - // do nothing + return super.computeWorkResources(session, localOptions, arguments); } public IStatus execute(Session session, GlobalOption[] globalOptions, diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java new file mode 100644 index 000000000..2460bcf4e --- /dev/null +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/RemoteCommand.java @@ -0,0 +1,39 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ +package org.eclipse.team.internal.ccvs.core.client; + +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.team.internal.ccvs.core.CVSException; +import org.eclipse.team.internal.ccvs.core.ICVSResource; +import org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption; +import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption; + +/** + * This class acts as a super class for those CVS commands that do not send up the local file structure + */ +public abstract class RemoteCommand extends Command { + + protected ICVSResource[] computeWorkResources(Session session, LocalOption[] localOptions, + String[] arguments) throws CVSException { + return new ICVSResource[0]; + } + + protected void sendLocalResourceState(Session session, GlobalOption[] globalOptions, + LocalOption[] localOptions, ICVSResource[] resources, IProgressMonitor monitor) + throws CVSException { + // do nothing + } + + protected void sendLocalWorkingDirectory(Session session) throws CVSException { + // do nothing + } + +} diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java index 127f3ca5b..ded3e384d 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Session.java @@ -1,9 +1,14 @@ +/******************************************************************************* + * Copyright (c) 2000, 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial API and implementation + ******************************************************************************/ package org.eclipse.team.internal.ccvs.core.client; - -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -897,6 +902,7 @@ public class Session { in = new ProgressMonitorInputStream(in, size, TRANSFER_PROGRESS_INCREMENT, monitor) { protected void updateMonitor(long bytesRead, long bytesTotal, IProgressMonitor monitor) { if (bytesRead == 0) return; + Assert.isTrue(bytesRead <= bytesTotal); monitor.subTask(Policy.bind("Session.transfer", //$NON-NLS-1$ new Object[] { title, Long.toString(bytesRead >> 10), Long.toString(bytesTotal >> 10) })); } diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java index 4064aefc4..af1ca8917 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Version.java @@ -29,7 +29,7 @@ import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation; * Concurrent Versions System (CVS) NT 1.11.1.1 (Build 27) * Concurrent Versions System (CVSNT) 1.11.1.3 (Build 57a) (client/server) */ -public class Version extends AbstractMessageCommand { +public class Version extends RemoteCommand { private static final String CVS_NT_PREFIX_1 = "Concurrent Versions System (CVS) NT "; //$NON-NLS-1$ private static final String CVS_NT_PREFIX_2 = "Concurrent Versions System (CVSNT) "; //$NON-NLS-1$ 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 f108168c1..5730407a5 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 @@ -109,8 +109,8 @@ public class CVSWorkspaceRoot { remote = getRemoteTreeFromParent(resource, managed, tag, progress); } else if(resource.getType() == IResource.FILE) { baseTree = remote; - ICVSRemoteResource remoteParent = CVSWorkspaceRoot.getRemoteResourceFor(resource.getParent()); - remote = RemoteFile.getLatest((RemoteFolder)remoteParent, (ICVSFile)managed, tag, progress); + ICVSRepositoryLocation location = remote.getRepository(); + remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress); } else { ICVSRepositoryLocation location = remote.getRepository(); baseTree = RemoteFolderTreeBuilder.buildBaseTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); @@ -125,8 +125,8 @@ public class CVSWorkspaceRoot { if (remote == null) { remote = getRemoteTreeFromParent(resource, managed, tag, progress); } else if(resource.getType() == IResource.FILE) { - ICVSRemoteResource remoteParent = CVSWorkspaceRoot.getRemoteResourceFor(resource.getParent()); - remote = RemoteFile.getLatest((RemoteFolder)remoteParent, (ICVSFile)managed, tag, progress); + ICVSRepositoryLocation location = remote.getRepository(); + remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFile)managed, tag, progress); } else { ICVSRepositoryLocation location = remote.getRepository(); remote = RemoteFolderTreeBuilder.buildRemoteTree((CVSRepositoryLocation)location, (ICVSFolder)managed, tag, progress); 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 520b4b63a..2da15c4c8 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 @@ -53,6 +53,7 @@ import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener; import org.eclipse.team.internal.ccvs.core.connection.CVSServerException; import org.eclipse.team.internal.ccvs.core.syncinfo.MutableResourceSyncInfo; import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; +import org.eclipse.team.internal.ccvs.core.util.Util; /** * This class provides the implementation of ICVSRemoteFile and IManagedFile for @@ -60,10 +61,10 @@ import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo; */ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { - // Contents will be cahced to disk when this thrshold is exceeded + // Contents will be cached to disk when this thrshold is exceeded private static final int CACHING_THRESHOLD = 32768; - // cache for file contents received from the server + // buffer for file contents received from the server private byte[] contents; // cach the log entry for the remote file private ILogEntry entry; @@ -86,71 +87,6 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { parent.setChildren(new ICVSRemoteResource[] {file}); return file; } - - /** - * Static method which creates a file as a single child of its parent. - * This should only be used when one is only interested in the file alone. - * - * The returned RemoteFile represents the latest remote revision corresponding to the local resource. - * If the local resource does not have a base, then null is returned - * even if the resource does exists remotely (e.g. created by another party). - */ - public static RemoteFile getLatest(RemoteFolder parent, ICVSFile managed, CVSTag tag, IProgressMonitor monitor) throws CVSException { - ResourceSyncInfo info = managed.getSyncInfo(); - if ((info == null) || info.isAdded()) { - // Either the file is unmanaged or has just been added (i.e. doesn't necessarily have a remote) - return null; - } - - // ensure that the entry line has the tag in it. Or else status will return - // the latest from the branch of the local resource. - if(tag!=null) { - MutableResourceSyncInfo newInfo = info.cloneMutable(); - newInfo.setTag(tag); - info = newInfo; - } - - // initialize with new sync info from the local resource, this info will - // be updated when updateRevision is called. - RemoteFile file = new RemoteFile(parent, info); - - // use the contents of the file on disk so that the server can calculate the relative - // sync state. This is a trick to allow the server to calculate sync state for us. - InputStream is = managed.getContents(); - file.setContents(is, ICVSFile.UPDATED, false, Policy.monitorFor(null)); - - parent.setChildren(new ICVSRemoteResource[] {file}); - if( ! file.updateRevision(tag, monitor)) { - // If updateRevision returns false then the resource no longer exists remotely - return null; - } - - // forget local contents. Remote contents will be fetched the next time - // the returned handle is used. - file.clearContents(); - - // If the revision changed, clear the contents of the original revision in case contents where cached - if ( ! info.getRevision().equals(file.getRevision())) { - RemoteFile originalRevision = new RemoteFile(parent, info); - originalRevision.clearContents(); - } - return file; - } - - /** - * Forget the contents associated with this remote handle. - */ - public void clearContents() { - contents = null; - try { - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - ioFile.delete(); - } - } catch (IOException e) { - CVSProviderPlugin.log(CVSException.wrapException(e).getStatus()); - } - } /** * Constructor for RemoteFile that should be used when nothing is know about the @@ -194,28 +130,15 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { public InputStream getContents(IProgressMonitor monitor) throws CVSException { if (contents == null) { // First, check to see if there's a cached contents for the file - try { - try { - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - return new BufferedInputStream(new FileInputStream(ioFile)); - } - } catch (IOException e) { - // Try to purge the cache and continue - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - ioFile.delete(); - } - } - } catch (IOException e) { - // We will end up here if we couldn't read or delete the cache file - throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$ + InputStream cached = getCachedContents(); + if (cached != null) { + return cached; } + // We need to fetch the contents from the server monitor.beginTask(Policy.bind("RemoteFile.getContents"), 100);//$NON-NLS-1$ Session.run(getRepository(), parent, false, new ICVSRunnable() { public void run(IProgressMonitor monitor) throws CVSException { - monitor.beginTask(null, 100); IStatus status = Command.UPDATE.execute( Command.NO_GLOBAL_OPTIONS, new LocalOption[] { @@ -223,16 +146,7 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { Update.IGNORE_LOCAL_CHANGES }, new ICVSResource[] { RemoteFile.this }, null, - Policy.subMonitorFor(monitor, 90)); - if (status.getCode() != CVSStatus.SERVER_ERROR) { - try { - getLogEntry(Policy.subMonitorFor(monitor, 10)); - } catch (CVSException e) { - // Ignore the status of the log entry fetch. - // If it fails, the entry will still be null - } - } - monitor.done(); + monitor); if (status.getCode() == CVSStatus.SERVER_ERROR) { throw new CVSServerException(status); } @@ -243,16 +157,11 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { // than we can assume that the remote file has no contents. if (contents == null) { // The above is true unless there is a cache file - try { - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - return new BufferedInputStream(new FileInputStream(ioFile)); - } else { - contents = new byte[0]; - } - } catch (IOException e) { - // Something is wrong with the cached file so signal an error. - throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$ + cached = getCachedContents(); + if (cached != null) { + return cached; + } else { + contents = new byte[0]; } } } @@ -339,30 +248,34 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { return file; } - /** - * @see IManagedFile#getSize() + /** + * @see ICVSFile#getSize() */ public long getSize() { + if (contents == null) { + try { + File ioFile = getCacheFile(); + if (ioFile.exists()) { + return ioFile.length(); + } + } catch (IOException e) { + // Try to purge the cache and continue + try { + clearCachedContents(); + } catch (IOException e2) { + } + CVSProviderPlugin.log(CVSException.wrapException(e).getStatus()); + } + } return contents == null ? 0 : contents.length; } /** - * @see IManagedFile#getFileInfo() + * @see ICVSFile#getSyncInfo() */ public ResourceSyncInfo getSyncInfo() { return info; } - - /** - * @see ICVSResource#getRelativePath(ICVSFolder) - */ - public String getRelativePath(ICVSFolder ancestor) throws CVSException { - String result = parent.getRelativePath(ancestor); - if (result.length() == 0) - return getName(); - else - return result + Session.SERVER_SEPARATOR + getName(); - } /** * @see ICVSResource#getRemoteLocation(ICVSFolder) @@ -407,13 +320,9 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { public InputStream getContents() throws CVSException { if (contents == null) { // Check for cached contents for the file - try { - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - return new BufferedInputStream(new FileInputStream(ioFile)); - } - } catch (IOException e) { - throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$ + InputStream cached = getCachedContents(); + if (cached != null) { + return cached; } } return new ByteArrayInputStream(contents == null ? new byte[0] : contents); @@ -434,16 +343,9 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { // Detect when the file is getting too big to keep in memory // and switch to a caching strategy for the contents of the file if (out == byteStream && byteStream.size() > CACHING_THRESHOLD) { - // Get the cache file to write to - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if ( ! ioFile.getParentFile().exists()) { - ioFile.getParentFile().mkdirs(); - } // Switch streams byteStream.close(); - out = new BufferedOutputStream(new FileOutputStream(ioFile)); - // Write what we've read so far - out.write(byteStream.toByteArray()); + out = switchToCacheOutputStream(byteStream); // Continue looping until the whole file is read } } @@ -453,17 +355,16 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { } catch (IOException e) { // Make sure we don't leave the cache file around as it may not have the right contents if (byteStream != out) { - File ioFile = CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); - if (ioFile.exists()) { - ioFile.delete(); - } + clearCachedContents(); } throw e; } - // Set the contents if we didn't cahce them + // Set the contents if we didn't cache them to disk if (out == byteStream) { contents = byteStream.toByteArray(); + } else { + contents = null; } } finally { stream.close(); @@ -565,4 +466,51 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile { path = path.append(getName() + ' ' + getRevision()); return path.toString(); } + + private File getCacheFile() throws IOException { + return CVSProviderPlugin.getPlugin().getCacheFileFor(getCacheRelativePath()); + } + + private void clearCachedContents() throws IOException { + try { + File ioFile = getCacheFile(); + if (ioFile.exists()) { + ioFile.delete(); + } + } catch (IOException e) { + CVSProviderPlugin.log(CVSException.wrapException(e).getStatus()); + } + } + + private InputStream getCachedContents() throws CVSException { + try { + try { + File ioFile = getCacheFile(); + if (ioFile.exists()) { + return new BufferedInputStream(new FileInputStream(ioFile)); + } + } catch (IOException e) { + // Try to purge the cache and continue + clearCachedContents(); + throw e; + } + } catch (IOException e) { + // We will end up here if we couldn't read or delete the cache file + throw new CVSException(new CVSStatus(IStatus.ERROR, 0, Policy.bind("RemoteFile.errorRetrievingFromCache", e.getMessage()), e));//$NON-NLS-1$ + } + return null; + } + + private OutputStream switchToCacheOutputStream(ByteArrayOutputStream byteStream) throws IOException { + // Get the cache file and make sure it's parent exists + File ioFile = getCacheFile(); + if ( ! ioFile.getParentFile().exists()) { + ioFile.getParentFile().mkdirs(); + } + // Switch streams + OutputStream out = new BufferedOutputStream(new FileOutputStream(ioFile)); + // Write what we've read so far + out.write(byteStream.toByteArray()); + return out; + } }
\ No newline at end of file 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 ebae8e5ec..865b45b11 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 @@ -459,13 +459,7 @@ public class RemoteFolder extends RemoteResource implements ICVSRemoteFolder, IC if (parent == null) { throw new CVSException(Policy.bind("RemoteFolder.invalidChild", getName(), ancestor.getName())); //$NON-NLS-1$ } - // Append the receivers name to the parents path relative to the ancestor - String parentPath = parent.getRelativePath(ancestor); - if (parentPath.equals(Session.CURRENT_LOCAL_FOLDER) || parentPath.length() == 0) { - return getName(); - } else { - return Util.appendPath(parentPath, getName()); - } + return super.getRelativePath(ancestor); } public ICVSRepositoryLocation getRepository() { diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java index cf380bb36..2ff1dc2f0 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFolderTreeBuilder.java @@ -154,6 +154,11 @@ public class RemoteFolderTreeBuilder { return builder.buildTree(monitor); } + public static RemoteFile buildRemoteTree(CVSRepositoryLocation repository, ICVSFile file, CVSTag tag, IProgressMonitor monitor) throws CVSException { + RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, file.getParent(), tag); + return builder.buildTree(file, monitor); + } + private RemoteFolderTree buildTree(IProgressMonitor monitor) throws CVSException { // Make sure that the cvs commands are not quiet during this operations @@ -168,7 +173,7 @@ public class RemoteFolderTreeBuilder { session.open(Policy.subMonitorFor(monitor, 10)); try { Policy.checkCanceled(monitor); - fetchDelta(session, Policy.subMonitorFor(monitor, 50)); + fetchDelta(session, Session.CURRENT_LOCAL_FOLDER, Policy.subMonitorFor(monitor, 50)); if (projectDoesNotExist) { return null; } @@ -227,6 +232,62 @@ public class RemoteFolderTreeBuilder { } } + private RemoteFile buildTree(ICVSFile file, IProgressMonitor monitor) throws CVSException { + QuietOption quietness = CVSProviderPlugin.getPlugin().getQuietness(); + try { + CVSProviderPlugin.getPlugin().setQuietness(Command.VERBOSE); + + monitor.beginTask(null, 100); + + // Query the server to see if there is a delta available + Policy.checkCanceled(monitor); + Session session = new Session(repository, root, false); + session.open(Policy.subMonitorFor(monitor, 10)); + try { + Policy.checkCanceled(monitor); + fetchDelta(session, file.getName(), Policy.subMonitorFor(monitor, 50)); + if (projectDoesNotExist) { + return null; + } + } finally { + session.close(); + } + // Create a parent for the remote resource + remoteRoot = + new RemoteFolderTree(null, root.getName(), repository, + new Path(root.getFolderSyncInfo().getRepository()), + tagForRemoteFolder(root, tag)); + // Create the remote resource (using the delta if there is one) + RemoteFile remoteFile; + Map deltas = (Map)fileDeltas.get(Path.EMPTY); + if (deltas == null || deltas.isEmpty()) { + remoteFile = new RemoteFile(remoteRoot, file.getSyncInfo()); + } else { + DeltaNode d = (DeltaNode)deltas.get(file.getName()); + remoteFile = new RemoteFile(remoteRoot, d.getSyncState(), file.getName(), tagForRemoteFolder(remoteRoot, tag)); + } + // Add the resource to its parent + remoteRoot.setChildren(new ICVSRemoteResource[] {remoteFile}); + // If there was a delta, ftech the new revision + if (!changedFiles.isEmpty()) { + // Add the remote folder to the remote folder lookup table (used to update file revisions) + remoteFolderTable.put(new Path(remoteRoot.getFolderSyncInfo().getRemoteLocation()), remoteRoot); + session = new Session(repository, remoteRoot, false); + session.open(Policy.subMonitorFor(monitor, 10)); + try { + fetchFileRevisions(session, (String[])changedFiles.toArray(new String[changedFiles.size()]), Policy.subMonitorFor(monitor, 20)); + } finally { + session.close(); + } + } + return remoteFile; + + } finally { + CVSProviderPlugin.getPlugin().setQuietness(quietness); + monitor.done(); + } + } + /* * Build the base remote tree from the local tree. * @@ -426,7 +487,7 @@ public class RemoteFolderTreeBuilder { * * Returns the list of changed files */ - private List fetchDelta(Session session, final IProgressMonitor monitor) throws CVSException { + private List fetchDelta(Session session, String argument, final IProgressMonitor monitor) throws CVSException { // Create an listener that will accumulate new and removed files and folders final List newChildDirectories = new ArrayList(); @@ -486,7 +547,7 @@ public class RemoteFolderTreeBuilder { IStatus status = Command.UPDATE.execute(session, new GlobalOption[] { Command.DO_NOT_CHANGE }, updateLocalOptions, - new String[] { Session.CURRENT_LOCAL_FOLDER }, + new String[] { argument }, new UpdateListener(listener), monitor); return changedFiles; 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 430e3b10b..fee58046f 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 @@ -42,6 +42,13 @@ public abstract class RemoteResource extends PlatformObject implements ICVSRemot } /* + * @see ICVSResource#getRelativePath(ICVSFolder) + */ + public String getRelativePath(ICVSFolder ancestor) throws CVSException { + return Util.appendPath(parent.getRelativePath(ancestor), getName()); + } + + /* * @see ICVSRemoteResource#getParent() */ public ICVSRemoteResource getRemoteParent() { 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 cd99f83d6..46deb13ea 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 @@ -51,7 +51,9 @@ public class Util { * 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 (prefix.length() == 0 || prefix.equals(Session.CURRENT_LOCAL_FOLDER)) { + return suffix; + } else if (prefix.endsWith(Session.SERVER_SEPARATOR)) { if (suffix.startsWith(Session.SERVER_SEPARATOR)) return prefix + suffix.substring(1); else |