Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-04-30 21:52:35 +0000
committerJean Michel-Lemieux2002-04-30 21:52:35 +0000
commit90b2ab04d9ed16c3d5e4e695179bf2c8a009133e (patch)
treeff91db9bd526b43f1e88ac3364c19d4d71c859c0
parent81ed8ca3439717ad1497daac809015a4d5204c26 (diff)
downloadeclipse.platform.team-90b2ab04d9ed16c3d5e4e695179bf2c8a009133e.tar.gz
eclipse.platform.team-90b2ab04d9ed16c3d5e4e695179bf2c8a009133e.tar.xz
eclipse.platform.team-90b2ab04d9ed16c3d5e4e695179bf2c8a009133e.zip
Compare refactoring to allow:
- all team compare editors are based on TeamFile and TeamNodes - compare editor allows to revert - you can remove nodes from a view as you like - save does not remove a node from the view, use the confirm merge action to confirm changes made to the file - compare now shows changes into added and deleted folders
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ILocalSyncElement.java11
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java9
-rw-r--r--bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java77
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java6
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java33
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java70
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java16
-rw-r--r--bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java7
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.properties24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml30
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java95
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java88
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java101
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java4
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithBaseAction.java84
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java135
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java98
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java32
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/ProjectElement.java1
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties15
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java82
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java64
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/CatchupReleaseViewer.java133
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncView.java1
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java265
30 files changed, 729 insertions, 767 deletions
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ILocalSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ILocalSyncElement.java
index 5317e1973..f3855f862 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ILocalSyncElement.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/ILocalSyncElement.java
@@ -151,17 +151,6 @@ public interface ILocalSyncElement {
public IRemoteResource getBase();
/**
- * Answers if the local resource currently has a different timestamp to the base timestamp
- * for this resource.
- *
- * @param resource the resource to test.
- * @return <code>true</code> if the resource has a different modification
- * timestamp, and <code>false</code> otherwise. If a base does not exist, this method
- * must return <code>false</code>.
- */
- public boolean isDirty();
-
- /**
* Answers if the remote resource state is checked-out. If the resource has never been checked in this
* method will return <code>true</code>.
* <p>
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java
index b260b3235..3089f8d18 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/IRemoteSyncElement.java
@@ -27,14 +27,7 @@ public interface IRemoteSyncElement extends ILocalSyncElement {
* is none.
*/
public IRemoteResource getRemote();
-
- /**
- * Answers <code>true</code> if the base of the given resource is different to the
- * released state of the given resource. If a base does not exist then this method must
- * return <code>false</code>.
- */
- public boolean isOutOfDate();
-
+
/**
* Answers <code>true</code> if the base tree is not to be considered during sync
* comparisons and <code>false</code> if it should. If the base tree is ignored the
diff --git a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java
index 8eb15d20f..77ff2c97e 100644
--- a/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java
+++ b/bundles/org.eclipse.team.core/src/org/eclipse/team/core/sync/RemoteSyncElement.java
@@ -164,8 +164,6 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
IRemoteResource base = getBase();
boolean localExists = getLocal().exists();
- boolean isDirty = isDirty();
- boolean isOutOfDate = isOutOfDate();
if (isThreeWay()) {
if (base == null) {
@@ -180,8 +178,14 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
description = INCOMING | ADDITION;
} else {
description = CONFLICTING | ADDITION;
- if (compare(granularity, false, local, remote, progress))
- description |= PSEUDO_CONFLICT;
+ try {
+ progress.beginTask(null, 60);
+ if (compare(granularity, true, local, remote, Policy.subMonitorFor(progress, 30))) {
+ description |= PSEUDO_CONFLICT;
+ }
+ } finally {
+ progress.done();
+ }
}
}
} else {
@@ -189,21 +193,21 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
if (remote == null) {
description = CONFLICTING | DELETION | PSEUDO_CONFLICT;
} else {
- if (compare(granularity, !isOutOfDate, base, remote, progress))
+ if (compare(granularity, false, base, remote, progress))
description = OUTGOING | DELETION;
else
description = CONFLICTING | CHANGE;
}
} else {
if (remote == null) {
- if (compare(granularity, !isDirty, local, base, progress))
+ if (compare(granularity, false, local, base, progress))
description = INCOMING | DELETION;
else
description = CONFLICTING | CHANGE;
} else {
progress.beginTask(null, 90);
- boolean ay = compare(granularity, !isDirty, local, base, Policy.subMonitorFor(progress, 30));
- boolean am = compare(granularity, !isOutOfDate, base, remote, Policy.subMonitorFor(progress, 30));
+ boolean ay = compare(granularity, false, local, base, Policy.subMonitorFor(progress, 30));
+ boolean am = compare(granularity, false, base, remote, Policy.subMonitorFor(progress, 30));
if (ay && am) {
;
} else if (ay && !am) {
@@ -213,51 +217,27 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
} else {
description = CONFLICTING | CHANGE;
}
- if (description != IN_SYNC && compare(granularity, false, local, remote, Policy.subMonitorFor(progress, 30)))
+ if (description != IN_SYNC && compare(granularity, true, local, remote, Policy.subMonitorFor(progress, 30))) {
description |= PSEUDO_CONFLICT;
+ }
progress.done();
}
}
}
- } else { // three-way compare without access to base contents
+ } else { // two compare without access to base contents
if (remote == null) {
if (!localExists) {
- // this should never happen
Assert.isTrue(false);
+ // shouldn't happen
} else {
- // no remote but a local
- if (!isDirty && isOutOfDate) {
- description = INCOMING | DELETION;
- } else if (isDirty && isOutOfDate) {
- description = CONFLICTING | CHANGE;
- } else if (!isDirty && !isOutOfDate) {
- description = OUTGOING | ADDITION;
- }
+ description= DELETION;
}
} else {
if (!localExists) {
- // a remote but no local
- if (!isDirty && !isOutOfDate) {
- description = INCOMING | ADDITION;
- } else if (isDirty && !isOutOfDate) {
- description = OUTGOING | DELETION;
- } else if (isDirty && isOutOfDate) {
- description = CONFLICTING | CHANGE;
- }
+ description= ADDITION;
} else {
- // have a local and a remote
- if (!isDirty && !isOutOfDate && base != null) {
- // ignore, there is no change;
- } else if (!isDirty && isOutOfDate) {
- description = INCOMING | CHANGE;
- } else if (isDirty && !isOutOfDate) {
- description = OUTGOING | CHANGE;
- } else {
- description = CONFLICTING | CHANGE;
- }
- // if contents are the same, then mark as pseudo change
- if (description != IN_SYNC && compare(granularity, false, local, remote, progress))
- description |= PSEUDO_CONFLICT;
+ if (! compare(granularity, false, local, remote, Policy.subMonitorFor(progress, 30)))
+ description= CHANGE;
}
}
}
@@ -270,8 +250,9 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
* If timestampDiff is true then the timestamps don't differ and there's no point checking the
* contents.
*/
- private boolean compare(int granularity, boolean timestampDiff, IResource e1, IRemoteResource e2, IProgressMonitor monitor) {
- if (!timestampDiff && (granularity == GRANULARITY_CONTENTS)) {
+ private boolean compare(int granularity, boolean force, IResource e1, IRemoteResource e2, IProgressMonitor monitor) {
+ boolean timestampEquals = force || timestampEquals(e1, e2);
+ if (!timestampEquals && (granularity == GRANULARITY_CONTENTS)) {
try {
monitor.beginTask(null, 100);
return contentsEqual(getContents(e1, Policy.subMonitorFor(monitor, 50)), getContents(e2, Policy.subMonitorFor(monitor, 50)));
@@ -279,12 +260,13 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
monitor.done();
}
} else {
- return timestampDiff;
+ return timestampEquals;
}
}
- private boolean compare(int granularity, boolean timestampDiff, IRemoteResource e1, IRemoteResource e2, IProgressMonitor monitor) {
- if (!timestampDiff && (granularity == GRANULARITY_CONTENTS)) {
+ private boolean compare(int granularity, boolean force, IRemoteResource e1, IRemoteResource e2, IProgressMonitor monitor) {
+ boolean timestampEquals = force || timestampEquals(e1, e2);
+ if (!timestampEquals && (granularity == GRANULARITY_CONTENTS)) {
try {
monitor.beginTask(null, 100);
return contentsEqual(getContents(e1, Policy.subMonitorFor(monitor, 50)), getContents(e2, Policy.subMonitorFor(monitor, 50)));
@@ -292,10 +274,13 @@ public abstract class RemoteSyncElement extends LocalSyncElement implements IRem
monitor.done();
}
} else {
- return timestampDiff;
+ return timestampEquals;
}
}
+ protected abstract boolean timestampEquals(IResource e1, IRemoteResource e2);
+ protected abstract boolean timestampEquals(IRemoteResource e1, IRemoteResource e2);
+
private InputStream getContents(IResource resource, IProgressMonitor monitor) {
try {
if (resource instanceof IStorage)
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
index d5e446211..3e5508e41 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/ICVSFile.java
@@ -76,12 +76,6 @@ public interface ICVSFile extends ICVSResource {
void setTimeStamp(Date date) throws CVSException;
/**
- * Answers <code>true</code> if the file differs from its base. If the file has no
- * base, it is not dirty
- */
- boolean isDirty() throws CVSException;
-
- /**
* Answers <code>true</code> if the file has changed since it was last updated
* from the repository, if the file does not exist, or is not managed. And <code>false</code>
* if it has not changed.
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
index dae66d83c..416b19a9f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSLocalSyncElement.java
@@ -49,39 +49,6 @@ public class CVSLocalSyncElement extends LocalSyncElement {
}
/*
- * @see ILocalSyncElement#isDirty()
- */
- public boolean isDirty() {
- ICVSResource cvsResource = getCVSResourceFor(getLocal());
- if(cvsResource == null) {
- return false;
- } else {
- // a folder is dirty if it is managed but is not a CVS folder. This can
- // easily happen if someone deletes a folder from the file system but
- // doesn't unmanage it.
- if(cvsResource.isFolder()) {
- return false;
- } else {
- try {
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- if(info==null) {
- return false;
- }
- if(base!=null) {
- boolean sameRevisions = ((RemoteFile)base).getRevision().equals(info.getRevision());
- if(!sameRevisions) {
- return true;
- }
- }
- return ((ICVSFile)cvsResource).isDirty();
- } catch(CVSException e) {
- return true;
- }
- }
- }
- }
-
- /*
* @see ILocalSyncElement#isCheckedOut()
*/
public boolean isCheckedOut() {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
index d1e7b9c1d..36220539b 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/CVSRemoteSyncElement.java
@@ -5,6 +5,7 @@ package org.eclipse.team.internal.ccvs.core.resources;
* All Rights Reserved.
*/
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.team.core.TeamException;
@@ -14,6 +15,7 @@ import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.core.sync.RemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
@@ -52,22 +54,6 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
}
/*
- * @see IRemoteSyncElement#isOutOfDate()
- */
- public boolean isOutOfDate() {
- IRemoteResource base = getBase();
- if(base!=null && remote!=null) {
- ICVSRemoteResource remoteCvs = (ICVSRemoteResource)remote;
- ICVSRemoteResource baseCvs = (ICVSRemoteResource)base;
- return ! remoteCvs.equals(baseCvs);
- } else if(base!=null && remote==null) {
- return true;
- } else {
- return false;
- }
- }
-
- /*
* @see LocalSyncElement#getData()
*/
protected Object getData() {
@@ -89,13 +75,6 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
}
/*
- * @see ILocalSyncElement#isDirty()
- */
- public boolean isDirty() {
- return localSync.isDirty();
- }
-
- /*
* @see ILocalSyncElement#isCheckedOut()
*/
public boolean isCheckedOut() {
@@ -281,7 +260,7 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
// special handling for folders, the generic sync algorithm doesn't work well
// with CVS because folders are not in namespaces (e.g. they exist in all versions
// and branches).
- if(isContainer()) {
+ if(isContainer() && isThreeWay()) {
int folderKind = IRemoteSyncElement.IN_SYNC;
IResource local = getLocal();
ICVSRemoteFolder remote = (ICVSRemoteFolder)getRemote();
@@ -293,7 +272,7 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
// conflicting deletion ignore
}
} else {
- if(remote == null) {
+ if(remote == null) {
if(cvsFolder.isCVSFolder()) {
folderKind = IRemoteSyncElement.INCOMING | IRemoteSyncElement.DELETION;
} else {
@@ -355,4 +334,45 @@ public class CVSRemoteSyncElement extends RemoteSyncElement {
}
return kind;
}
+
+ /**
+ * @see RemoteSyncElement#timestampEquals(IRemoteResource, IRemoteResource)
+ */
+ protected boolean timestampEquals(IRemoteResource e1, IRemoteResource e2) {
+ if(e1.isContainer()) {
+ if(e2.isContainer()) {
+ return true;
+ }
+ return false;
+ }
+ return e1.equals(e2);
+ }
+
+ /**
+ * @see RemoteSyncElement#timestampEquals(IResource, IRemoteResource)
+ */
+ protected boolean timestampEquals(IResource e1, IRemoteResource e2) {
+ if(e1.getType() != IResource.FILE) {
+ if(e2.isContainer()) {
+ return true;
+ }
+ return false;
+ }
+ ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)e1);
+ try {
+ ResourceSyncInfo info1 = cvsFile.getSyncInfo();
+ ResourceSyncInfo info2 = ((ICVSRemoteResource)e2).getSyncInfo();
+
+ if(info1 != null) {
+ if(info1.isDeleted() || info1.isMerged() || cvsFile.isModified()) {
+ return false;
+ }
+ return info1.getRevision().equals(info2.getRevision());
+ }
+ return false;
+ } catch(CVSException e) {
+ CVSProviderPlugin.log(e.getStatus());
+ return false;
+ }
+ }
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
index 618a07789..5c0cab35f 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/EclipseFile.java
@@ -104,22 +104,6 @@ public class EclipseFile extends EclipseResource implements ICVSFile {
}
/*
- * @see ICVSFile#isDirty()
- */
- public boolean isDirty() throws CVSException {
- if (!exists() || !isManaged()) {
- return true;
- } else {
- ResourceSyncInfo info = getSyncInfo();
- if (info.isAdded()) return false;
- if (info.isDeleted()) return true;
- // consider a merged file as always modified.
- if(info.isMerged()) return true;
- return !getTimeStamp().equals(info.getTimeStamp());
- }
- }
-
- /*
* @see ICVSFile#isModified()
*/
public boolean isModified() throws CVSException {
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
index 2da15c4c8..da91c272d 100644
--- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
+++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/resources/RemoteFile.java
@@ -400,13 +400,6 @@ public class RemoteFile extends RemoteResource implements ICVSRemoteFile {
public void setTimeStamp(Date date) throws CVSException {
}
- /*
- * @see ICVSFile#isDirty()
- */
- public boolean isDirty() throws CVSException {
- return false;
- }
-
public boolean isModified() throws CVSException {
// it is safe to always consider a remote file handle as modified. This will cause any
// CVS command to fetch new contents from the server.
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.properties b/bundles/org.eclipse.team.cvs.ui/plugin.properties
index 66aa0cd66..895a9a6d0 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.properties
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.properties
@@ -22,9 +22,6 @@ AddAction.tooltip=Add the Selected Resources to Version Control
MergeAction.label=&Merge...
MergeAction.tooltip=Merge
-AutoDefineTagsAction.label=&Auto-discover Tags
-AutoDefineTagsAction.tooltip=Auto-discover Tags
-
BranchAction.label=&Branch...
BranchAction.tooltip=Branch
@@ -37,11 +34,8 @@ CompareWithRemoteAction.tooltip=Compare with Content on CVS Server
CompareWithRevisionAction.label=&Revision...
CompareWithRevisionAction.tooltip=Compare with Revision on CVS Server
-CompareWithTagAction.label=&Tag...
-CompareWithTagAction.tooltip=Compare with Tag on CVS Server
-
-CompareWithBaseAction.label=&Base
-CompareWithBaseAction.tooltip=Compare with Base on CVS Server
+CompareWithTagAction.label=&Branch or Version...
+CompareWithTagAction.tooltip=Compare with a Branch or a Version on the CVS Server
CopyRepositoryNameAction.label=&Copy to Clipboard
CopyRepositoryNameAction.tooltip=Copy Repository Names to Clipboard
@@ -52,8 +46,8 @@ IgnoreAction.tooltip=Ignore the Selected Resources when Synchronizing
RemoveBranchTagAction.label=Discard &Branch
RemoveBranchTagAction.tooltip=Discard Branch
-RemoveModuleVersionAction.label=Discard &Tag
-RemoveModuleVersionAction.tooltip=Discard Tag
+RemoveModuleVersionAction.label=Discard &Version
+RemoveModuleVersionAction.tooltip=Discard Version
RemoveRootAction.label=Discard &Location
RemoveRootAction.tooltip=Discard Location
@@ -61,14 +55,14 @@ RemoveRootAction.tooltip=Discard Location
ReplaceWithRevisionAction.label=&Revision...
ReplaceWithRevisionAction.tooltip=Replace with Revision on CVS Server
-ReplaceWithTagAction.label=&Tag...
-ReplaceWithTagAction.tooltip=Replace with Version on CVS Server
+ReplaceWithTagAction.label=&Branch or Version...
+ReplaceWithTagAction.tooltip=Replace with Branch or Version on the CVS Server
TagAction.label=&Tag as Version...
-TagAction.tooltip=Tag
+TagAction.tooltip=Tag the resources with a CVS version tag
TagInRepositoryAction.label=&Tag as Version...
-TagInRepositoryAction.tooltip=Tag
+TagInRepositoryAction.tooltip=Tag the resources with a CVS version tag
MoveTagAction.label=&Tag with Existing...
MoveTagAction.tooltip=Tag the selected resources with an existing tag
@@ -88,7 +82,7 @@ UpdateAction.tooltip=Update
ReplaceWithAction.label=&Latest From Repository
ReplaceWithAction.tooltip=Replace with last committed content from CVS Server
-ConfigureTags.label=&Configure Tags...
+ConfigureTags.label=&Configure Branches and Versions...
ConfigureTags.tooltip=Configure the branch and version tags shown in the workbench
CommitAction.label=&Commit...
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 707dd381f..d46111fd4 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -210,6 +210,13 @@
id="org.eclipse.team.ccvs.ui.sync">
</action>
<action
+ label="%CompareWithTagAction.label"
+ tooltip="%CompareWithTagAction.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.actions.CompareWithTagAction"
+ menubarPath="compareWithMenu/compareWithGroup"
+ id="org.eclipse.team.ccvs.ui.compareWithTag">
+ </action>
+ <action
label="%ReplaceWithTagAction.label"
tooltip="%ReplaceWithTagAction.tooltip"
class="org.eclipse.team.internal.ccvs.ui.actions.ReplaceWithTagAction"
@@ -257,29 +264,6 @@
</action>
</objectContribution>
<objectContribution
- objectClass="org.eclipse.core.resources.IContainer"
- adaptable="true"
- id="org.eclipse.team.ccvs.ui.IContainerContributions">
- <filter
- name="projectNature"
- value="org.eclipse.team.cvs.core.cvsnature">
- </filter>
- <action
- label="%CompareWithTagAction.label"
- tooltip="%CompareWithTagAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.actions.CompareWithTagAction"
- menubarPath="compareWithMenu/compareWithGroup"
- id="org.eclipse.team.ccvs.ui.compareWithTag">
- </action>
- <action
- label="%CompareWithBaseAction.label"
- tooltip="%CompareWithBaseAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.actions.CompareWithBaseAction"
- menubarPath="compareWithMenu/compareWithGroup"
- id="org.eclipse.team.ccvs.ui.compareWithBase">
- </action>
- </objectContribution>
- <objectContribution
objectClass="org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder"
id="org.eclipse.team.ccvs.ui.RemoteFolderContributions">
<action
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
index 3bd5a6c85..6ff815c24 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSCompareEditorInput.java
@@ -46,8 +46,8 @@ import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
/**
- * A compare input for performing naive comparisons between
- * resources and resource editions.
+ * A compare input for comparing remote resources. Use <code>CVSLocalCompareInput</code>
+ * when comparing resources in the workspace to remote resources.
*/
public class CVSCompareEditorInput extends CompareEditorInput {
private ITypedElement left;
@@ -59,53 +59,17 @@ public class CVSCompareEditorInput extends CompareEditorInput {
private static final int NODE_NOT_EQUAL = 1;
private static final int NODE_UNKNOWN = 2;
- class ResourceDiffNode extends DiffNode {
- public ResourceDiffNode(IDiffContainer parent, int kind, ITypedElement ancestor, ITypedElement left, ITypedElement right) {
- super(parent, kind, ancestor, left, right);
- }
- /*
- * @see ICompareInput#copy(boolean)
- */
- public void copy(boolean leftToRight) {
- if (leftToRight) return;
- ITypedElement right = getRight();
- ITypedElement left = getLeft();
- if (left == null) {
- // Addition
- ResourceDiffNode parent = (ResourceDiffNode)getParent();
- IContainer parentResource = (IContainer)((CVSResourceNode)parent.getLeft()).getResource();
- IFile resource = parentResource.getFile(new Path(right.getName()));
- try {
- resource.create(new ByteArrayInputStream(new byte[0]), false, null);
- } catch (CoreException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- left = new CVSResourceNode(resource);
- setLeft(left);
- } else {
- // Deletion
- try {
- ((IFile)((CVSResourceNode)left).getResource()).delete(false, true, null);
- } catch (CoreException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- setLeft(null);
- }
- super.copy(leftToRight);
- }
- };
-
/**
* Creates a new CVSCompareEditorInput.
*/
- public CVSCompareEditorInput(ITypedElement left, ITypedElement right) {
+ public CVSCompareEditorInput(ResourceEditionNode left, ResourceEditionNode right) {
this(left, right, null);
}
/**
* Creates a new CVSCompareEditorInput.
*/
- public CVSCompareEditorInput(ITypedElement left, ITypedElement right, ITypedElement ancestor) {
+ public CVSCompareEditorInput(ResourceEditionNode left, ResourceEditionNode right, ResourceEditionNode ancestor) {
super(new CompareConfiguration());
this.left = left;
this.right = right;
@@ -113,19 +77,9 @@ public class CVSCompareEditorInput extends CompareEditorInput {
}
/**
- * Overridden to create the CVSDiffTreeViewer to have the proper popup actions
- */
- //public Viewer createDiffViewer(Composite parent) {
- // return new CVSDiffTreeViewer(parent, this);
- //}
-
- /**
* Returns the label for the given input element.
*/
private String getLabel(ITypedElement element) {
- if (element instanceof ResourceNode) {
- return Policy.bind("CVSCompareEditorInput.workspace", element.getName()); //$NON-NLS-1$
- }
if (element instanceof ResourceEditionNode) {
ICVSRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource();
ICVSResource resource = (ICVSResource)edition;
@@ -161,9 +115,6 @@ public class CVSCompareEditorInput extends CompareEditorInput {
* Returns the label for the given input element.
*/
private String getVersionLabel(ITypedElement element) {
- if (element instanceof ResourceNode) {
- return Policy.bind("CVSCompareEditorInput.workspaceLabel"); //$NON-NLS-1$
- }
if (element instanceof ResourceEditionNode) {
ICVSRemoteResource edition = ((ResourceEditionNode)element).getRemoteResource();
ICVSResource resource = (ICVSResource)edition;
@@ -260,25 +211,6 @@ public class CVSCompareEditorInput extends CompareEditorInput {
ITypedElement right = this.right;
ITypedElement ancestor = this.ancestor;
- if (selection.size() == 1) {
- Object s = selection.getFirstElement();
- if (s instanceof ResourceDiffNode) {
- ResourceDiffNode node = (ResourceDiffNode)s;
- left = node.getLeft();
- right = node.getRight();
- ancestor = node.getAncestor();
- if (left == null) {
- cc.setLeftLabel(Policy.bind("CVSCompareEditorInput.noWorkspaceFile")); //$NON-NLS-1$
- cc.setLeftImage(right.getImage());
- }
- if (right == null) {
- cc.setRightLabel(Policy.bind("CVSCompareEditorInput.noRepositoryFile")); //$NON-NLS-1$
- cc.setRightImage(left.getImage());
- }
- if (ancestor == null) ancestor = this.ancestor;
- }
- }
-
if (left != null) {
cc.setLeftLabel(getLabel(left));
cc.setLeftImage(left.getImage());
@@ -342,11 +274,7 @@ public class CVSCompareEditorInput extends CompareEditorInput {
return null;
}
protected Object visit(Object data, int result, Object ancestor, Object left, Object right) {
- if (CVSCompareEditorInput.this.left instanceof CVSResourceNode) {
- return new ResourceDiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right);
- } else {
- return new DiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right);
- }
+ return new DiffNode((IDiffContainer) data, result, (ITypedElement)ancestor, (ITypedElement)left, (ITypedElement)right);
}
};
@@ -385,22 +313,10 @@ public class CVSCompareEditorInput extends CompareEditorInput {
* NODE_UNKNOWN if comparison was not possible.
*/
protected int teamEqual(Object left, Object right) {
-
// calculate the type for the left contribution
ICVSRemoteResource leftEdition = null;
if (left instanceof ResourceEditionNode) {
leftEdition = ((ResourceEditionNode)left).getRemoteResource();
- } else if (left instanceof ResourceNode) {
- IResource resource = ((ResourceNode)left).getResource();
- try {
- ICVSResource element = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if (resource.getType() == IResource.FILE) {
- if (((ICVSFile) element).isDirty()) return NODE_NOT_EQUAL;
- }
- leftEdition = CVSWorkspaceRoot.getRemoteResourceFor(resource);
- } catch(CVSException e) {
- return NODE_UNKNOWN;
- }
}
// calculate the type for the right contribution
@@ -451,6 +367,7 @@ public class CVSCompareEditorInput extends CompareEditorInput {
private boolean considerContentIfRevisionOrPathDiffers() {
return CVSUIPlugin.getPlugin().getPreferenceStore().getBoolean(ICVSUIConstants.PREF_CONSIDER_CONTENTS);
}
+
public Viewer createDiffViewer(Composite parent) {
Viewer viewer = super.createDiffViewer(parent);
viewer.addSelectionChangedListener(new ISelectionChangedListener() {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java
new file mode 100644
index 000000000..7f644d48e
--- /dev/null
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSLocalCompareEditorInput.java
@@ -0,0 +1,88 @@
+package org.eclipse.team.internal.ccvs.ui;
+
+/*
+ * (c) Copyright IBM Corp. 2000, 2002.
+ * All Rights Reserved.
+ */
+
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.team.core.TeamException;
+import org.eclipse.team.core.sync.IRemoteResource;
+import org.eclipse.team.core.sync.IRemoteSyncElement;
+import org.eclipse.team.internal.ccvs.core.CVSTag;
+import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
+import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.core.util.Assert;
+import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput;
+import org.eclipse.team.ui.sync.SyncView;
+
+public class CVSLocalCompareEditorInput extends CVSSyncCompareInput {
+ CVSTag[] tags;
+
+ public CVSLocalCompareEditorInput(IResource[] resources, CVSTag[] tags) {
+ super(resources);
+ Assert.isTrue(resources.length == tags.length);
+ this.tags = tags;
+ }
+
+ public CVSLocalCompareEditorInput(IResource[] resources, CVSTag tag) {
+ super(resources);
+ Assert.isTrue(tag != null);
+ this.tags = new CVSTag[] {tag};
+ }
+
+ public Viewer createDiffViewer(Composite parent) {
+ Viewer viewer = super.createDiffViewer(parent);
+ getViewer().syncModeChanged(SyncView.SYNC_COMPARE);
+ return viewer;
+ }
+
+ protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException {
+ IResource[] resources = getResources();
+ IRemoteSyncElement[] trees = new IRemoteSyncElement[resources.length];
+ int work = 100 * resources.length;
+ monitor.beginTask(null, work);
+ try {
+ for (int i = 0; i < trees.length; i++) {
+ IResource resource = resources[i];
+ CVSTag tag;
+ if(tags.length != resources.length) {
+ tag = tags[0];
+ } else {
+ tag = tags[i];
+ }
+ IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(resource, tag, Policy.subMonitorFor(monitor, 50));
+ trees[i] = new CVSRemoteSyncElement(false /* two-way */, resource, null, remote);
+ }
+ } finally {
+ monitor.done();
+ }
+ //getViewer().resetFilters();
+ return trees;
+ }
+
+ public String getTitle() {
+ return "CVS Compare [" + tags[0].getName() +"]";
+ }
+
+ public boolean isSaveNeeded() {
+ return false;
+ }
+
+ protected void contentsChanged(ICompareInput source) {
+ }
+
+ /*
+ * @see SyncCompareInput#getSyncGranularity()
+ */
+ protected int getSyncGranularity() {
+ // we have to perform content comparison since files in different branches
+ // may have different revisions but the same contents. Consider these files
+ // for merge purposes as equal.
+ return IRemoteSyncElement.GRANULARITY_CONTENTS;
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java
deleted file mode 100644
index a0b08fcbc..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSResourceNode.java
+++ /dev/null
@@ -1,101 +0,0 @@
-package org.eclipse.team.internal.ccvs.ui;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import java.io.ByteArrayInputStream;
-import java.util.ArrayList;
-
-import org.eclipse.compare.ResourceNode;
-import org.eclipse.compare.structuremergeviewer.IStructureComparator;
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.ICVSFile;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-
-/**
- * This class is a wrapper for a CVSResource. We use it instead of the standard
- * ResourceNode because it can more accurately get its local children taking
- * into account ignored resources, CVS/ directories, etc.
- */
-public class CVSResourceNode extends ResourceNode {
- ArrayList fChildren;
-
- public CVSResourceNode(IResource resource) {
- super(resource);
- }
-
- public Object[] getChildren() {
- if (fChildren == null) {
- fChildren= new ArrayList();
- IResource resource = getResource();
- if (resource instanceof IContainer) {
- try {
- ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer) resource);
- ICVSResource[] resources = cvsFolder.members(ICVSFolder.FILE_MEMBERS | ICVSFolder.FOLDER_MEMBERS);
- for (int i= 0; i < resources.length; i++) {
- IResource child;
- if (resources[i].isFolder()) {
- child = getFolder((IContainer)resource, resources[i].getName());
- } else {
- child = getFile((IContainer)resource, resources[i].getName());
- }
- if (child.exists()) {
- IStructureComparator childNode = createChild(child);
- if (childNode != null) {
- fChildren.add(childNode);
- }
- }
- }
- } catch (TeamException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- }
- }
- return fChildren.toArray();
- }
-
- private IResource getFile(IContainer container, String name) {
- if (container instanceof IProject) {
- return ((IProject)container).getFile(name);
- }
- if (container instanceof IFolder) {
- return ((IFolder)container).getFile(name);
- }
- return null;
- }
-
- private IResource getFolder(IContainer container, String name) {
- if (container instanceof IProject) {
- return ((IProject)container).getFolder(name);
- }
- if (container instanceof IFolder) {
- return ((IFolder)container).getFolder(name);
- }
- return null;
- }
-
- protected IStructureComparator createChild(IResource child) {
- return new CVSResourceNode(child);
- }
- /*
- * @see BufferedContent#setContent(byte[])
- */
- public void setContent(byte[] contents) {
- try {
- ((IFile)getResource()).setContents(new ByteArrayInputStream(contents), false, true, new NullProgressMonitor());
- } catch (CoreException e) {
- CVSUIPlugin.log(e.getStatus());
- }
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
index 836120b19..0f4208f79 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/CVSUIPlugin.java
@@ -267,6 +267,7 @@ public class CVSUIPlugin extends AbstractUIPlugin {
store.setDefault(ICVSUIConstants.PREF_DIRTY_FLAG, CVSDecoratorConfiguration.DEFAULT_DIRTY_FLAG);
store.setDefault(ICVSUIConstants.PREF_CALCULATE_DIRTY, true);
store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS, true);
+ store.setDefault(ICVSUIConstants.PREF_PROMPT_ON_SAVING_IN_SYNC, true);
// Forward the values to the CVS plugin
CVSProviderPlugin.getPlugin().setPruneEmptyDirectories(store.getBoolean(ICVSUIConstants.PREF_PRUNE_EMPTY_DIRECTORIES));
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
index ba4a674bc..da7dfe83a 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/ICVSUIConstants.java
@@ -55,6 +55,7 @@ public interface ICVSUIConstants {
public final String PREF_COMPRESSION_LEVEL = "pref_compression_level"; //$NON-NLS-1$
public final String PREF_TEXT_KSUBST = "pref_text_ksubst"; //$NON-NLS-1$
public final String PREF_PROMPT_ON_MIXED_TAGS = "pref_prompt_on_mixed_tags"; //$NON-NLS-1$
+ public final String PREF_PROMPT_ON_SAVING_IN_SYNC = "pref_prompt_on_saving_in_sync"; //$NON-NLS-1$
// console preferences
public final String PREF_CONSOLE_COMMAND_COLOR = "pref_console_command_color"; //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
index 0ad109242..8872b261f 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/BranchAction.java
@@ -14,6 +14,7 @@ import org.eclipse.jface.action.IAction;
import org.eclipse.jface.wizard.WizardDialog;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.wizards.BranchWizard;
/**
@@ -39,8 +40,13 @@ public class BranchAction extends CVSAction {
/*
* @see TeamAction#isEnabled()
*/
- protected boolean isEnabled() throws TeamException {
- return isSelectionNonOverlapping();
+ protected boolean isEnabled() {
+ try {
+ return isSelectionNonOverlapping();
+ } catch(TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return false;
+ }
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
index 55631f8f5..ff3af4653 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareRemoteResourcesAction.java
@@ -21,8 +21,8 @@ import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode;
import org.eclipse.team.ui.actions.TeamAction;
/**
- * This action is used for comparing two arbitrary resource
- * editions.
+ * This action is used for comparing two arbitrary remote resources. This is
+ * enabled in the repository explorer.
*/
public class CompareRemoteResourcesAction extends TeamAction {
/* (non-Javadoc)
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithBaseAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithBaseAction.java
deleted file mode 100644
index 404f6b5a5..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithBaseAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-package org.eclipse.team.internal.ccvs.ui.actions;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2002.
- * All Rights Reserved.
- */
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.compare.CompareUI;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.ICVSResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
-import org.eclipse.team.internal.ccvs.ui.CVSResourceNode;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode;
-import org.eclipse.team.ui.actions.TeamAction;
-
-/**
- * Action for container compare with base.
- */
-public class CompareWithBaseAction extends TeamAction {
- /*
- * Method declared on IActionDelegate.
- */
- public void run(IAction action) {
-
- // Setup the holders
- final IResource[] resource = new IResource[] {null};
- final ICVSRemoteResource[] remoteResource = new ICVSRemoteResource[] { null };
-
- // Fetch the remote tree
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- IResource[] resources = getSelectedResources();
- if (resources.length != 1) return;
- resource[0] = resources[0];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource[0]);
-
- monitor.beginTask(Policy.bind("CompareWithRemoteAction.fetching"), 100); //$NON-NLS-1$
- remoteResource[0] = CVSWorkspaceRoot.getRemoteTree(resource[0], CVSTag.BASE, Policy.subMonitorFor(monitor, 100));
- monitor.done();
-
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- }, Policy.bind("CompareWithRemoteAction.compare"), PROGRESS_DIALOG); //$NON-NLS-1$
-
- // Just to be safe...
- if (remoteResource[0] == null) {
- MessageDialog.openInformation(getShell(), Policy.bind("CompareWithRemoteAction.noRemote"), Policy.bind("CompareWithRemoteAction.noRemoteLong")); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // Open the compare view
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- CompareUI.openCompareEditor(new CVSCompareEditorInput(new CVSResourceNode(resource[0]), new ResourceEditionNode(remoteResource[0])));
- }
- }, Policy.bind("CompareWithRemoteAction.compare"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$
-
- }
-
- protected boolean isEnabled() {
- IResource[] resources = getSelectedResources();
- if (resources.length != 1) return false;
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(resources[0].getProject(), CVSProviderPlugin.getTypeId());
- if(provider==null) return false;
- return provider.hasRemote(resources[0]);
- }
-}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
index 7429b7682..d7a0a485d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithRemoteAction.java
@@ -5,103 +5,82 @@ package org.eclipse.team.internal.ccvs.ui.actions;
* All Rights Reserved.
*/
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.team.core.RepositoryProvider;
-import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.FolderSyncInfo;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
-import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
-import org.eclipse.team.internal.ccvs.ui.CVSResourceNode;
+import org.eclipse.team.internal.ccvs.ui.CVSLocalCompareEditorInput;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode;
-import org.eclipse.team.ui.actions.TeamAction;
-/**
- * Action for container compare with stream.
- */
-public class CompareWithRemoteAction extends TeamAction {
- /*
- * Method declared on IActionDelegate.
- */
+public class CompareWithRemoteAction extends CompareWithTagAction {
+
public void run(IAction action) {
-
- // Setup the holders
- final IResource[] resource = new IResource[] {null};
- final CVSTag[] tag = new CVSTag[] {null};
- final ICVSRemoteResource[] remoteResource = new ICVSRemoteResource[] { null };
-
- // Fetch the remote tree
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- IResource[] resources = getSelectedResources();
- if (resources.length != 1) return;
- resource[0] = resources[0];
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource[0]);
- if (cvsResource.isFolder()) {
- FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo();
- if (folderInfo!=null) {
- tag[0] = folderInfo.getTag();
- }
- } else {
- ResourceSyncInfo info = cvsResource.getSyncInfo();
- if (info!=null) {
- tag[0] = info.getTag();
- }
- }
- if (tag[0]==null) {
- if (cvsResource.getParent().isCVSFolder()) {
- tag[0] = cvsResource.getParent().getFolderSyncInfo().getTag();
- } else {
- // XXX: this is wrong :> should return an error
- tag[0] = CVSTag.DEFAULT;
- }
- }
-
- monitor.beginTask(Policy.bind("CompareWithRemoteAction.fetching"), 100); //$NON-NLS-1$
- remoteResource[0] = CVSWorkspaceRoot.getRemoteTree(resource[0], tag[0], Policy.subMonitorFor(monitor, 100));
- monitor.done();
-
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
+ IResource[] resources;
+ resources = getSelectedResources();
+ CVSTag[] tags = new CVSTag[resources.length];
+ try {
+ for (int i = 0; i < resources.length; i++) {
+ tags[i] = getTag(resources[i]);
+ }
+ CompareUI.openCompareEditor(new CVSLocalCompareEditorInput(resources, tags));
+ } catch(CVSException e) {
+ ErrorDialog.openError(getShell(), Policy.bind("CompareWithRemoteAction.compare"),
+ Policy.bind("CompareWithRemoteAction.noRemoteLong"), e.getStatus());
+ }
+ }
+
+ protected CVSTag getTag(IResource resource) throws CVSException {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
+ CVSTag tag = null;
+ if (cvsResource.isFolder()) {
+ FolderSyncInfo folderInfo = ((ICVSFolder)cvsResource).getFolderSyncInfo();
+ if (folderInfo!=null) {
+ tag = folderInfo.getTag();
+ }
+ } else {
+ ResourceSyncInfo info = cvsResource.getSyncInfo();
+ if (info != null) {
+ tag = info.getTag();
}
- }, Policy.bind("CompareWithRemoteAction.compare"), PROGRESS_DIALOG); //$NON-NLS-1$
-
- // Just to be safe...
- if (remoteResource[0] == null) {
- MessageDialog.openInformation(getShell(), Policy.bind("CompareWithRemoteAction.noRemote"), Policy.bind("CompareWithRemoteAction.noRemoteLong")); //$NON-NLS-1$ //$NON-NLS-2$
- return;
}
-
- // Open the compare view
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- CompareUI.openCompareEditor(new CVSCompareEditorInput(new CVSResourceNode(resource[0]), new ResourceEditionNode(remoteResource[0])));
+ if (tag==null) {
+ if (cvsResource.getParent().isCVSFolder()) {
+ tag = cvsResource.getParent().getFolderSyncInfo().getTag();
+ if(tag == null) {
+ tag = CVSTag.DEFAULT;
+ }
}
- }, Policy.bind("CompareWithRemoteAction.compare"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$
-
+ }
+ return tag;
}
protected boolean isEnabled() {
IResource[] resources = getSelectedResources();
- if (resources.length != 1) return false;
- CVSTeamProvider provider = (CVSTeamProvider)RepositoryProvider.getProvider(resources[0].getProject(), CVSProviderPlugin.getTypeId());
- if(provider==null) return false;
- return provider.hasRemote(resources[0]);
+ if(resources.length>0) {
+ for (int i = 0; i < resources.length; i++) {
+ IResource resource = resources[i];
+ if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
+ return false;
+ }
+ try {
+ if(getTag(resource) == null) {
+ return false;
+ }
+ } catch(CVSException e) {
+ return false;
+ }
+ }
+ return true;
+ }
+ return false;
}
-}
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
index d39cd68de..2c568dc85 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CompareWithTagAction.java
@@ -5,106 +5,50 @@ package org.eclipse.team.internal.ccvs.ui.actions;
* All Rights Reserved.
*/
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.compare.CompareUI;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
-import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
-import org.eclipse.team.internal.ccvs.ui.CVSCompareEditorInput;
-import org.eclipse.team.internal.ccvs.ui.CVSResourceNode;
+import org.eclipse.team.internal.ccvs.ui.CVSLocalCompareEditorInput;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.ResourceEditionNode;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
import org.eclipse.team.ui.actions.TeamAction;
-/**
- * Action for compare with tag.
- */
-public class CompareWithTagAction extends TeamAction {
- /*
- * Method declared on IActionDelegate.
- */
+public class CompareWithTagAction extends CVSAction {
+
public void run(IAction action) {
-
- // Setup the holders
- final CVSTag[] tag = new CVSTag[] {null};
+ final CVSTag tag;
final ICVSRemoteResource[] remoteResource = new ICVSRemoteResource[] { null };
final IResource[] resources = getSelectedResources();
-
-
- // Show a busy curesor while popping up the Tag selection dialog
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- IProject[] projects = new IProject[resources.length];
- for (int i = 0; i < resources.length; i++) {
- projects[i] = resources[i].getProject();
- }
- TagSelectionDialog dialog = new TagSelectionDialog(getShell(), projects, Policy.bind("CompareWithTagAction.message")); //$NON-NLS-1$
- dialog.setBlockOnOpen(true);
- int result = dialog.open();
- if (result == Dialog.CANCEL || dialog.getResult() == null) {
- return;
- }
- tag[0] = dialog.getResult();
- }
- }, Policy.bind("CompareWithTagAction.compare"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$
-
- if (tag[0] == null) return;
-
+ IProject[] projects = new IProject[resources.length];
for (int i = 0; i < resources.length; i++) {
- // Show a progress dialog while fethcing the remote tree
- final IResource resource = resources[i];
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- try {
- monitor.beginTask(Policy.bind("CompareWithTagAction.fetching", tag[0].getName()), 100); //$NON-NLS-1$
- remoteResource[0] = CVSWorkspaceRoot.getRemoteTree(resource, tag[0], Policy.subMonitorFor(monitor, 100));
- monitor.done();
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- }, Policy.bind("CompareWithTagAction.compare"), PROGRESS_DIALOG); //$NON-NLS-1$
-
- // Just to be safe...
- if (remoteResource[0] == null) {
- MessageDialog.openInformation(getShell(), Policy.bind("CompareWithTagAction.noRemote"), Policy.bind("CompareWithTagAction.noRemoteLong")); //$NON-NLS-1$ //$NON-NLS-2$
- return;
- }
-
- // Show a busy cursor while opening the compare view
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
- CompareUI.openCompareEditor(new CVSCompareEditorInput(new CVSResourceNode(resource), new ResourceEditionNode(remoteResource[0])));
- }
- }, Policy.bind("CompareWithTagAction.compare"), PROGRESS_BUSYCURSOR); //$NON-NLS-1$
+ projects[i] = resources[i].getProject();
+ }
+ TagSelectionDialog dialog = new TagSelectionDialog(getShell(), projects, Policy.bind("CompareWithTagAction.message")); //$NON-NLS-1$
+ dialog.setBlockOnOpen(true);
+ int result = dialog.open();
+ if (result == Dialog.CANCEL || dialog.getResult() == null) {
+ return;
}
+ tag = dialog.getResult();
+ if (tag == null) return;
+ CompareUI.openCompareEditor(new CVSLocalCompareEditorInput(resources, tag));
}
protected boolean isEnabled() {
- IResource[] resources = getSelectedResources();
- // allow operation for homegeneous multiple selections
- if(resources.length>0) {
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- }
- return true;
+ try {
+ return isSelectionNonOverlapping();
+ } catch(TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return false;
}
- return false;
}
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
index 1816d4ed3..47125f5d8 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ReplaceWithTagAction.java
@@ -27,6 +27,7 @@ import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.internal.ccvs.ui.PromptingDialog;
import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
@@ -36,7 +37,7 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
/**
* Action for replace with tag.
*/
-public class ReplaceWithTagAction extends TeamAction {
+public class ReplaceWithTagAction extends CVSAction {
/*
* Method declared on IActionDelegate.
*/
@@ -109,30 +110,13 @@ public class ReplaceWithTagAction extends TeamAction {
}, Policy.bind("ReplaceWithTagAction.replace"), this.PROGRESS_DIALOG); //$NON-NLS-1$
}
- protected boolean isEnabled() {
- IResource[] resources = getSelectedResources();
- // allow operation for homegeneous multiple selections
- if(resources.length>0) {
- int type = -1;
- for (int i = 0; i < resources.length; i++) {
- IResource resource = resources[i];
- if(type!=-1) {
- if(type!=resource.getType()) return false;
- }
- if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) {
- return false;
- }
- type = resource.getType();
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource);
- if(cvsResource.isFolder()) {
- if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false;
- } else {
- if( ! cvsResource.isManaged()) return false;
- }
- }
- return true;
+ protected boolean isEnabled() {
+ try {
+ return isSelectionNonOverlapping();
+ } catch(TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
+ return false;
}
- return false;
}
protected boolean equalTags(CVSTag tag1, CVSTag tag2) {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
index a532cc05f..f7a1ddf2c 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeEditorInput.java
@@ -135,5 +135,4 @@ public class MergeEditorInput extends CVSSyncCompareInput {
}
return super.collectResourceChanges(parent, tree, pm);
}
-
} \ No newline at end of file
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/ProjectElement.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/ProjectElement.java
index bd531ca18..6f225c599 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/ProjectElement.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/ProjectElement.java
@@ -29,6 +29,7 @@ public class ProjectElement implements IAdaptable, IWorkbenchAdapter {
if(includeHeadTag) {
return new Object[] { branches,
new TagElement(CVSTag.DEFAULT),
+ new TagElement(CVSTag.BASE),
versions
};
} else {
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 6c730c1e6..42c713d93 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -69,6 +69,7 @@ CVSCatchupReleaseViewer.workspaceFile=Workspace file: {0}
CVSCatchupReleaseViewer.showInHistory=Show in Resource History
CVSCatchupReleaseViewer.fileDecoration={0} ({1})
CVSCatchupReleaseViewer.folderDecoration={0} {1}
+CVSCatchupReleaseViewer.confirmMerge=C&onfirm Merge
CVSCompareEditorInput.branchLabel=<branch-{0}>
CVSCompareEditorInput.headLabel=<HEAD>
@@ -190,6 +191,12 @@ CVSRepositoryLocationPropertySource.port=Port
CVSRepositoryLocationPropertySource.root=Root
CVSRepositoryLocationPropertySource.method=Connection Method
+CVSSyncCompareInput.confirmMergeMessageTitle=Information
+CVSSyncCompareInput.confirmMergeMessage=Your changes have been saved. You can continue merging the file \
+ and saving the changes. When when you are finished \
+ select it from the Structure Compare and select 'Confirm Merge' to make this \
+ file an outgoing change.
+
CheckoutAsAction.checkoutFailed=Problems encountered performing checkout
CheckoutAsAction.enterProjectTitle=Check Out {0} As...
CheckoutAsAction.taskname=Checking out "{0}" from CVS as "{1}"
@@ -213,8 +220,8 @@ CompareWithRevisionAction.noRevisions=No Revisions
CompareWithRevisionAction.noRevisionsLong=The selected resource has no revisions to compare with.
CompareWithRevisionAction.fetching=Fetching revisions from repository...
-CompareWithTagAction.message=Compare with Tag
-CompareWithTagAction.replace=Error Comparing With Tag
+CompareWithTagAction.message=Compare with Branch or Version
+CompareWithTagAction.replace=Error Comparing With Branch or Version
CompareWithTagAction.noRemote=No Remote Resource
CompareWithTagAction.noRemoteLong=The selected tag has no remote resource to compare with.
CompareWithTagAction.fetching=Fetching resources with tag {0}...
@@ -366,7 +373,7 @@ RemoveRootAction.removeRoot=Error Discarding Location
RemoveBranchTagAction.removeTag=Discard Branch
RemoveModuleVersionAction.removeTag=Discard Version
-ReplaceWithTagAction.message=Replace with Tag
+ReplaceWithTagAction.message=Replace with Branch or Version
ReplaceWithTagAction.replace=Error Replacing With Tag
ReplaceWithTagAction.replacing=Replacing with tag {0}
ReplaceWithTagAction.mixingTags=You are mixing tags within a project. This may cause confusion \
@@ -563,7 +570,7 @@ Run_update_4=Run update
Do_nothing_5=Do nothing
Validate_Connection_on_Finish_7=Validate Location on Finish
-TagSelectionDialog.Select_a_Tag_1=Select a Tag:
+TagSelectionDialog.Select_a_Tag_1=Select a branch or version:
UpdateSyncAction.Conflicting_changes_found_1=Conflicting changes found
UpdateSyncAction.You_have_local_changes_you_are_about_to_overwrite_2=You have local changes you are about to overwrite
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
index 221e09a51..2565ef915 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java
@@ -6,9 +6,15 @@ package org.eclipse.team.internal.ccvs.ui.sync;
*/
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.structuremergeviewer.DiffContainer;
+import org.eclipse.compare.structuremergeviewer.DiffElement;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -23,6 +29,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.ImageData;
import org.eclipse.swt.graphics.Point;
@@ -66,6 +73,7 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
private IgnoreAction ignoreAction;
private HistoryAction showInHistory;
private OverrideUpdateMergeAction forceUpdateMergeAction;
+ private Action confirmMerge;
private static class DiffOverlayIcon extends OverlayIcon {
private static final int HEIGHT = 16;
@@ -218,6 +226,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
manager.add(updateAction);
forceUpdateAction.update(SyncView.SYNC_INCOMING);
manager.add(forceUpdateAction);
+ manager.add(new Separator());
+ manager.add(confirmMerge);
break;
case SyncView.SYNC_OUTGOING:
commitAction.update(SyncView.SYNC_OUTGOING);
@@ -226,6 +236,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
manager.add(forceCommitAction);
ignoreAction.update();
manager.add(ignoreAction);
+ manager.add(new Separator());
+ manager.add(confirmMerge);
break;
case SyncView.SYNC_BOTH:
commitAction.update(SyncView.SYNC_BOTH);
@@ -237,6 +249,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
manager.add(forceCommitAction);
forceUpdateAction.update(SyncView.SYNC_BOTH);
manager.add(forceUpdateAction);
+ manager.add(new Separator());
+ manager.add(confirmMerge);
break;
case SyncView.SYNC_MERGE:
updateMergeAction.update(SyncView.SYNC_INCOMING);
@@ -265,7 +279,73 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
// Show in history view
showInHistory = new HistoryAction(Policy.bind("CVSCatchupReleaseViewer.showInHistory")); //$NON-NLS-1$
- addSelectionChangedListener(showInHistory);
+ addSelectionChangedListener(showInHistory);
+
+ // confirm merge
+ confirmMerge = new Action(Policy.bind("CVSCatchupReleaseViewer.confirmMerge"), null) { //$NON-NLS-1$
+ public void run() {
+ ISelection s = getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return;
+ }
+ List needsMerge = new ArrayList();
+ for (Iterator it = ((IStructuredSelection)s).iterator(); it.hasNext();) {
+ final Object element = it.next();
+ if(element instanceof DiffElement) {
+ mergeRecursive((IDiffElement)element, needsMerge);
+ }
+ }
+ TeamFile[] files = (TeamFile[]) needsMerge.toArray(new TeamFile[needsMerge.size()]);
+ if(files.length != 0) {
+ try {
+ for (int i = 0; i < files.length; i++) {
+ TeamFile teamFile = (TeamFile)files[i];
+ CVSUIPlugin.getPlugin().getRepositoryManager().merged(new IRemoteSyncElement[] {teamFile.getMergeResource().getSyncElement()});
+ teamFile.merged();
+ }
+ } catch(TeamException e) {
+ ErrorDialog.openError(getControl().getShell(), null, null, e.getStatus());
+ }
+ }
+ refresh();
+ }
+
+ public boolean isEnabled() {
+ ISelection s = getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return false;
+ }
+ for (Iterator it = ((IStructuredSelection)s).iterator(); it.hasNext();) {
+ Object element = (Object) it.next();
+ if(element instanceof TeamFile) {
+ TeamFile file = (TeamFile)element;
+ if(file.hasBeenSaved()) {
+ int direction = file.getChangeDirection();
+ int type = file.getChangeType();
+ if(direction == IRemoteSyncElement.INCOMING ||
+ direction == IRemoteSyncElement.CONFLICTING) {
+ continue;
+ }
+ }
+ }
+ return false;
+ }
+ return true;
+ }
+ };
+ }
+
+ protected void mergeRecursive(IDiffElement element, List needsMerge) {
+ if(element instanceof DiffContainer) {
+ DiffContainer container = (DiffContainer)element;
+ IDiffElement[] children = container.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ mergeRecursive(children[i], needsMerge);
+ }
+ } else if(element instanceof TeamFile) {
+ TeamFile file = (TeamFile)element;
+ needsMerge.add(file);
+ }
}
/**
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
index 0053f240d..ebb1cb295 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncCompareInput.java
@@ -5,31 +5,27 @@ package org.eclipse.team.internal.ccvs.ui.sync;
* All Rights Reserved.
*/
-import java.lang.reflect.InvocationTargetException;
-
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.TreeItem;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.core.sync.IRemoteSyncElement;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
-import org.eclipse.team.internal.ccvs.core.ILogEntry;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
+import org.eclipse.team.internal.ccvs.ui.AvoidableMessageDialog;
import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
+import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants;
import org.eclipse.team.internal.ccvs.ui.Policy;
import org.eclipse.team.ui.sync.CatchupReleaseViewer;
import org.eclipse.team.ui.sync.ChangedTeamContainer;
-import org.eclipse.team.ui.sync.ITeamNode;
import org.eclipse.team.ui.sync.SyncCompareInput;
import org.eclipse.team.ui.sync.TeamFile;
@@ -147,19 +143,15 @@ public class CVSSyncCompareInput extends SyncCompareInput {
*/
protected void compareInputChanged(ICompareInput source) {
super.compareInputChanged(source);
- contentsChanged(source);
- }
- protected void contentsChanged(ICompareInput source) {
- // Mark the source as merged.
- if (source instanceof TeamFile) {
- IRemoteSyncElement element = ((TeamFile)source).getMergeResource().getSyncElement();
- try {
- CVSUIPlugin.getPlugin().getRepositoryManager().merged(new IRemoteSyncElement[] {element});
- } catch (TeamException e) {
- ErrorDialog.openError(getShell(), null, null, e.getStatus());
- }
+ updateView();
+
+ // prompt user with warning
+ Shell shell = getShell();
+ if(shell != null) {
+ promptForConfirmMerge(getShell());
}
}
+
/*
* @see SyncCompareInput#getSyncGranularity()
*/
@@ -188,4 +180,32 @@ public class CVSSyncCompareInput extends SyncCompareInput {
public IResource[] getResources() {
return resources;
}
+
+ /*
+ * Inform user that when changes are merged in the sync view that confirm
+ * merge should be called to finish the merge.
+ */
+ private void promptForConfirmMerge(final Shell shell) {
+ final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore();
+ if(!store.getBoolean(ICVSUIConstants.PREF_PROMPT_ON_SAVING_IN_SYNC)) {
+ return;
+ };
+
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ AvoidableMessageDialog dialog = new AvoidableMessageDialog(
+ shell,
+ Policy.bind("CVSSyncCompareInput.confirmMergeTitle"), //$NON-NLS-1$
+ null, // accept the default window icon
+ Policy.bind("CVSSyncCompareInput.confirmMergeMessage"), //$NON-NLS-1$
+ MessageDialog.INFORMATION,
+ new String[] {IDialogConstants.OK_LABEL},
+ 0);
+ dialog.open();
+ if(dialog.isDontShowAgain()) {
+ store.setValue(ICVSUIConstants.PREF_PROMPT_ON_SAVING_IN_SYNC, false);
+ }
+ }
+ });
+ }
}
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
index d83c66af5..fd732f15a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/messages.properties
@@ -9,6 +9,8 @@ CatchupReleaseViewer.showIncomingAction=Show Incoming
CatchupReleaseViewer.showInNavigator=&Show in Navigator
CatchupReleaseViewer.showOnlyConflictsAction=Show Only Conflicts
CatchupReleaseViewer.showOutgoingAction=Show Outgoing
+CatchupReleaseViewer.removeFromView=Remove &From View
+CatchupReleaseViewer.copyAllRightToLeft=Copy &All Changes From Right To Left
CheckInAction.checkin=Check In
CheckInAction.checkingIn=Checking In...
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/CatchupReleaseViewer.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/CatchupReleaseViewer.java
index 524575f61..25244c23a 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/CatchupReleaseViewer.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/CatchupReleaseViewer.java
@@ -5,17 +5,31 @@ package org.eclipse.team.ui.sync;
* All Rights Reserved.
*/
+import java.lang.reflect.InvocationTargetException;
import java.util.Iterator;
+import org.eclipse.compare.BufferedContent;
import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IEditableContent;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DiffContainer;
+import org.eclipse.compare.structuremergeviewer.DiffElement;
import org.eclipse.compare.structuremergeviewer.DiffTreeViewer;
import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.compare.structuremergeviewer.IDiffElement;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
@@ -41,6 +55,7 @@ import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewSite;
import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.internal.WorkbenchPlugin;
import org.eclipse.ui.views.navigator.ResourceNavigator;
import org.eclipse.ui.views.navigator.ShowInNavigatorAction;
@@ -146,12 +161,15 @@ public abstract class CatchupReleaseViewer extends DiffTreeViewer implements ISe
private FilterAction showOnlyConflicts;
private Action refresh;
private Action expandAll;
+ private Action removeFromTree;
private ShowInNavigatorAction showInNavigator;
private Action ignoreWhiteSpace;
// Property constant for diff mode kind
static final String PROP_KIND = "team.ui.PropKind"; //$NON-NLS-1$
+ private Action copyAllRightToLeft;
+
/**
* Creates a new catchup/release viewer.
@@ -185,9 +203,13 @@ public abstract class CatchupReleaseViewer extends DiffTreeViewer implements ISe
*/
protected void fillContextMenu(IMenuManager manager) {
manager.add(expandAll);
+ manager.add(removeFromTree);
if (showInNavigator != null) {
manager.add(showInNavigator);
}
+ if(syncMode == SyncView.SYNC_COMPARE) {
+ manager.add(copyAllRightToLeft);
+ }
}
/**
@@ -250,6 +272,67 @@ public abstract class CatchupReleaseViewer extends DiffTreeViewer implements ISe
}
};
+ removeFromTree = new Action(Policy.bind("CatchupReleaseViewer.removeFromView"), null) { //$NON-NLS-1$
+ public void run() {
+ ISelection s = getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return;
+ }
+ // mark all selected nodes as in sync
+ for (Iterator it = ((IStructuredSelection)s).iterator(); it.hasNext();) {
+ Object element = it.next();
+ setAllChildrenInSync((IDiffElement)element);
+ }
+ refresh();
+ }
+ };
+
+ copyAllRightToLeft = new Action(Policy.bind("CatchupReleaseViewer.copyAllRightToLeft"), null) { //$NON-NLS-1$
+ public void run() {
+ ISelection s = getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return;
+ }
+ for (Iterator it = ((IStructuredSelection)s).iterator(); it.hasNext();) {
+ final Object element = it.next();
+ if(element instanceof DiffElement) {
+ try {
+ new ProgressMonitorDialog(getTree().getShell()).run(false, false, new IRunnableWithProgress() {
+ public void run(IProgressMonitor monitor)
+ throws InvocationTargetException, InterruptedException {
+ try {
+ ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ try {
+ monitor.beginTask("Copying right contents into workspace", 100);
+ copyAllRightToLeft((DiffElement)element, Policy.subMonitorFor(monitor, 100));
+ } finally {
+ monitor.done();
+ }
+ }
+ }, monitor);
+ } catch(CoreException e) {
+ throw new InvocationTargetException(e);
+ }
+ }
+ });
+ } catch(InvocationTargetException e) {
+ ErrorDialog.openError(WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Policy.bind("CatchupReleaseViewer.errorCopyAllRightToLeft"), null, null); //$NON-NLS-1$
+ } catch(InterruptedException e) {
+ }
+ }
+ }
+ refresh();
+ }
+ public boolean isEnabled() {
+ ISelection s = getSelection();
+ if (!(s instanceof IStructuredSelection) || s.isEmpty()) {
+ return false;
+ }
+ return ((IStructuredSelection)s).size() == 1;
+ }
+ };
+
// Show in navigator
if (diffModel.getViewSite() != null) {
showInNavigator = new ShowInNavigatorAction(diffModel.getViewSite(), Policy.bind("CatchupReleaseViewer.showInNavigator")); //$NON-NLS-1$
@@ -292,6 +375,56 @@ public abstract class CatchupReleaseViewer extends DiffTreeViewer implements ISe
showOnlyConflicts.setChecked(false);
setFilters(CategoryFilter.SHOW_INCOMING| CategoryFilter.SHOW_CONFLICTS | CategoryFilter.SHOW_OUTGOING);
}
+
+ /**
+ * Method setAllChildrenInSync.
+ * @param iDiffElement
+ */
+ private void setAllChildrenInSync(IDiffElement element) {
+ if(element instanceof DiffContainer) {
+ DiffContainer container = (DiffContainer)element;
+ IDiffElement[] children = container.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ setAllChildrenInSync(children[i]);
+ }
+ }
+ ((DiffElement)element).setKind(IRemoteSyncElement.IN_SYNC);
+ }
+
+ protected void copyAllRightToLeft(IDiffElement element, IProgressMonitor monitor) throws CoreException {
+ if(element instanceof DiffContainer) {
+ DiffContainer container = (DiffContainer)element;
+ IDiffElement[] children = container.getChildren();
+ for (int i = 0; i < children.length; i++) {
+ copyAllRightToLeft(children[i], monitor);
+ }
+ } else if(element instanceof TeamFile) {
+ TeamFile file = (TeamFile)element;
+ try {
+ monitor = Policy.monitorFor(monitor);
+ monitor.beginTask(null, 1);
+ file.setProgressMonitor(Policy.subMonitorFor(monitor, 1));
+ if(file.getKind() != IRemoteSyncElement.IN_SYNC) {
+ if(file.getRight() == null || file.getLeft() == null) {
+ file.copy(false /* right to left */);
+ }
+ ITypedElement te = file.getLeft();
+ ITypedElement rte = file.getRight();
+ if(te instanceof IEditableContent) {
+ IEditableContent editable = (IEditableContent)te;
+ if(editable.isEditable()) {
+ if(rte instanceof BufferedContent) {
+ editable.setContent(((BufferedContent)rte).getContent());
+ }
+ }
+ }
+ }
+ file.setProgressMonitor(null);
+ } finally {
+ monitor.done();
+ }
+ }
+ }
/*
* Method declared on ContentViewer.
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncView.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncView.java
index a7fb4ba8c..e740db35b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncView.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/SyncView.java
@@ -60,6 +60,7 @@ public class SyncView extends ViewPart {
public static final int SYNC_OUTGOING = 2;
public static final int SYNC_BOTH = 3;
public static final int SYNC_MERGE = 4;
+ public static final int SYNC_COMPARE = 5;
// Titles cached for efficiency
private final String CATCHUP_TITLE = Policy.bind("SyncView.incomingModeTitle"); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
index f5a843cb4..01a9e2ea0 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/ui/sync/TeamFile.java
@@ -5,6 +5,7 @@ package org.eclipse.team.ui.sync;
* All Rights Reserved.
*/
+import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.lang.reflect.InvocationTargetException;
@@ -15,7 +16,9 @@ import org.eclipse.compare.structuremergeviewer.Differencer;
import org.eclipse.compare.structuremergeviewer.ICompareInput;
import org.eclipse.compare.structuremergeviewer.ICompareInputChangeListener;
import org.eclipse.compare.structuremergeviewer.IDiffContainer;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -28,6 +31,7 @@ import org.eclipse.jface.util.Assert;
import org.eclipse.jface.util.ListenerList;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Shell;
+import org.eclipse.team.core.TeamPlugin;
import org.eclipse.team.core.sync.IRemoteSyncElement;
import org.eclipse.team.internal.ui.Policy;
import org.eclipse.team.ui.TeamUIPlugin;
@@ -45,13 +49,20 @@ import org.eclipse.ui.internal.WorkbenchPlugin;
* and the ancestor is the common file.
*/
public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
+
private MergeResource mergeResource;
+
private Shell shell;
private ListenerList listeners;
+
private TypedBufferedContent localByteContents;
private TypedBufferedContent commonByteContents;
private TypedBufferedContent remoteByteContents;
+ boolean hasBeenSaved = false;
+
+ private IProgressMonitor monitor;
+
/**
* Creates a new file node.
*/
@@ -71,23 +82,14 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
return mergeResource.getLatestRevision();
}
};
- // don't allow editing of outgoing deletion content. To revert from the deletion the
- // user should use the appropriate sync view action.
- boolean outgoingDeletion = getChangeDirection() == IRemoteSyncElement.OUTGOING && getChangeType() == IRemoteSyncElement.DELETION;
- localByteContents = new TypedBufferedContent(this, !outgoingDeletion) {
- protected InputStream createStream() throws CoreException {
- return mergeResource.getLocalStream();
- }
- public void setContent(byte[] contents) {
- super.setContent(contents);
- merged();
- fireContentChanged();
- }
- public ITypedElement replace(ITypedElement child, ITypedElement other) {
- return null;
- }
- };
+
+ if(getResource().exists()) {
+ localByteContents = getLocalTypedContent();
+ } else {
+ localByteContents = null;
+ }
}
+
public void addCompareInputChangeListener(ICompareInputChangeListener l) {
if (listeners == null) {
listeners = new ListenerList();
@@ -95,13 +97,28 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
listeners.add(l);
}
+ /*
+ * @see ICompareInput#copy(boolean)
+ */
public void copy(boolean leftToRight) {
- if (!leftToRight) {
- // Catchup to all on the server
- localByteContents.setContent(remoteByteContents.getContent());
- merged();
+ if (leftToRight) return;
+ ITypedElement right = getRight();
+ ITypedElement left = getLeft();
+ try {
+ if (left == null) {
+ // Addition
+ saveChanges(new ByteArrayInputStream(new byte[0]));
+ localByteContents = getLocalTypedContent();
+ } else {
+ // deletion
+ saveChanges(null);
+ localByteContents = null;
+ }
+ } catch(CoreException e) {
+ TeamPlugin.log(e.getStatus());
}
}
+
public boolean equals(Object other) {
if (other != null && other.getClass() == getClass()) {
TeamFile file = (TeamFile) other;
@@ -109,17 +126,7 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
}
return super.equals(other);
}
- private void fireThreeWayInputChange() {
- if (listeners != null) {
- Object[] listenerArray = listeners.getListeners();
- // Iterate backwards so that the model gets updated last
- // it might want to remove the node completely, which might
- // upset other listeners.
- for (int i = listenerArray.length; --i >= 0;)
- ((ICompareInputChangeListener) listenerArray[i]).compareInputChanged(this);
- }
- }
-
+
/*
* @see ICompareInput#getAncestor
*/
@@ -143,6 +150,7 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
public int getChangeType() {
return getKind() & Differencer.CHANGE_TYPE_MASK;
}
+
/*
* @see ITypedInput#getType
*/
@@ -157,28 +165,17 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
return localByteContents;
}
- /**
- * Returns the team resource managed by this object.
- * Guaranteed to be non-null.
- */
- public MergeResource getMergeResource() {
- return mergeResource;
- }
-
/*
* @see ITypedInput#getName
*/
public String getName() {
- return mergeResource.getName();
- }
- /**
- * Returns the core resource managed by this object.
- * Guaranteed to be non-null.
- */
- public IResource getResource() {
- return mergeResource.getResource();
+ if(hasBeenSaved) {
+ return "<" + mergeResource.getName() + ">";
+ } else {
+ return mergeResource.getName();
+ }
}
-
+
/*
* @see ICompareInput#getRight
*/
@@ -189,6 +186,7 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
return null;
}
}
+
/*
* @see ITypedInput#getType
*/
@@ -197,84 +195,152 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
}
/*
+ * @see ICompareInput#removeCompareInputChangeListener(ICompareInputChangeListener)
+ */
+ public void removeCompareInputChangeListener(ICompareInputChangeListener listener) {
+ if (listeners != null) {
+ listeners.remove(listener);
+ }
+ }
+
+ /*
* @see Object
*/
public int hashCode() {
return mergeResource.hashCode();
}
+
+ /**
+ * Returns the team resource managed by this object.
+ * Guaranteed to be non-null.
+ */
+ public MergeResource getMergeResource() {
+ return mergeResource;
+ }
+
+ /**
+ * Returns the core resource managed by this object.
+ * Guaranteed to be non-null.
+ */
+ public IResource getResource() {
+ return mergeResource.getResource();
+ }
/**
- * The local resource has beed modified (i.e. merged).
+ * For debugging purposes only.
*/
- private void merged() {
- mergeResource.confirmMerge();
- try {
- // persist changes to disk (e.g. there is no buffering in the sync view).
- saveChanges();
-
- // calculate the new sync state based on the type of change that was merged. This
- // logic cannot be in the IRemoteSyncElement because there is no way to update the
- // base before calling getSyncKind() again.
- if(getChangeDirection()==INCOMING) {
- switch(getChangeType()) {
- case Differencer.ADDITION:
- case Differencer.CHANGE:
- setKind(OUTGOING | Differencer.CHANGE);
- break;
- case Differencer.DELETION:
- setKind(CONFLICTING | Differencer.CHANGE);
- }
- } else {
- setKind(OUTGOING | (getKind() & Differencer.CHANGE_TYPE_MASK));
- }
-
- // update the UI with the sync state change.
- fireThreeWayInputChange();
- } catch (CoreException e) {
- ErrorDialog.openError(WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Policy.bind("TeamFile.saveChanges", getName()), null, e.getStatus()); //$NON-NLS-1$
- }
+ public String toString() {
+ return "TeamFile(" + mergeResource.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
}
- public void removeCompareInputChangeListener(ICompareInputChangeListener listener) {
- if (listeners != null) {
- listeners.remove(listener);
- }
+ protected TypedBufferedContent getLocalTypedContent() {
+ // don't allow editing of outgoing deletion content. To revert from the deletion the
+ // user should use the appropriate sync view action.
+ boolean outgoingDeletion = getChangeDirection() == IRemoteSyncElement.OUTGOING && getChangeType() == IRemoteSyncElement.DELETION;
+ final String name = getName();
+ return new TypedBufferedContent(this, !outgoingDeletion) {
+ protected InputStream createStream() throws CoreException {
+ return mergeResource.getLocalStream();
+ }
+ public void setContent(byte[] contents) {
+ try {
+ if(contents==null) {
+ saveChanges(new ByteArrayInputStream(new byte[0]));
+ } else {
+ saveChanges(new ByteArrayInputStream(contents));
+ }
+ } catch(CoreException e) {
+ ErrorDialog.openError(WorkbenchPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell(), Policy.bind("TeamFile.saveChanges", name), null, e.getStatus()); //$NON-NLS-1$
+ }
+ fireContentChanged();
+ }
+ public ITypedElement replace(ITypedElement child, ITypedElement other) {
+ return null;
+ }
+ };
}
/**
- * Saves cached copy to disk and clears dirty flag.
+ * The local resource has beed modified (i.e. merged).
*/
- private void saveChanges() throws CoreException {
+ public void merged() {
+ // calculate the new sync state based on the type of change that was merged. This
+ // logic cannot be in the IRemoteSyncElement because there is no way to update the
+ // base before calling getSyncKind() again.
+ if(getChangeDirection()==INCOMING) {
+ switch(getChangeType()) {
+ case Differencer.ADDITION:
+ case Differencer.CHANGE:
+ setKind(OUTGOING | Differencer.CHANGE);
+ break;
+ case Differencer.DELETION:
+ setKind(CONFLICTING | Differencer.CHANGE);
+ }
+ } else {
+ setKind(OUTGOING | (getKind() & Differencer.CHANGE_TYPE_MASK));
+ }
+ hasBeenSaved = false;
+ }
+
+ public void setProgressMonitor(IProgressMonitor monitor) {
+ this.monitor = monitor;
+ }
+
+ private void saveChanges(final InputStream is) throws CoreException {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
try {
- InputStream stream = localByteContents.getContents();
IFile file = (IFile) getResource();
- if (stream != null) {
+ if (is != null) {
if (!file.exists()) {
- file.create(stream, false, monitor);
+ createParents(getParent(), getResource().getParent());
+ file.create(is, false, monitor);
} else {
- file.setContents(stream, false, true, monitor);
+ file.setContents(is, false, true, monitor);
}
} else {
file.delete(false, true, monitor);
+ deleteParents(getParent(), getResource().getParent());
}
+ hasBeenSaved = true;
+
+ // update the UI with the sync state change.
+ fireThreeWayInputChange();
} catch (CoreException e) {
throw new InvocationTargetException(e);
}
}
});
}
- /**
- * For debugging purposes only.
- */
- public String toString() {
- return "TeamFile(" + mergeResource.getName() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ private void createParents(IDiffContainer parentNode, IContainer parentFolder) throws CoreException {
+ if(!parentFolder.exists() && parentFolder.getType() != IResource.PROJECT) {
+ createParents(parentNode.getParent(), parentFolder.getParent());
+ ((IFolder)parentFolder).create(false /* force */, true, null);
+ if(parentNode instanceof ChangedTeamContainer) {
+ ((ChangedTeamContainer)parentNode).setKind(IRemoteSyncElement.IN_SYNC);
+ }
+ }
+ }
+
+ private void deleteParents(IDiffContainer parentNode, IContainer parentFolder) throws CoreException {
+ if(parentFolder.members().length == 0 && parentFolder.getType() != IResource.PROJECT) {
+ IContainer parent = parentFolder.getParent();
+ parentFolder.delete(false, null);
+ if(parentNode instanceof ChangedTeamContainer) {
+ ((ChangedTeamContainer)parentNode).setKind(IRemoteSyncElement.IN_SYNC);
+ }
+ deleteParents(parentNode.getParent(), parent);
+ }
}
private void run(IRunnableWithProgress runnable) throws CoreException {
try {
- new ProgressMonitorDialog(shell).run(false, false, runnable);
+ if(monitor == null) {
+ new ProgressMonitorDialog(shell).run(false, false, runnable);
+ } else {
+ runnable.run(monitor);
+ }
} catch (InvocationTargetException e) {
if (e.getTargetException() instanceof CoreException) {
throw (CoreException)e.getTargetException();
@@ -285,4 +351,19 @@ public class TeamFile extends DiffElement implements ICompareInput, ITeamNode {
// Ignore
}
}
+
+ private void fireThreeWayInputChange() {
+ if (listeners != null) {
+ Object[] listenerArray = listeners.getListeners();
+ // Iterate backwards so that the model gets updated last
+ // it might want to remove the node completely, which might
+ // upset other listeners.
+ for (int i = listenerArray.length; --i >= 0;)
+ ((ICompareInputChangeListener) listenerArray[i]).compareInputChanged(this);
+ }
+ }
+
+ public boolean hasBeenSaved() {
+ return hasBeenSaved;
+ }
}

Back to the top