Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 148029
Collapse All | Expand All

(-)src/org/eclipse/team/tests/ccvs/core/subscriber/CVSWorkspaceSubscriberTest.java (+24 lines)
Lines 1339-1342 Link Here
1339
    		CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option);
1339
    		CVSProviderPlugin.getPlugin().setDefaultTextKSubstOption(option);
1340
    	}
1340
    	}
1341
    }
1341
    }
1342
    
1343
    public void testDisabledDirectoryDiscovery() throws CoreException {
1344
    	// Create a project and disable new directory discovery
1345
    	IProject project = createProject(new String[] { "file1.txt"});
1346
    	setFetchAbsentDirectories(project, false);
1347
    	
1348
    	IProject copy = checkoutCopy(project, "-copy");
1349
    	addResources(copy, new String[] { "added.txt", "folder2/", "folder2/added.txt" }, true);
1350
    	
1351
    	// The new subfolder (folder2) and its contents should not have sync info (i.e. in_sync)
1352
		assertSyncEquals("testDisabledDirectoryDiscovery", project,
1353
				new String[] {"file1.txt", "added.txt", "folder2/", "folder2/added.txt" },
1354
				true, new int[] { 
1355
				SyncInfo.IN_SYNC,
1356
				SyncInfo.INCOMING | SyncInfo.ADDITION,
1357
				SyncInfo.IN_SYNC,
1358
				SyncInfo.IN_SYNC
1359
		});
1360
    }
1361
1362
	private void setFetchAbsentDirectories(IProject project, boolean fetch) throws CVSException {
1363
		RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
1364
		((CVSTeamProvider) provider).setFetchAbsentDirectories(fetch);
1365
	}
1342
}
1366
}
(-)src/org/eclipse/team/internal/ccvs/core/client/Update.java (-13 / +25 lines)
Lines 103-108 Link Here
103
	protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
103
	protected LocalOption[] filterLocalOptions(Session session, GlobalOption[] globalOptions, LocalOption[] localOptions) {
104
		List newOptions = new ArrayList(Arrays.asList(localOptions));
104
		List newOptions = new ArrayList(Arrays.asList(localOptions));
105
		
105
		
106
		if (shouldRetrieveAbsentDirectories(session) && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) {
107
			newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
108
		}
109
110
		// Prune empty directories if pruning is enabled and the command in not being run in non-update mode
111
		if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() && ! PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) {
112
			if (! DO_NOT_CHANGE.isElementOf(globalOptions)) {
113
				newOptions.add(Command.PRUNE_EMPTY_DIRECTORIES);
114
			}
115
		}
116
		localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]);
117
		return super.filterLocalOptions(session, globalOptions, localOptions);
118
	}
119
	
120
	/**
121
	 * Return whether the update command should retrieve absent directories.
122
	 * @param session the session
123
	 * @return whether the update command should retrieve absent directories
124
	 */
125
	protected boolean shouldRetrieveAbsentDirectories(Session session) {
106
		// Look for absent directories if enabled and the option is not already included
126
		// Look for absent directories if enabled and the option is not already included
107
		IResource resource = null;
127
		IResource resource = null;
108
		RepositoryProvider provider = null;
128
		RepositoryProvider provider = null;
Lines 112-119 Link Here
112
			if (resource != null) {
132
			if (resource != null) {
113
				provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
133
				provider = RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId());
114
				if (provider != null) {
134
				if (provider != null) {
115
					if (((CVSTeamProvider)provider).getFetchAbsentDirectories() && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) {
135
					if (((CVSTeamProvider)provider).getFetchAbsentDirectories()) {
116
						newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
136
						return true;
117
					}
137
					}
118
				}
138
				}
119
			}
139
			}
Lines 122-140 Link Here
122
		}
142
		}
123
		// If there is no provider, use the global setting
143
		// If there is no provider, use the global setting
