Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: baf0f04c5cb41aa81da9cb73fa3454ad829162dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/*******************************************************************************
 * Copyright (c) 2000, 2011 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *     Olexiy Buyanskyy <olexiyb@gmail.com> - Bug 76386 - [History View] CVS Resource History shows revisions from all branches
 *******************************************************************************/

package org.eclipse.team.internal.ccvs.core.filehistory;

import org.eclipse.core.filesystem.IFileStore;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.history.*;
import org.eclipse.team.core.history.provider.FileHistoryProvider;
import org.eclipse.team.internal.ccvs.core.*;
import org.eclipse.team.internal.ccvs.core.client.listeners.LogEntry;
import org.eclipse.team.internal.ccvs.core.filesystem.CVSFileStore;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.resources.RemoteFile;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;

public class CVSFileHistoryProvider extends FileHistoryProvider {

	/**
	 * see <code>org.eclipse.team.core.IFileHistoryProvider</code>
	 */
	public IFileHistory getFileHistoryFor(IResource resource, int flags, IProgressMonitor monitor) {
		ICVSRemoteResource remoteResource;
		try {
			monitor.beginTask(null, 100);
			if ((flags == IFileHistoryProvider.SINGLE_REVISION) || ((flags == IFileHistoryProvider.SINGLE_LINE_OF_DESCENT))) {
				remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
				monitor.worked(40);
				CVSFileHistory remoteFile = null;
				if (remoteResource instanceof ICVSFile) {
					remoteFile = new CVSFileHistory((ICVSFile) remoteResource, flags);
					remoteFile.refresh(CVSFileHistory.REFRESH_ALL, monitor);
				}
				return remoteFile;
			} else {
				// TODO need to complete the revision
				remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
				monitor.worked(40);
				CVSFileHistory remoteFile = null;
				if (remoteResource instanceof ICVSFile) {
					remoteFile = new CVSFileHistory((ICVSFile) remoteResource);
					remoteFile.refresh(CVSFileHistory.REFRESH_ALL, monitor);
				}
				return remoteFile;
			}
		} catch (CVSException e) {
		} catch (TeamException e) {
		} finally {
			monitor.done();
		}

		return null;
	}

	public IFileRevision getWorkspaceFileRevision(IResource resource) {
		
		ICVSRemoteResource remoteResource;
		try {
			remoteResource = CVSWorkspaceRoot.getRemoteResourceFor(resource);
			if (remoteResource != null && 
				remoteResource instanceof RemoteFile){
				ResourceSyncInfo syncInfo = remoteResource.getSyncInfo();
				LogEntry cvsEntry = new LogEntry((RemoteFile) remoteResource, syncInfo.getRevision(), "", null,"","", new CVSTag[0], new CVSTag[0]);  //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
				return new CVSFileRevision(cvsEntry);
			}
		} catch (CVSException e) {
		}
		
		return null;
	}

	public IFileHistory getFileHistoryFor(IFileStore store, int flags, IProgressMonitor monitor) {
		if (store instanceof CVSFileStore) {
			
			CVSFileStore fileStore = (CVSFileStore) store;
			ICVSRemoteFile file = fileStore.getCVSURI().toFile();
			if (file != null){
				try{
				if ((flags == IFileHistoryProvider.SINGLE_REVISION) || ((flags == IFileHistoryProvider.SINGLE_LINE_OF_DESCENT))) {
					CVSFileHistory history = new CVSFileHistory(file, flags);
					history.refresh(CVSFileHistory.REFRESH_ALL, monitor);
					return history;
				} else{
					CVSFileHistory history = new CVSFileHistory(file);
					history.refresh(CVSFileHistory.REFRESH_ALL, monitor);
					return history;
				} } catch (TeamException ex){}
			}
		}
		return null;
	}

}

Back to the top