Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2006-01-24 20:15:22 +0000
committerMichael Valenta2006-01-24 20:15:22 +0000
commit952f3078ff5ea1cd2f34f98ab94a1b4522556777 (patch)
treee78a50b12134b97328371f2ddf216df2ab53afe1
parentadad46b4a849470458e06232fdc69cfc90c26d5e (diff)
downloadeclipse.platform.team-952f3078ff5ea1cd2f34f98ab94a1b4522556777.tar.gz
eclipse.platform.team-952f3078ff5ea1cd2f34f98ab94a1b4522556777.tar.xz
eclipse.platform.team-952f3078ff5ea1cd2f34f98ab94a1b4522556777.zip
Bug 125040 [Update] Model update must handle outgoing changes whose contents match
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java63
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java10
3 files changed, 71 insertions, 4 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
index 4d8774813..32ac20a87 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/mappings/ModelUpdateOperation.java
@@ -50,7 +50,7 @@ public class ModelUpdateOperation extends AbstractModelMergeOperation {
protected IMergeContext buildMergeContext(IProgressMonitor monitor) throws CoreException {
monitor.beginTask(null, 100);
IMergeContext context = WorkspaceSubscriberContext.createContext(getScope(), true /* refresh */, getMergeType(), Policy.subMonitorFor(monitor, 50));
- cacheContents(getPart(), context, monitor);
+ cacheContents(getPart(), context, Policy.subMonitorFor(monitor, 40));
monitor.done();
return context;
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java
index b1c671736..0f566455a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CacheBaseContentsOperation.java
@@ -10,14 +10,24 @@
*******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.operations;
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.*;
import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.diff.IDiffNode;
import org.eclipse.team.core.diff.IThreeWayDiff;
import org.eclipse.team.core.history.IFileState;
import org.eclipse.team.core.mapping.IResourceDiff;
import org.eclipse.team.core.mapping.IResourceDiffTree;
+import org.eclipse.team.core.synchronize.SyncInfoFilter;
+import org.eclipse.team.core.synchronize.SyncInfoFilter.ContentComparisonSyncInfoFilter;
+import org.eclipse.team.core.variants.IResourceVariant;
import org.eclipse.team.internal.ccvs.core.*;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.ui.IWorkbenchPart;
/**
@@ -57,5 +67,58 @@ public class CacheBaseContentsOperation extends CacheTreeContentsOperation {
protected ICVSRemoteResource buildTree(CVSTeamProvider provider) throws TeamException {
return CVSProviderPlugin.getPlugin().getCVSWorkspaceSubscriber().buildBaseTree(provider.getProject(), true, new NullProgressMonitor());
}
+
+ protected void execute(CVSTeamProvider provider, IResource[] resources, boolean recurse, IProgressMonitor monitor) throws CVSException, InterruptedException {
+ IResource[] localChanges = getFilesWithLocalChanges(resources, recurse);
+ super.execute(provider, resources, recurse, monitor);
+ // Now that the contents are cached, reset the timestamps for any false local changes
+ if (localChanges.length > 0) {
+ performCleanTimestampa(localChanges[0].getProject(), localChanges, monitor);
+ }
+ }
+
+ private IResource[] getFilesWithLocalChanges(IResource[] resources, boolean recurse) {
+ ArrayList result = new ArrayList();
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ IDiffNode[] nodes = getTree().getDiffs(resource, recurse ? IResource.DEPTH_INFINITE: IResource.DEPTH_ONE);
+ for (int j = 0; j < nodes.length; j++) {
+ IDiffNode node = nodes[j];
+ if (isFileWithLocalChange(node)) {
+ result.add(getTree().getResource(node));
+ }
+ }
+ }
+ return (IResource[]) result.toArray(new IResource[result.size()]);
+ }
+
+ private boolean isFileWithLocalChange(IDiffNode node) {
+ if (node instanceof IThreeWayDiff) {
+ IThreeWayDiff twd = (IThreeWayDiff) node;
+ return (twd.getDirection() == IThreeWayDiff.OUTGOING || twd.getDirection() == IThreeWayDiff.CONFLICTING)
+ && getTree().getResource(node).getType() == IResource.FILE;
+ }
+ return false;
+ }
+
+ private void performCleanTimestampa(IProject project, final IResource[] resources, IProgressMonitor monitor) throws CVSException {
+ ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
+ final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false);
+ folder.run(new ICVSRunnable() {
+ public void run(IProgressMonitor monitor) throws CVSException {
+ monitor.beginTask(null, resources.length * 100);
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if (resource.getType() == IResource.FILE) {
+ if (comparator.compareContents((IFile)resource, (IResourceVariant)CVSWorkspaceRoot.getRemoteResourceFor(resource), Policy.subMonitorFor(monitor, 100))) {
+ ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource);
+ cvsFile.checkedIn(null, false /* not a commit */);
+ }
+ }
+ }
+ monitor.done();
+ }
+ }, Policy.subMonitorFor(monitor, 100));
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java
index 8d3e14383..7b29eb7ee 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/subscriber/RefreshDirtyStateOperation.java
@@ -45,13 +45,18 @@ public class RefreshDirtyStateOperation extends CVSSubscriberOperation {
* @see org.eclipse.team.internal.ccvs.ui.subscriber.CVSSubscriberOperation#run(org.eclipse.team.core.synchronize.SyncInfoSet, org.eclipse.core.runtime.IProgressMonitor)
*/
protected void run(SyncInfoSet set, IProgressMonitor monitor) throws TeamException {
- final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false);
final SyncInfo[] infos = set.getSyncInfos();
if (infos.length == 0) return;
monitor.beginTask(null, 200);
IProject project = infos[0].getLocal().getProject();
- ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
ensureBaseContentsCached(project, infos, Policy.subMonitorFor(monitor, 100));
+ performCleanTimestamps(project, infos, monitor);
+ monitor.done();
+ }
+
+ private void performCleanTimestamps(IProject project, final SyncInfo[] infos, IProgressMonitor monitor) throws CVSException {
+ ICVSFolder folder = CVSWorkspaceRoot.getCVSFolderFor(project);
+ final ContentComparisonSyncInfoFilter comparator = new SyncInfoFilter.ContentComparisonSyncInfoFilter(false);
folder.run(new ICVSRunnable() {
public void run(IProgressMonitor monitor) throws CVSException {
monitor.beginTask(null, infos.length * 100);
@@ -68,7 +73,6 @@ public class RefreshDirtyStateOperation extends CVSSubscriberOperation {
monitor.done();
}
}, Policy.subMonitorFor(monitor, 100));
- monitor.done();
}
private void ensureBaseContentsCached(IProject project, SyncInfo[] infos, IProgressMonitor monitor) throws CVSException {

Back to the top