Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 59c21d149c45508b582cc64e8520fe94cbb3556a (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
/*******************************************************************************
 * Copyright (c) 2000, 2006 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
 *******************************************************************************/
package org.eclipse.team.internal.ccvs.core.client;


import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.MutableFolderSyncInfo;

/**
 * Handles any "Set-static-directory" and "Clear-static-directory" responses
 * from the CVS server.
 * <p>
 * Suppose as a result of performing a command the CVS server responds
 * as follows:<br>
 * <pre>
 *   [...]
 *   Set-static-directory myproject/ \n
 *   /u/cvsroot/myproject/ \n
 *   [...]
 * </pre>
 * Then we set or clear the static flag of the folder "myproject",
 * automatically creating it if it does not exist locally,
 * </p>
 */
class StaticHandler extends ResponseHandler {
	private final boolean setStaticDirectory;

	public StaticHandler(boolean setStaticDirectory) {
		this.setStaticDirectory = setStaticDirectory;
	}

	public String getResponseID() {
		if (setStaticDirectory) {
			return "Set-static-directory"; //$NON-NLS-1$
		} else {
			return "Clear-static-directory"; //$NON-NLS-1$
		}
	}

	public void handle(Session session, String localDir,
		IProgressMonitor monitor) throws CVSException {
		// read additional data for the response
		String repositoryDir = session.readLine();

		// create the directory then set or clear the static flag
		Assert.isTrue(repositoryDir.endsWith("/")); //$NON-NLS-1$
		repositoryDir = repositoryDir.substring(0, repositoryDir.length() - 1);
		try {
			ICVSFolder folder = createFolder(session, localDir, repositoryDir);
			FolderSyncInfo syncInfo = folder.getFolderSyncInfo();
			// Added to ignore sync info for workspace root
			if (syncInfo == null) return;
			MutableFolderSyncInfo newInfo = syncInfo.cloneMutable();
			newInfo.setStatic(setStaticDirectory);
			// only set the sync info if it has changed
			if (!syncInfo.equals(newInfo))
				folder.setFolderSyncInfo(newInfo);
		} catch (CVSException e) {
			if (!handleInvalidResourceName(session, session.getLocalRoot().getFolder(localDir), e)) {
				throw e;
			}
		}
	}
}

Back to the top