Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 74853919533d1515643ec360375ebf93708bf41c (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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
/*******************************************************************************
 * 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.syncinfo;

import java.util.Date;

import org.eclipse.core.runtime.Assert;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption;

/**
 * Mutable version of ResourceSyncInfo. Can be used when either creating a resource sync
 * object from scratch (e.g. without an entry line) or want to modify an existing
 * <code>ResourceSyncInfo</code> instance. Example usage:
 * <pre>
 * ResourceSyncInfo info = resource.getSyncInfo();
 * if(info!=null) {
 *   MutableResourceSyncInfo newInfo = info.cloneMutable();
 *   newInfo.setRevision("1.22");
 *   resource.setSyncInfo(newInfo);
 * }
 * </pre>
 * @see ResourceSyncInfo
 */
public class MutableResourceSyncInfo extends ResourceSyncInfo {
	
	protected MutableResourceSyncInfo(ResourceSyncInfo info) {
		this.name = info.getName();
		setRevision(info.getRevision());
		setTag(info.getTag());
		this.timeStamp = info.getTimeStamp();
		this.isDirectory = info.isDirectory();
		this.keywordMode = info.getKeywordMode();
		this.isDeleted = info.isDeleted();
		if(info.isMergedWithConflicts()) {
			setSyncType(TYPE_MERGED_WITH_CONFLICTS);
		} else if(info.isMerged()) {
			setSyncType(TYPE_MERGED);
		} else {
			setSyncType(TYPE_REGULAR);
		}
	}
	
	/**
	 * Creates a default sync info, if revision is <code>null</code> then
	 * the sync info will be considered in the newly added state.
	 */ 
	public MutableResourceSyncInfo(String name, String revision) {
		Assert.isNotNull(name);
		this.name = name;
		setRevision(revision);
	}
	
	/**
	 * Sets the revision.
	 * @param revision The revision to set
	 */
	public void setRevision(String revision) {
		super.setRevision(revision);
	}
	
	/**
	 * Sets the timeStamp.
	 * @param timeStamp The timeStamp to set
	 */
	public void setTimeStamp(Date timeStamp) {
		this.timeStamp = timeStamp;
	}
	
	/**
	 * Sets the timeStamp.
	 * @param timeStamp The timeStamp to set
	 */
	public void setTimeStamp(Date timeStamp, boolean clearMerged) {
		setTimeStamp(timeStamp);
		if (clearMerged) setSyncType(TYPE_REGULAR);
	}
	
	/**
	 * Sets the keywordMode.
	 * @param keywordMode The keywordMode to set
	 */
	public void setKeywordMode(KSubstOption keywordMode) {
		this.keywordMode = keywordMode;
	}

	/**
	 * Sets the tag.
	 * @param tag The tag to set
	 */
	public void setTag(CVSTag tag) {
		super.setTag(tag);
	}
	
	/**
	 * Sets the deleted state.
	 * @param isDeleted The deleted state of this resource sync
	 */
	public void setDeleted(boolean isDeleted) {
		this.isDeleted = isDeleted;;
	}
	
	/**
	 * Sets to the added state. The timestamp and other are cleared.
	 */
	public void setAdded() {
		setRevision(ADDED_REVISION);
	}
	
	/**
	 * Sets that this resource sync is a result of a non-conflicting merge
	 */
	public void setMerged() {
		// if already merged state then ignore
		if(syncType==TYPE_REGULAR) {			
			this.syncType = TYPE_MERGED;
		}
	}
	
	@Override
	public void setEntryLine(String entryLine) throws CVSException {
		super.setEntryLine(entryLine);
	}
}

Back to the top