Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java9
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java21
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java44
3 files changed, 61 insertions, 13 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
index a150af4e2..485aed384 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSRemoteFile.java
@@ -22,7 +22,14 @@ import org.eclipse.team.core.TeamException;
public interface ICVSRemoteFile extends ICVSRemoteResource {
/**
- * Get the log entries of the remote file
+ * Get the log entry for the revision the remote file represents.
+ * This method will return null until after the getContents(IProgressMonitor)
+ * method is called (i.e. the call to getContents also fetches the entry.
+ */
+ public ILogEntry getLogEntry();
+
+ /**
+ * Get all the log entries of the remote file
*/
public ILogEntry[] getLogEntries(IProgressMonitor monitor) throws TeamException;
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
index 6684bd208..5ec084d18 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/client/Log.java
@@ -1,13 +1,24 @@
+/*******************************************************************************
+ * 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 org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
public class Log extends AbstractMessageCommand {
/*** Local options: specific to log ***/
-
+
+ public static LocalOption makeRevisionOption(String revision) {
+ return new LocalOption("-r" + revision, null);
+ }
+
protected Log() { }
protected String getRequestId() {
return "log"; //$NON-NLS-1$
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 7fb37fde4..ab8ef53cd 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
@@ -16,6 +16,7 @@ import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.team.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.ccvs.core.CVSStatus;
@@ -34,7 +35,6 @@ import org.eclipse.team.internal.ccvs.core.Policy;
import org.eclipse.team.internal.ccvs.core.client.Command;
import org.eclipse.team.internal.ccvs.core.client.Session;
import org.eclipse.team.internal.ccvs.core.client.Update;
-import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
import org.eclipse.team.internal.ccvs.core.client.Command.QuietOption;
import org.eclipse.team.internal.ccvs.core.client.listeners.LogListener;
@@ -50,6 +50,8 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
// cache for file contents received from the server
private byte[] contents;
+ // cach the log entry for the remote file
+ private ILogEntry entry;
/**
* Static method which creates a file as a single child of its parent.
@@ -153,18 +155,33 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
public InputStream getContents(final IProgressMonitor monitor) {
try {
if (contents == null) {
+ final List entries = new ArrayList();
monitor.beginTask(null, 100);
IStatus status;
Session s = new Session(getRepository(), parent, false);
s.open(Policy.subMonitorFor(monitor, 10));
try {
status = Command.UPDATE.execute(s,
- Command.NO_GLOBAL_OPTIONS,
- new LocalOption[] { Update.makeTagOption(new CVSTag(info.getRevision(), CVSTag.VERSION)),
- Update.IGNORE_LOCAL_CHANGES },
- new String[] { getName() },
- null,
- Policy.subMonitorFor(monitor, 90));
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] {
+ Update.makeTagOption(new CVSTag(info.getRevision(), CVSTag.VERSION)),
+ Update.IGNORE_LOCAL_CHANGES },
+ new String[] { getName() },
+ null,
+ Policy.subMonitorFor(monitor, 80));
+ if (status.getCode() != CVSStatus.SERVER_ERROR) {
+ IStatus logStatus = Command.LOG.execute(s,
+ Command.NO_GLOBAL_OPTIONS,
+ new LocalOption[] {
+ Command.LOG.makeRevisionOption(info.getRevision())},
+ new String[] { getName() },
+ new LogListener(this, entries),
+ Policy.subMonitorFor(monitor, 10));
+ if (logStatus.isMultiStatus()) {
+ ((MultiStatus)logStatus).merge(status);
+ status = logStatus;
+ }
+ }
} finally {
s.close();
monitor.done();
@@ -176,6 +193,12 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
// than we can assume that the remote file has no contents.
if (contents == null)
contents = new byte[0];
+
+ if (entries.size() == 1) {
+ entry = (ILogEntry)entries.get(0);
+ } else {
+ // No log entry was fetch for the remote file.
+ }
}
return new ByteArrayInputStream(contents);
} catch(CVSException e) {
@@ -309,6 +332,13 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile, ICVSFi
}
/*
+ * @see ICVSRemoteFile#getLogEntry()
+ */
+ public ILogEntry getLogEntry() {
+ return entry;
+ }
+
+ /*
* @see ICVSFile#setReadOnly()
*/
public void setContents(InputStream stream, int responseType, boolean keepLocalHistory, IProgressMonitor monitor) throws CVSException {

Back to the top