124
		if (provider == null) {
144
		if (provider == null) {
125
			if (CVSProviderPlugin.getPlugin().getFetchAbsentDirectories() && ! RETRIEVE_ABSENT_DIRECTORIES.isElementOf(localOptions)) {
145
			if (CVSProviderPlugin.getPlugin().getFetchAbsentDirectories()) {
126
				newOptions.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
146
				return true;
127
			}
147
			}
128
		}
148
		}
129
		
149
		return false;
130
		// Prune empty directories if pruning is enabled and the command in not being run in non-update mode
131
		if (CVSProviderPlugin.getPlugin().getPruneEmptyDirectories() && ! PRUNE_EMPTY_DIRECTORIES.isElementOf(localOptions)) {
132
			if (! DO_NOT_CHANGE.isElementOf(globalOptions)) {
133
				newOptions.add(Command.PRUNE_EMPTY_DIRECTORIES);
134
			}
135
		}
136
		localOptions = (LocalOption[]) newOptions.toArray(new LocalOption[newOptions.size()]);
137
		return super.filterLocalOptions(session, globalOptions, localOptions);
138
	}
150
	}
139
	
151
	
140
	/**
152
	/**
(-)src/org/eclipse/team/internal/ccvs/core/resources/UpdateContentCachingService.java (-2 / +39 lines)
Lines 13-22 Link Here
13
import java.util.ArrayList;
13
import java.util.ArrayList;
14
import java.util.Date;
14
import java.util.Date;
15
15
16
import org.eclipse.core.resources.IProject;
16
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.resources.IResource;
17
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IProgressMonitor;
18
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.core.runtime.IStatus;
19
import org.eclipse.osgi.util.NLS;
20
import org.eclipse.osgi.util.NLS;
21
import org.eclipse.team.core.RepositoryProvider;
20
import org.eclipse.team.core.TeamException;
22
import org.eclipse.team.core.TeamException;
21
import org.eclipse.team.internal.ccvs.core.*;
23
import org.eclipse.team.internal.ccvs.core.*;
22
import org.eclipse.team.internal.ccvs.core.client.*;
24
import org.eclipse.team.internal.ccvs.core.client.*;
Lines 24-30 Link Here
24
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
26
import org.eclipse.team.internal.ccvs.core.client.listeners.ICommandOutputListener;
25
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
27
import org.eclipse.team.internal.ccvs.core.connection.CVSRepositoryLocation;
26
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
28
import org.eclipse.team.internal.ccvs.core.connection.CVSServerException;
27
import org.eclipse.team.internal.ccvs.core.syncinfo.*;
29
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
30
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
28
31
29
/**
32
/**
30
 * This class can be used to fetch and cache file contents for remote files.
33
 * This class can be used to fetch and cache file contents for remote files.
Lines 35-42 Link Here
35
	private ICVSFolder remoteRoot;
38
	private ICVSFolder remoteRoot;
36
	private final CVSTag tag;
39
	private final CVSTag tag;
37
	private final int depth;
40
	private final int depth;
41
	private boolean fetchAbsentDirectories = true;
38
42
39
	public class SandboxUpdate extends Update {
43
	public class SandboxUpdate extends Update {
44
		
45
		/* (non-Javadoc)
46
		 * @see org.eclipse.team.internal.ccvs.core.client.Update#shouldRetrieveAbsentDirectories(org.eclipse.team.internal.ccvs.core.client.Session)
47
		 */
48
		protected boolean shouldRetrieveAbsentDirectories(Session session) {
49
			return fetchAbsentDirectories;
50
		}
51
		
40
		/* (non-Javadoc)
52
		/* (non-Javadoc)
41
		 * @see org.eclipse.team.internal.ccvs.core.client.Command#commandFinished(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IStatus)
53
		 * @see org.eclipse.team.internal.ccvs.core.client.Command#commandFinished(org.eclipse.team.internal.ccvs.core.client.Session, org.eclipse.team.internal.ccvs.core.client.Command.GlobalOption[], org.eclipse.team.internal.ccvs.core.client.Command.LocalOption[], org.eclipse.team.internal.ccvs.core.ICVSResource[], org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IStatus)
42
		 */
