From 1f18c75f2b546958aa5bf8bfbf7d350cd5802461 Mon Sep 17 00:00:00 2001 From: Jean Michel-Lemieux Date: Thu, 18 Apr 2002 21:22:22 +0000 Subject: Bug 7327: "Add to workspace" from history doesn't update revision # Bug 8904: tag information should be invalidated on modification Bug 9467: Exception creating branch on a file 9469: Only have partial support for branching on sub-folders/files - merge allowed on multiple selection, merge results show in same merge editor - merge allowed on all resource types - branching allowed on all resource types - replace with allowed on all resource types with multiple selection - warning dialog added when ever a user creates a project with mixed tags. It warns about the implied CVS behavior. Can be turned off. - tags only shown if different than parent tag (reduces tag clutter and makes it more obvious when a tag is different) - get revision for files allowed from history/replace/compare dialogs, to revert from a sticky revision use replace with tag and select the branch you are working on - CVS text decorations consolidated and as a result the text decorations in the sync view will follow the users preferences (except for the dirty flag which is not shown in the sync view) --- bundles/org.eclipse.team.cvs.ui/plugin.xml | 42 ++--- .../internal/ccvs/ui/CVSCompareRevisionsInput.java | 55 ++++++- .../internal/ccvs/ui/CVSDecorationRunnable.java | 171 ++++++++++++--------- .../eclipse/team/internal/ccvs/ui/CVSUIPlugin.java | 1 + .../eclipse/team/internal/ccvs/ui/HistoryView.java | 60 +++++--- .../team/internal/ccvs/ui/ICVSUIConstants.java | 1 + .../org/eclipse/team/internal/ccvs/ui/Policy.java | 7 + .../team/internal/ccvs/ui/RepositoryManager.java | 28 ++-- .../internal/ccvs/ui/TagConfigurationDialog.java | 2 +- .../internal/ccvs/ui/actions/BranchAction.java | 37 ++--- .../team/internal/ccvs/ui/actions/CVSAction.java | 132 ++++++++++++++++ .../team/internal/ccvs/ui/actions/MergeAction.java | 24 +-- .../ccvs/ui/actions/ReplaceWithTagAction.java | 21 +-- .../ccvs/ui/actions/ShowHistoryAction.java | 2 +- .../internal/ccvs/ui/merge/MergeEditorInput.java | 27 ++-- .../team/internal/ccvs/ui/merge/MergeWizard.java | 33 ++-- .../team/internal/ccvs/ui/messages.properties | 10 +- .../ccvs/ui/sync/CVSCatchupReleaseViewer.java | 50 +++--- .../internal/ccvs/ui/sync/CVSSyncCompareInput.java | 16 +- .../internal/ccvs/ui/wizards/BranchWizard.java | 45 ++---- 20 files changed, 470 insertions(+), 294 deletions(-) create mode 100644 bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml index 757998337..2d86c9ce0 100644 --- a/bundles/org.eclipse.team.cvs.ui/plugin.xml +++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml @@ -140,6 +140,20 @@ menubarPath="team.main/group3" id="org.eclipse.team.ccvs.ui.setKeywordSubstitution"> + + + + + + - - - - - - true if the current selection contains resource that don't + * have overlapping paths and false otherwise. + */ + protected boolean isSelectionNonOverlapping() throws TeamException { + IResource[] resources = getSelectedResources(); + // allow operation for non-overlapping resource selections + if(resources.length>0) { + List validPaths = new ArrayList(2); + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + + // only allow cvs resources to be selected + if(RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId()) == null) { + return false; + } + + // check if this resource overlaps other selections + IPath resourceFullPath = resource.getFullPath(); + if(!validPaths.isEmpty()) { + for (Iterator it = validPaths.iterator(); it.hasNext();) { + IPath path = (IPath) it.next(); + if(path.isPrefixOf(resourceFullPath) || + resourceFullPath.isPrefixOf(path)) { + return false; + } + } + } + validPaths.add(resourceFullPath); + + // ensure that resources are managed + ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); + if(cvsResource.isFolder()) { + if( ! ((ICVSFolder)cvsResource).isCVSFolder()) return false; + } else { + if( ! cvsResource.isManaged()) return false; + } + } + return true; + } + return false; + } + + /** + * Checks if a the resources' parent's tags are different then the given tag. + * Prompts the user that they are adding mixed tags and returns true if + * the user wants to continue or false otherwise. + */ + public static boolean checkForMixingTags(final Shell shell, IResource[] resources, final CVSTag tag) throws CVSException { + final IPreferenceStore store = CVSUIPlugin.getPlugin().getPreferenceStore(); + if(!store.getBoolean(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS)) { + return true; + }; + + final boolean[] result = new boolean[] { true }; + + for (int i = 0; i < resources.length; i++) { + IResource resource = resources[i]; + if (resource.getType() != IResource.PROJECT) { + ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resource); + CVSTag parentTag = cvsResource.getParent().getFolderSyncInfo().getTag(); + if (!CVSTag.equalTags(tag, parentTag)) { + shell.getDisplay().syncExec(new Runnable() { + public void run() { + AvoidableMessageDialog dialog = new AvoidableMessageDialog( + shell, + Policy.bind("CVSAction.mixingTagsTitle"), //$NON-NLS-1$ + null, // accept the default window icon + Policy.bind("CVSAction.mixingTags", tag.getName()), //$NON-NLS-1$ + MessageDialog.QUESTION, + new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, + 0); + + result[0] = dialog.open() == 0; + if(result[0] && dialog.isDontShowAgain()) { + store.setValue(ICVSUIConstants.PREF_PROMPT_ON_MIXED_TAGS, false); + } + } + }); + // only prompt once + break; + } + } + } + return result[0]; + } +} diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java index 5fe3662d7..1bd1c021f 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MergeAction.java @@ -1,19 +1,22 @@ +/******************************************************************************* + * Copyright (c) 2002 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v0.5 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v05.html + * + * Contributors: + * IBM - Initial implementation + ******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.actions; -/* - * (c) Copyright IBM Corp. 2000, 2002. - * All Rights Reserved. - */ - -import org.eclipse.core.resources.IProject; 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.merge.MergeWizard; -import org.eclipse.team.ui.actions.TeamAction; -public class MergeAction extends TeamAction { +public class MergeAction extends CVSAction { /* * @see IActionDelegate#run(IAction) */ @@ -22,7 +25,7 @@ public class MergeAction extends TeamAction { shell.getDisplay().syncExec(new Runnable() { public void run() { MergeWizard wizard = new MergeWizard(); - wizard.setProject(getSelectedProjects()[0]); + wizard.setResources(getSelectedResources()); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); } @@ -32,7 +35,6 @@ public class MergeAction extends TeamAction { * @see TeamAction#isEnabled() */ protected boolean isEnabled() throws TeamException { - IProject[] projects = getSelectedProjects(); - return projects.length == 1; + return isSelectionNonOverlapping(); } } 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 07df54e86..ca3b13148 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 @@ -85,24 +85,9 @@ public class ReplaceWithTagAction extends ReplaceWithAction { // For non-projects determine if the tag being loaded is the same as the resource's parent // If it's not, warn the user that they will have strange sync behavior try { - for (int i = 0; i < resources.length; i++) { - if (resources[i].getType() != IResource.PROJECT) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - CVSTag parentTag = cvsResource.getParent().getFolderSyncInfo().getTag(); - if ( ! equalTags(tag[0], parentTag)) { - final Shell shell = getShell(); - final boolean[] result = new boolean[] { false }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = MessageDialog.openQuestion(getShell(), Policy.bind("question"), Policy.bind("ReplaceWithTagAction.mixingTags")); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); - if (!result[0]) tag[0] = null; - // Only ask once! - return; - } - } - + if(!CVSAction.checkForMixingTags(getShell(), resources, tag[0])) { + tag[0] = null; + return; } } catch (CVSException e) { throw new InvocationTargetException(e); diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java index be8f69bf5..86e112f90 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/ShowHistoryAction.java @@ -66,7 +66,7 @@ public class ShowHistoryAction extends TeamAction { ICVSRemoteFile[] files = getSelectedRemoteFiles(); HistoryView view = HistoryView.openInActivePerspective(); if (view != null) { - view.showHistory(files[0]); + view.showHistory(files[0], null /* no current revision */); } } }, Policy.bind("ShowHistoryAction.showHistory"), this.PROGRESS_BUSYCURSOR); //$NON-NLS-1$ 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 3a8d9722d..b44bea365 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 @@ -6,35 +6,27 @@ package org.eclipse.team.internal.ccvs.ui.merge; */ import org.eclipse.compare.structuremergeviewer.ICompareInput; -import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Composite; -import org.eclipse.team.core.TeamPlugin; import org.eclipse.team.core.TeamException; -import org.eclipse.team.core.TeamPlugin; 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.CVSTeamProvider; 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.Policy; import org.eclipse.team.internal.ccvs.ui.sync.CVSSyncCompareInput; -import org.eclipse.team.ui.sync.CatchupReleaseViewer; import org.eclipse.team.ui.sync.SyncView; -import org.eclipse.team.ui.sync.TeamFile; public class MergeEditorInput extends CVSSyncCompareInput { - IProject project; CVSTag start; CVSTag end; - public MergeEditorInput(IProject project, CVSTag start, CVSTag end) { - super(new IResource[] {project}); - this.project = project; + public MergeEditorInput(IResource[] resources, CVSTag start, CVSTag end) { + super(resources); this.start = start; this.end = end; } @@ -44,14 +36,21 @@ public class MergeEditorInput extends CVSSyncCompareInput { return viewer; } protected IRemoteSyncElement[] createSyncElements(IProgressMonitor monitor) throws TeamException { - monitor.beginTask(null, 100); + IResource[] resources = getResources(); + IRemoteSyncElement[] trees = new IRemoteSyncElement[resources.length]; + int work = 100 * resources.length; + monitor.beginTask(null, work); try { - IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(project, start, Policy.subMonitorFor(monitor, 50)); - IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(project, end, Policy.subMonitorFor(monitor, 50)); - return new IRemoteSyncElement[] {new CVSRemoteSyncElement(true /*three way*/, project, base, remote)}; + for (int i = 0; i < trees.length; i++) { + IResource resource = resources[i]; + IRemoteResource base = CVSWorkspaceRoot.getRemoteTree(resource, start, Policy.subMonitorFor(monitor, 50)); + IRemoteResource remote = CVSWorkspaceRoot.getRemoteTree(resource, end, Policy.subMonitorFor(monitor, 50)); + trees[i] = new CVSRemoteSyncElement(true /*three way*/, resource, base, remote); + } } finally { monitor.done(); } + return trees; } public CVSTag getStartTag() { return start; diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java index 61542db5e..62e954198 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/merge/MergeWizard.java @@ -5,15 +5,9 @@ package org.eclipse.team.internal.ccvs.ui.merge; * All Rights Reserved. */ -import java.lang.reflect.InvocationTargetException; - import org.eclipse.compare.CompareUI; import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Status; -import org.eclipse.jface.dialogs.ProgressMonitorDialog; -import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.core.resources.IResource; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.jface.wizard.Wizard; import org.eclipse.team.internal.ccvs.core.CVSTag; @@ -24,17 +18,22 @@ import org.eclipse.team.internal.ccvs.ui.Policy; public class MergeWizard extends Wizard { MergeWizardStartPage startPage; MergeWizardEndPage endPage; - IProject project; + IResource[] resources; public void addPages() { - // Provide a progress monitor to indicate what is going on + + // when merging multiple resources, use the tags found on the first selected + // resource. This makes sense because you would typically merge resources that + // have a common context and are versioned and branched together. + IProject projectForTagRetrieval = resources[0].getProject(); + setWindowTitle(Policy.bind("MergeWizard.title")); //$NON-NLS-1$ ImageDescriptor mergeImage = CVSUIPlugin.getPlugin().getImageDescriptor(ICVSUIConstants.IMG_WIZBAN_MERGE); startPage = new MergeWizardStartPage("startPage", Policy.bind("MergeWizard.start"), mergeImage); //$NON-NLS-1$ //$NON-NLS-2$ - startPage.setProject(project); + startPage.setProject(projectForTagRetrieval); addPage(startPage); endPage = new MergeWizardEndPage("endPage", Policy.bind("MergeWizard.end"), mergeImage, startPage); //$NON-NLS-1$ //$NON-NLS-2$ - endPage.setProject(project); + endPage.setProject(projectForTagRetrieval); addPage(endPage); } @@ -43,11 +42,15 @@ public class MergeWizard extends Wizard { */ public boolean performFinish() { CVSTag startTag = startPage.getTag(); - CVSTag endTag = endPage.getTag(); - CompareUI.openCompareEditor(new MergeEditorInput(project, startTag, endTag)); + CVSTag endTag = endPage.getTag(); + CompareUI.openCompareEditor(new MergeEditorInput(resources, startTag, endTag)); return true; } - public void setProject(IProject project) { - this.project = project; + + /* + * Set the resources that should be merged. + */ + public void setResources(IResource[] resources) { + this.resources = resources; } } 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 3505b8788..82e79b631 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 @@ -31,12 +31,6 @@ AvoidableMessageDialog.dontShowAgain=Don't show this again BranchWizard.createABranch=Creates a new CVS Branch BranchWizard.title=Branch BranchWizard.errorTagging=Error Tagging Resources -BranchWizard.mixingTags=You are mixing tags within a project. This may cause confusion when \ - synchronizing with the repository. Synchronize uses the tag information associated with \ - each resource to determine the remote resource against which the local resource is compared. \ - For branching, this means that the part(s) of your project that you are branching will be \ - synchronized against branch tag ''{0}'' while others will be sychronized against ''HEAD'' \ - (or whichever tag is associated with the other local resources). Do you wish to continue? BranchWizardPage.pageDescription=Creates a new branch and a starting point version. BranchWizardPage.pageDescriptionVersion=Creates a new branch based on the version in the workspace. BranchWizardPage.specifyVersion=The version will provide a starting point for merging the branch back to the source branch. @@ -53,6 +47,9 @@ ConsolePreferencePage.errorColor=&Error: ConsolePreferencePage.font=Console font setting: ConsolePreferencePage.autoOpen=&Show CVS Console when there is output +CVSAction.mixingTagsTitle=Confirm Mixing Tags +CVSAction.mixingTags=You are mixing tags within a project. Beware that synchronization uses the tag information associated with each resource to determine the remote resource against which the local resource is compared. \n\nThis means that the part(s) of your project that you are replacing with another tag will be synchronized against the tag ''{0}'' while others resources in the project will be sychronized against another tag. \n\nDo you wish to continue? + CVSCatchupReleaseViewer.commit=&Commit CVSCatchupReleaseViewer.update=&Update from Repository CVSCatchupReleaseViewer.forceCommit=Override and Co&mmit @@ -298,6 +295,7 @@ HistoryFilterDialog.fromDate = &From date (M/D/Y) : HistoryFilterDialog.toDate = &To date (M/D/Y) : HistoryView.getContentsAction=&Get Contents +HistoryView.getRevisionAction=Get &Revision HistoryView.copy=&Copy HistoryView.revision=Revision HistoryView.tags=Tags 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 f9e3986ff..1d4c3bb81 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 @@ -5,8 +5,9 @@ package org.eclipse.team.internal.ccvs.ui.sync; * All Rights Reserved. */ +import java.util.Map; + import org.eclipse.compare.CompareConfiguration; -import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.NullProgressMonitor; @@ -29,15 +30,13 @@ 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.CVSException; -import org.eclipse.team.internal.ccvs.core.CVSTag; 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.ILogEntry; -import org.eclipse.team.internal.ccvs.core.client.Command.KSubstOption; 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.CVSDecoration; +import org.eclipse.team.internal.ccvs.ui.CVSDecorationRunnable; +import org.eclipse.team.internal.ccvs.ui.CVSDecoratorConfiguration; import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin; import org.eclipse.team.internal.ccvs.ui.HistoryView; import org.eclipse.team.internal.ccvs.ui.ICVSUIConstants; @@ -98,10 +97,16 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer { ICVSRemoteFile baseFile = (ICVSRemoteFile)remoteSyncElement.getBase(); // can only show history if remote exists or local has a base. + String currentRevision = null; + try { + currentRevision = baseFile!=null ? baseFile.getRevision(): null; + } catch(TeamException e) { + CVSUIPlugin.log(e.getStatus()); + } if(remoteFile!=null) { - view.showHistory(remoteFile); + view.showHistory(remoteFile, currentRevision); } else if(baseFile!=null) { - view.showHistory(baseFile); + view.showHistory(baseFile, currentRevision); } } public void selectionChanged(SelectionChangedEvent event) { @@ -176,31 +181,14 @@ public class CVSCatchupReleaseViewer extends CatchupReleaseViewer { } public String getText(Object element) { if (element instanceof ITeamNode) { - ITeamNode node = (ITeamNode)element; + ITeamNode node = (ITeamNode)element; IResource resource = node.getResource(); if (resource.exists()) { - try { - if (resource.getType() == IResource.FILE) { - ICVSFile cvsFile = CVSWorkspaceRoot.getCVSFileFor((IFile)resource); - ResourceSyncInfo info = cvsFile.getSyncInfo(); - KSubstOption option = info != null && info.getKeywordMode() != null ? - info.getKeywordMode() : - KSubstOption.fromFile((IFile)resource); - return Policy.bind("CVSCatchupReleaseViewer.fileDecoration", oldProvider.getText(element), option.getShortDisplayText()); //$NON-NLS-1$ - } else if (resource instanceof IContainer) { - ICVSFolder cvsFolder = CVSWorkspaceRoot.getCVSFolderFor((IContainer)resource); - FolderSyncInfo info = cvsFolder.getFolderSyncInfo(); - if (info != null) { - CVSTag tag = info.getTag(); - if (tag != null) { - return Policy.bind("CVSCatchupReleaseViewer.folderDecoration", oldProvider.getText(element), tag.getName()); //$NON-NLS-1$ - } - } - } - - } catch (CVSException e) { - ErrorDialog.openError(getControl().getShell(), null, null, e.getStatus()); - } + CVSDecoration decoration = CVSDecorationRunnable.computeTextLabelFor(resource, false /*don't show dirty*/); + String format = decoration.getFormat(); + Map bindings = decoration.getBindings(); + bindings.put(CVSDecoratorConfiguration.RESOURCE_NAME, oldProvider.getText(element)); + return CVSDecoratorConfiguration.bind(format, bindings); } } return oldProvider.getText(element); 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 8c395fe5b..226bad6d7 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 @@ -33,8 +33,8 @@ import org.eclipse.team.ui.sync.SyncCompareInput; import org.eclipse.team.ui.sync.TeamFile; public class CVSSyncCompareInput extends SyncCompareInput { - boolean dirty = false; - IResource[] resources; + private boolean dirty = false; + private IResource[] resources; /** * Creates a new catchup or release operation. @@ -148,7 +148,7 @@ public class CVSSyncCompareInput extends SyncCompareInput { } /* - * Helper method to get cvs elements from the selection in the sync editoru input + * Helper method to get cvs elements from the selection in the sync editor input */ public static CVSRemoteSyncElement getSyncElementFrom(Object node) { CVSRemoteSyncElement element = null; @@ -159,12 +159,20 @@ public class CVSSyncCompareInput extends SyncCompareInput { } return element; } + public void setDirty(boolean dirty) { this.dirty = dirty; super.setDirty(dirty); } + public boolean isDirty() { return dirty; } - + + /* + * Returns the resources in this input. + */ + public IResource[] getResources() { + return resources; + } } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java index 0d39d668c..e5b61a39b 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/wizards/BranchWizard.java @@ -20,10 +20,8 @@ import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.MultiStatus; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.dialogs.ErrorDialog; -import org.eclipse.jface.dialogs.MessageDialog; import org.eclipse.jface.operation.IRunnableWithProgress; import org.eclipse.jface.wizard.Wizard; -import org.eclipse.swt.widgets.Shell; import org.eclipse.team.core.RepositoryProvider; import org.eclipse.team.core.TeamException; import org.eclipse.team.internal.ccvs.core.CVSException; @@ -41,6 +39,7 @@ 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.internal.ccvs.ui.RepositoryManager; +import org.eclipse.team.internal.ccvs.ui.actions.CVSAction; public class BranchWizard extends Wizard { BranchWizardPage mainPage; @@ -86,7 +85,15 @@ public class BranchWizard extends Wizard { if (versionString != null) { rootVersionTag = new CVSTag(versionString, CVSTag.VERSION); } - + + // For non-projects determine if the tag being loaded is the same as the resource's parent + // If it's not, warn the user that they will have strange sync behavior + if (update) { + if(!CVSAction.checkForMixingTags(getShell(), resources, branchTag)) { + return; + } + } + RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager(); Hashtable table = getProviderMapping(resources); Set keySet = table.keySet(); @@ -97,31 +104,7 @@ public class BranchWizard extends Wizard { IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1000); CVSTeamProvider provider = (CVSTeamProvider)iterator.next(); List list = (List)table.get(provider); - IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); - // For non-projects determine if the tag being loaded is the same as the resource's parent - // If it's not, warn the user that they will have strange sync behavior - if (update) { - for (int i = 0; i < resources.length; i++) { - if (providerResources[i].getType() != IResource.PROJECT) { - ICVSResource cvsResource = CVSWorkspaceRoot.getCVSResourceFor(resources[i]); - CVSTag parentTag = cvsResource.getParent().getFolderSyncInfo().getTag(); - if (!equalTags(branchTag, parentTag)) { - final Shell shell = getShell(); - final boolean[] result = new boolean[] { false }; - shell.getDisplay().syncExec(new Runnable() { - public void run() { - result[0] = MessageDialog.openQuestion(getShell(), Policy.bind("question"), Policy.bind("BranchWizard.mixingTags", branchTag.getName())); //$NON-NLS-1$ //$NON-NLS-2$ - } - }); - if (!result[0]) return; - // Only ask once! - break; - } - } - - } - } - + IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]); ICVSRepositoryLocation root = provider.getCVSWorkspaceRoot().getRemoteLocation(); try { if (!areAllResourcesSticky(resources)) { @@ -221,10 +204,4 @@ public class BranchWizard extends Wizard { } return false; } - - protected boolean equalTags(CVSTag tag1, CVSTag tag2) { - if (tag1 == null) tag1 = CVSTag.DEFAULT; - if (tag2 == null) tag2 = CVSTag.DEFAULT; - return tag1.equals(tag2); - } } -- cgit v1.2.3