Skip to main content
summaryrefslogtreecommitdiffstats
blob: 6d94c0b2c035cbc7cbb5a816aa2528c963a60f53 (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
package org.eclipse.team.internal.ccvs.core.client;
/*
 * (c) Copyright IBM Corp. 2000, 2002.
 * All Rights Reserved.
 */
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
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.syncinfo.*;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;

/**
 * The diff command needs to send a file structure to the server that differs somewhat from the canonical
 * format sent by other commands. Instead of sending new files as questionables this class sends
 * new files as modified and fakes them being added. The contents are sent to the server and are 
 * included in the returned diff report.
 */
class DiffStructureVisitor extends FileStructureVisitor {
	public DiffStructureVisitor(Session session, boolean modifiedOnly, boolean emptyFolders,
		IProgressMonitor monitor) {
		super(session, modifiedOnly, emptyFolders, monitor);
	}
	
	/**
	 * Send unmanaged files as modified with a default entry line.
	 */
	protected void sendFile(ICVSFile mFile, boolean sendQuestionable, String mode) throws CVSException {
		boolean binary = mode != null && mode.indexOf(ResourceSyncInfo.BINARY_TAG) != -1;
		boolean newFile = false;

		if (mFile.isManaged()) {
			session.sendEntry(mFile.getSyncInfo().getEntryLine(false));
		} else {
			ResourceSyncInfo info = new ResourceSyncInfo(mFile.getName(), ResourceSyncInfo.ADDED_REVISION, null, null, null, null);
			session.sendEntry(info.getEntryLine(false));
			newFile = true;
		}

		if (!mFile.exists()) {
			return;
		}

		if (mFile.isModified() || newFile) {
			session.sendModified(mFile, binary, monitor);
		} else {
			session.sendUnchanged(mFile);
		}
	}			
}

Back to the top