Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjames2002-06-01 00:12:42 +0000
committerjames2002-06-01 00:12:42 +0000
commite2cb8854123c1699c51f0f9fe4ee86a39254593e (patch)
tree893806062715b5a390966fca0d6b8d9154fcf5df
parent737618a48b886e26e3c6d84a540752bd132b3369 (diff)
downloadeclipse.platform.team-e2cb8854123c1699c51f0f9fe4ee86a39254593e.tar.gz
eclipse.platform.team-e2cb8854123c1699c51f0f9fe4ee86a39254593e.tar.xz
eclipse.platform.team-e2cb8854123c1699c51f0f9fe4ee86a39254593e.zip
16161: Synchronize doesn't commit outgoing additions
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties2
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSCatchupReleaseViewer.java58
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncSet.java28
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java8
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ForceCommitSyncAction.java35
5 files changed, 109 insertions, 22 deletions
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 3a3f08936..a82f0b94f 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
@@ -725,6 +725,6 @@ WorkbenchUserAuthenticator.The_operation_was_canceled_by_the_user_1=The operatio
CVSCatchupReleaseViewer.No_workspace_file_1=No workspace file
CVSPreferencesPage.Timeout_must_not_be_negative_1=Timeout must not be negative
CVSPreferencesPage.Timeout_must_be_a_number_2=Timeout must be a number
-CVSCatchupReleaseViewer.Select_&Outgoing_Additions_1=Select &Outgoing Additions
+CVSCatchupReleaseViewer.Select_&Outgoing_Additions_1=Select &New Resources
ForceCommitSyncAction.Outgoing_Changes_Not_Added_1=Outgoing Changes Not Added
ForceCommitSyncAction.You_have_chosen_to_commit_new_resources_which_have_not_been_added_to_version_control._Do_you_wish_to_add_them_to_version_control_now__2=You have chosen to commit new resources which have not been added to version control. Do you wish to add them to version control now?
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 5ac6fe34c..6cdcd2f8a 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
@@ -14,7 +14,9 @@ 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.DiffNode;
import org.eclipse.compare.structuremergeviewer.IDiffElement;
+import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -29,6 +31,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;
@@ -42,7 +45,9 @@ import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSTeamProvider;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSRemoteFile;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.ILogEntry;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
import org.eclipse.team.internal.ccvs.core.syncinfo.ResourceSyncInfo;
@@ -60,10 +65,12 @@ import org.eclipse.team.internal.ccvs.ui.merge.OverrideUpdateMergeAction;
import org.eclipse.team.internal.ccvs.ui.merge.UpdateMergeAction;
import org.eclipse.team.internal.ccvs.ui.merge.UpdateWithForcedJoinAction;
import org.eclipse.team.internal.ui.sync.CatchupReleaseViewer;
+import org.eclipse.team.internal.ui.sync.ChangedTeamContainer;
import org.eclipse.team.internal.ui.sync.ITeamNode;
import org.eclipse.team.internal.ui.sync.MergeResource;
import org.eclipse.team.internal.ui.sync.SyncView;
import org.eclipse.team.internal.ui.sync.TeamFile;
+import org.eclipse.team.internal.ui.sync.UnchangedTeamContainer;
import org.eclipse.team.ui.ISharedImages;
import org.eclipse.team.ui.TeamImages;
import org.eclipse.ui.help.WorkbenchHelp;
@@ -86,6 +93,8 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
private Action confirmMerge;
private AddSyncAction addAction;
+ private Action selectAdditions;
+
private static class DiffOverlayIcon extends OverlayIcon {
private static final int HEIGHT = 16;
private static final int WIDTH = 22;
@@ -289,6 +298,7 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
manager.add(ignoreAction);
manager.add(new Separator());
manager.add(confirmMerge);
+ manager.add(selectAdditions);
break;
case SyncView.SYNC_BOTH:
addAction.update(SyncView.SYNC_BOTH);
@@ -335,6 +345,50 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
showInHistory = new HistoryAction(Policy.bind("CVSCatchupReleaseViewer.showInHistory")); //$NON-NLS-1$
addSelectionChangedListener(showInHistory);
+ selectAdditions = new Action(Policy.bind("CVSCatchupReleaseViewer.Select_&Outgoing_Additions_1"), null) { //$NON-NLS-1$
+ public void run() {
+ List additions = new ArrayList();
+ DiffNode root = diffModel.getDiffRoot();
+ visit(root, additions);
+ setSelection(new StructuredSelection(additions));
+ }
+ private void visit(IDiffElement node, List additions) {
+ try {
+ if (node instanceof TeamFile) {
+ TeamFile file = (TeamFile)node;
+ if (file.getChangeDirection() == IRemoteSyncElement.OUTGOING) {
+ if (file.getChangeType() == IRemoteSyncElement.ADDITION) {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(file.getResource());
+ if (cvsResource.isManaged()) return;
+ additions.add(node);
+ }
+ }
+ return;
+ }
+ if (node instanceof ChangedTeamContainer) {
+ ChangedTeamContainer container = (ChangedTeamContainer)node;
+ if (container.getChangeDirection() == IRemoteSyncElement.OUTGOING) {
+ if (container.getChangeType() == IRemoteSyncElement.ADDITION) {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(container.getResource());
+ if (!((ICVSFolder)cvsResource).isCVSFolder()) {
+ additions.add(node);
+ }
+ }
+ }
+
+ }
+ if (node instanceof DiffContainer) {
+ IDiffElement[] children = ((DiffContainer)node).getChildren();
+ for (int i = 0; i < children.length; i++) {
+ visit(children[i], additions);
+ }
+ }
+ } catch (TeamException e) {
+ CVSUIPlugin.log(e.getStatus());
+ }
+ }
+ };
+
// confirm merge
confirmMerge = new Action(Policy.bind("CVSCatchupReleaseViewer.confirmMerge"), null) { //$NON-NLS-1$
public void run() {
@@ -391,13 +445,13 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer {
}
protected void mergeRecursive(IDiffElement element, List needsMerge) {
- if(element instanceof DiffContainer) {
+ 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) {
+ } 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/CVSSyncSet.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncSet.java
index 9b13e0632..fc908a0ef 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncSet.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CVSSyncSet.java
@@ -5,7 +5,9 @@ package org.eclipse.team.internal.ccvs.ui.sync;
* All Rights Reserved.
*/
+import java.util.ArrayList;
import java.util.Iterator;
+import java.util.List;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.sync.IRemoteSyncElement;
@@ -31,30 +33,32 @@ public class CVSSyncSet extends SyncSet {
super(nodeSelection);
}
- public boolean hasNonAddedChanges() throws CVSException {
+ public ITeamNode[] getNonAddedNodes() throws CVSException {
+ List result = new ArrayList();
for (Iterator it = getSyncSet().iterator(); it.hasNext();) {
ITeamNode node = (ITeamNode)it.next();
ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(node.getResource());
- if(cvsResource.isFolder()) {
- if(! ((ICVSFolder)cvsResource).isCVSFolder()) {
- return true;
+ if (cvsResource.isFolder()) {
+ if (!((ICVSFolder)cvsResource).isCVSFolder()) {
+ result.add(node);
}
- } else if(! cvsResource.isManaged()) {
- return true;
+ } else if (!cvsResource.isManaged()) {
+ result.add(node);
}
}
- return false;
+ return (ITeamNode[])result.toArray(new ITeamNode[result.size()]);
}
- public boolean hasCommitableChanges() throws CVSException {
+ public boolean hasNonAddedChanges() throws CVSException {
for (Iterator it = getSyncSet().iterator(); it.hasNext();) {
ITeamNode node = (ITeamNode)it.next();
- // outgoing file that is added is a commit candidate
- if (node.getChangeDirection() == IRemoteSyncElement.OUTGOING) {
- ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(node.getResource());
- if(!cvsResource.isFolder() && cvsResource.isManaged()) {
+ ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(node.getResource());
+ if (cvsResource.isFolder()) {
+ if (!((ICVSFolder)cvsResource).isCVSFolder()) {
return true;
}
+ } else if (!cvsResource.isManaged()) {
+ return true;
}
}
return false;
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
index a352b89a5..b83b873f4 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
@@ -31,18 +31,12 @@ public class CommitSyncAction extends ForceCommitSyncAction {
protected boolean isEnabled(ITeamNode node) {
// The commit action is enabled only for non-conflicting outgoing changes
CVSSyncSet set = new CVSSyncSet(new StructuredSelection(node));
- try {
- return set.hasCommitableChanges();
- } catch (CVSException e) {
- CVSUIPlugin.log(e.getStatus());
- return false;
- }
+ return set.hasOutgoingChanges();
}
protected void removeNonApplicableNodes(SyncSet set, int syncMode) {
set.removeConflictingNodes();
set.removeIncomingNodes();
- ((CVSSyncSet)set).removeNonAddedChanges();
}
/**
* @see MergeAction#getHelpContextID()
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ForceCommitSyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ForceCommitSyncAction.java
index 0f75ae6b8..87171513e 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ForceCommitSyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/ForceCommitSyncAction.java
@@ -33,6 +33,7 @@ import org.eclipse.jface.viewers.StructuredSelection;
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.CVSException;
import org.eclipse.team.internal.ccvs.core.ICVSFile;
import org.eclipse.team.internal.ccvs.core.resources.CVSRemoteSyncElement;
import org.eclipse.team.internal.ccvs.core.resources.CVSWorkspaceRoot;
@@ -76,6 +77,40 @@ public class ForceCommitSyncAction extends MergeAction {
if (changed.length == 0) {
return syncSet;
}
+
+ if (syncSet instanceof CVSSyncSet) {
+ CVSSyncSet cvsSyncSet = (CVSSyncSet)syncSet;
+ try {
+ if (cvsSyncSet.hasNonAddedChanges()) {
+ final int[] r = new int[1];
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ MessageDialog dialog = new MessageDialog(
+ getShell(),
+ Policy.bind("ForceCommitSyncAction.Outgoing_Changes_Not_Added_1"), //$NON-NLS-1$
+ null,
+ Policy.bind("ForceCommitSyncAction.You_have_chosen_to_commit_new_resources_which_have_not_been_added_to_version_control._Do_you_wish_to_add_them_to_version_control_now__2"), //$NON-NLS-1$
+ MessageDialog.QUESTION,
+ new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL},
+ 0);
+ r[0] = dialog.open();
+ }
+ });
+ switch (r[0]) {
+ case 0: // yes
+ break;
+ case 1: // no
+ cvsSyncSet.removeNonAddedChanges();
+ changed = syncSet.getChangedNodes();
+ break;
+ case 2: // cancel
+ return null;
+ }
+ }
+ } catch (CVSException e) {
+ CVSUIPlugin.log(e.getStatus());
+ }
+ }
List commits = new ArrayList();
List additions = new ArrayList();
List deletions = new ArrayList();

Back to the top