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 306507 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/team/internal/ccvs/ui/subscriber/SafeUpdateOperation.java (-14 / +77 lines)
Lines 11-43 Link Here
11
package org.eclipse.team.internal.ccvs.ui.subscriber;
11
package org.eclipse.team.internal.ccvs.ui.subscriber;
12
12
13
import java.lang.reflect.InvocationTargetException;
13
import java.lang.reflect.InvocationTargetException;
14
import java.util.ArrayList;
14
import java.util.*;
15
import java.util.HashSet;
16
import java.util.List;
17
import java.util.Set;
18
15
19
import org.eclipse.compare.structuremergeviewer.IDiffElement;
16
import org.eclipse.compare.structuremergeviewer.IDiffElement;
20
import org.eclipse.core.resources.*;
17
import org.eclipse.core.resources.*;
18
import org.eclipse.core.resources.mapping.ResourceMapping;
19
import org.eclipse.core.resources.mapping.ResourceMappingContext;
20
import org.eclipse.core.runtime.CoreException;
21
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
22
import org.eclipse.core.runtime.jobs.ISchedulingRule;
23
import org.eclipse.core.runtime.jobs.MultiRule;
22
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.osgi.util.NLS;
25
import org.eclipse.osgi.util.NLS;
24
import org.eclipse.team.core.TeamException;
26
import org.eclipse.team.core.TeamException;
25
import org.eclipse.team.core.synchronize.FastSyncInfoFilter;
27
import org.eclipse.team.core.mapping.provider.SynchronizationScopeManager;
26
import org.eclipse.team.core.synchronize.SyncInfo;
28
import org.eclipse.team.core.synchronize.*;
27
import org.eclipse.team.core.synchronize.SyncInfoSet;
29
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.*;
28
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.AndSyncInfoFilter;
29
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.OrSyncInfoFilter;
30
import org.eclipse.team.core.synchronize.FastSyncInfoFilter.SyncInfoDirectionFilter;
31
import org.eclipse.team.core.variants.IResourceVariant;
30
import org.eclipse.team.core.variants.IResourceVariant;
32
import org.eclipse.team.internal.ccvs.core.CVSException;
31
import org.eclipse.team.internal.ccvs.core.*;
33
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
34
import org.eclipse.team.internal.ccvs.core.ICVSFile;
35
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
32
import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
36
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
33
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
34
import org.eclipse.team.internal.ccvs.core.resources.EclipseSynchronizer;
37
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
35
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
38
import org.eclipse.team.internal.ccvs.ui.*;
36
import org.eclipse.team.internal.ccvs.ui.*;
39
import org.eclipse.team.internal.ccvs.ui.operations.UpdateOnlyMergableOperation;
37
import org.eclipse.team.internal.ccvs.ui.Policy;
38
import org.eclipse.team.internal.ccvs.ui.operations.*;
40
import org.eclipse.team.internal.ui.TeamUIPlugin;
39
import org.eclipse.team.internal.ui.TeamUIPlugin;
40
import org.eclipse.team.internal.ui.Utils;
41
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
41
import org.eclipse.team.ui.synchronize.ISynchronizePageConfiguration;
42
42
43
/**
43
/**
Lines 64-69 Link Here
64
	public boolean shouldRun() {
64
	public boolean shouldRun() {
65
		return promptIfNeeded();
65
		return promptIfNeeded();
66
	}
66
	}
67
68
	/**
69
	 * Run the operation for the sync infos from the given project. By default, a lock
70
	 * is acquired on the project.
71
	 * @param projectSyncInfos the project syncInfos
72
	 * @param project the project
73
	 * @param monitor a progress monitor
74
	 * @throws InvocationTargetException
75
	 */
76
	protected void run(final Map projectSyncInfos, final IProject project,
77
			IProgressMonitor monitor) throws InvocationTargetException {
78
		try {
79
			IResource[] resources = getIResourcesFrom(((SyncInfoSet) projectSyncInfos
80
					.get(project)).getSyncInfos());
81
			ResourceMapping[] selectedMappings = Utils
82
					.getResourceMappings(resources);
83
			ResourceMappingContext context = new SingleProjectSubscriberContext(
84
					CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber(),
85
					false, project);
86
			SynchronizationScopeManager manager = new SingleProjectScopeManager(
87
					getJobName(), selectedMappings, context, true, project);
88
			manager.initialize(null);
89
			ISchedulingRule updateRule = getUpdateRule(manager);
90
91
			// Pass the scheduling rule to the synchronizer so that sync change
92
			// events
93
			// and cache commits to disk are batched
94
			EclipseSynchronizer.getInstance().run(updateRule,
95
					new ICVSRunnable() {
96
						public void run(IProgressMonitor monitor)
97
								throws CVSException {
98
							try {
99
								runWithProjectRule(project,
100
										(SyncInfoSet) projectSyncInfos
101
												.get(project), monitor);
102
							} catch (TeamException e) {
103
								throw CVSException.wrapException(e);
104
							}
105
						}
106
					}, Policy.subMonitorFor(monitor, 100));
107
		} catch (TeamException e) {
108
			throw new InvocationTargetException(e);
109
		} catch (CoreException e) {
110
			throw new InvocationTargetException(e);
111
		}
112
	}
113
114
	private ISchedulingRule getUpdateRule(SynchronizationScopeManager manager) {
115
		ISchedulingRule rule = null;
116
		ResourceMapping[] mappings = manager.getScope().getMappings();
117
		for (int i = 0; i < mappings.length; i++) {
118
			ResourceMapping mapping = mappings[i];
119
			IProject[] mappingProjects = mapping.getProjects();
120
			for (int j = 0; j < mappingProjects.length; j++) {
121
				if (rule == null) {
122
					rule = mappingProjects[j];
123
				} else {
124
					rule = MultiRule.combine(rule, mappingProjects[j]);
125
				}
126
			}
127
		}
128
		return rule;
129
	}
67
	
130
	
68
	/* (non-Javadoc)
131
	/* (non-Javadoc)
69
	 * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor)
132
	 * @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.core.runtime.IProgressMonitor)

Return to bug 306507