54
		 */
Lines 59-65 Link Here
59
	
71
	
60
	/**
72
	/**
61
	 * This class overrides the "Created" handler in order to configure the remote file
73
	 * This class overrides the "Created" handler in order to configure the remote file
62
	 * to recieve and cache the contents
74
	 * to receive and cache the contents
63
	 */
75
	 */
64
	public class SandboxUpdatedHandler extends UpdatedHandler {
76
	public class SandboxUpdatedHandler extends UpdatedHandler {
65
		public SandboxUpdatedHandler(int type) {
77
		public SandboxUpdatedHandler(int type) {
Lines 102-107 Link Here
102
		try {
114
		try {
103
			RemoteFolder tree = buildBaseTree(repository, root, tag, Policy.subMonitorFor(monitor, 50));
115
			RemoteFolder tree = buildBaseTree(repository, root, tag, Policy.subMonitorFor(monitor, 50));
104
			UpdateContentCachingService service = new UpdateContentCachingService(repository, tree, tag, depth);
116
			UpdateContentCachingService service = new UpdateContentCachingService(repository, tree, tag, depth);
117
			service.setFetchAbsentDirectories(getFetchAbsentDirectories(root));
105
			if (!service.cacheFileContents(Policy.subMonitorFor(monitor, 50)))
118
			if (!service.cacheFileContents(Policy.subMonitorFor(monitor, 50)))
106
				return null;
119
				return null;
107
			return tree;
120
			return tree;
Lines 110-115 Link Here
110
		}
123
		}
111
	}
124
	}
112
	
125
	
126
	private void setFetchAbsentDirectories(boolean fetchAbsentDirectories) {
127
		this.fetchAbsentDirectories = fetchAbsentDirectories;
128
	}
129
130
	private static boolean getFetchAbsentDirectories(ICVSFolder root) {
131
		IResource resource = root.getIResource();
132
		if (resource != null) {
133
			IProject project = resource.getProject();
134
			RepositoryProvider provider = RepositoryProvider.getProvider(project, CVSProviderPlugin.getTypeId());
135
			if (provider instanceof CVSTeamProvider) {
136
				CVSTeamProvider cp = (CVSTeamProvider) provider;
137
				try {
138
					return cp.getFetchAbsentDirectories();
139
				} catch (CVSException e) {
140
					CVSProviderPlugin.log(e);
141
				}
142
			}
143
		}
144
		return CVSProviderPlugin.getPlugin().getFetchAbsentDirectories();
145
	}
146
113
	private static RemoteFolder buildBaseTree(final CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor progress) throws CVSException {
147
	private static RemoteFolder buildBaseTree(final CVSRepositoryLocation repository, ICVSFolder root, CVSTag tag, IProgressMonitor progress) throws CVSException {
114
		try {
148
		try {
115
			RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag) {
149
			RemoteFolderTreeBuilder builder = new RemoteFolderTreeBuilder(repository, root, tag) {
Lines 228-233 Link Here
228
		if (depth != IResource.DEPTH_INFINITE )
262
		if (depth != IResource.DEPTH_INFINITE )
229
			options.add(Command.DO_NOT_RECURSE);
263
			options.add(Command.DO_NOT_RECURSE);
230
		
264
		
265
		if (fetchAbsentDirectories)
266
			options.add(Update.RETRIEVE_ABSENT_DIRECTORIES);
267
		
231
		if (!options.isEmpty())
268
		if (!options.isEmpty())
232
			return (LocalOption[]) options.toArray(new LocalOption[options.size()]);
269
			return (LocalOption[]) options.toArray(new LocalOption[options.size()]);
233
		
270
		

Return to bug 148029