blob: eb664c7239a46939ce86654954cf4f93bbb06575 (
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
|
package org.eclipse.team.internal.ccvs.core.client;
/*
* (c) Copyright IBM Corp. 2000, 2002.
* All Rights Reserved.
*/
import java.util.HashSet;
import java.util.Set;
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.util.Assert;
/**
* This is a visitor that is specially created for the add-command.<br>
* It traverses the file-structure in the other direction, so that
* all the parents are send until a parent is found that should allready
* be known by the to the root are send.<br>
* The visitor remembers the folders it has allready been to and does not
* send them again (if possible).
*/
class AddStructureVisitor extends AbstractStructureVisitor {
private boolean forceSend = false;
private Set visitedFolders = new HashSet();
private ICVSFolder lastVisitedFolder;
/**
* Constructor for AddStructureVisitor.
* @param requestSender
* @param mRoot
* @param monitor
*/
public AddStructureVisitor(Session session, IProgressMonitor monitor) {
super(session, monitor);
}
/**
* @see ICVSResourceVisitor#visitFile(IManagedFile)
*/
public void visitFile(ICVSFile mFile) throws CVSException {
if (!mFile.getParent().equals(lastVisitedFolder)) {
forceSend = true;
mFile.getParent().accept(this);
}
// Sends the Is-modified request if it is supported, otherwise
// the file contents are sent as binary. The server does not
// need the contents at this stage so this should not be a problem.
session.sendIsModified(mFile, true, monitor);
}
/**
* @see ICVSResourceVisitor#visitFolder(ICVSFolder)
*/
public void visitFolder(ICVSFolder mFolder) throws CVSException {
Assert.isNotNull(mFolder);
// Save the status wheter we want to send
// this folder in every case
boolean alreadyVisited;
boolean forceSend = this.forceSend;
this.forceSend = false;
alreadyVisited = visitedFolders.contains(mFolder);
if (!mFolder.equals(session.getLocalRoot()) && !alreadyVisited) {
mFolder.getParent().accept(this);
}
if (forceSend || !alreadyVisited) {
visitedFolders.add(mFolder);
lastVisitedFolder = mFolder;
sendFolder(mFolder,false,false);
}
}
}
|