IDEA-67535 (Cannot move CVS branch) & IDEA-16311 (Misleading status message for CVS "Create Tag" command)

This commit is contained in:
Bas Leijdekkers
2012-10-04 22:30:46 +02:00
parent b3e3676de1
commit dc103c35ab
11 changed files with 132 additions and 185 deletions
@@ -315,6 +315,7 @@ label.add.file.confirmation.keyword.substitution=keyword substitution?
label.add.file.confirmation.keyword.substitution.to.cvs.with=to CVS with
label.add.file.confirmation.keyword.substitution.add.file=Add file
checkbox.create.tag.override.existing=Override existing (-F)
checkbox.create.tag.override.existing.branch=Override existing (-F -B)
label.delete.tag.tag.name=Tag name:
radio.corrupted.project.files.get.all.silently=Get all silently
radio.corrupted.project.files.skip.all.silently=Skip all silently
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.actions;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.config.CvsConfiguration;
@@ -24,9 +25,6 @@ import com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.CreateTagDialog;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.actions.VcsContext;
import com.intellij.CvsBundle;
import java.util.Arrays;
/**
* author: lesya
@@ -35,7 +33,7 @@ public class BranchAction extends ActionOnSelectedElement{
public BranchAction() {
super(true);
CvsActionVisibility visibility = getVisibility();
final CvsActionVisibility visibility = getVisibility();
visibility.canBePerformedOnSeveralFiles();
visibility.canBePerformedOnLocallyDeletedFile();
visibility.addCondition(FILES_EXIST_IN_CVS);
@@ -46,17 +44,14 @@ public class BranchAction extends ActionOnSelectedElement{
}
protected CvsHandler getCvsHandler(CvsContext context) {
FilePath[] selectedFiles = context.getSelectedFilePaths();
Project project = context.getProject();
CreateTagDialog createBranchDialog = new CreateTagDialog(Arrays.asList(selectedFiles),
project, false);
createBranchDialog.show();
if (!createBranchDialog.isOK()) return CvsHandler.NULL;
final FilePath[] selectedFiles = context.getSelectedFilePaths();
final Project project = context.getProject();
final CreateTagDialog dialog = new CreateTagDialog(selectedFiles, project, false);
dialog.show();
if (!dialog.isOK()) return CvsHandler.NULL;
return CommandCvsHandler.createBranchOrTagHandler(selectedFiles,
createBranchDialog.getTagName(),
createBranchDialog.switchToThisBranch(),
createBranchDialog.getOverrideExisting(),
false, CvsConfiguration.getInstance(context.getProject()).MAKE_NEW_FILES_READONLY, project);
final boolean makeNewFilesReadOnly = CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
return CommandCvsHandler.createBranchHandler(
selectedFiles, dialog.getTagName(), dialog.switchToThisBranch(), dialog.getOverrideExisting(), makeNewFilesReadOnly, project);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.actions;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.config.CvsConfiguration;
@@ -25,8 +26,6 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.actions.VcsContext;
import java.util.Arrays;
/**
* author: lesya
*/
@@ -34,27 +33,25 @@ public class CreateTagAction extends ActionOnSelectedElement{
public CreateTagAction() {
super(true);
CvsActionVisibility visibility = getVisibility();
final CvsActionVisibility visibility = getVisibility();
visibility.canBePerformedOnSeveralFiles();
visibility.canBePerformedOnLocallyDeletedFile();
visibility.addCondition(FILES_EXIST_IN_CVS);
}
protected String getTitle(VcsContext context) {
return com.intellij.CvsBundle.message("operation.name.create.tag");
return CvsBundle.message("operation.name.create.tag");
}
protected CvsHandler getCvsHandler(CvsContext context) {
FilePath[] selectedFiles = context.getSelectedFilePaths();
Project project = context.getProject();
CreateTagDialog dialog = new CreateTagDialog(Arrays.asList(selectedFiles),
project, true);
final FilePath[] selectedFiles = context.getSelectedFilePaths();
final Project project = context.getProject();
final CreateTagDialog dialog = new CreateTagDialog(selectedFiles, project, true);
dialog.show();
if (!dialog.isOK())
return CvsHandler.NULL;
return CommandCvsHandler.createBranchOrTagHandler(selectedFiles, dialog.getTagName(),
dialog.switchToThisBranch(), dialog.getOverrideExisting(),
true, CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY, project);
}
if (!dialog.isOK()) return CvsHandler.NULL;
final boolean makeNewFilesReadOnly = CvsConfiguration.getInstance(project).MAKE_NEW_FILES_READONLY;
return CommandCvsHandler.createTagHandler(
selectedFiles, dialog.getTagName(), dialog.switchToThisBranch(), dialog.getOverrideExisting(), makeNewFilesReadOnly, project);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.actions;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.actions.actionVisibility.CvsActionVisibility;
import com.intellij.cvsSupport2.actions.cvsContext.CvsContext;
import com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler;
@@ -23,9 +24,6 @@ import com.intellij.cvsSupport2.cvsoperations.cvsTagOrBranch.ui.DeleteTagDialog;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.actions.VcsContext;
import java.util.Arrays;
import java.util.Collection;
/**
* author: lesya
*/
@@ -33,27 +31,21 @@ public class DeleteTagAction extends ActionOnSelectedElement{
public DeleteTagAction() {
super(false);
CvsActionVisibility visibility = getVisibility();
final CvsActionVisibility visibility = getVisibility();
visibility.canBePerformedOnSeveralFiles();
visibility.addCondition(FILES_EXIST_IN_CVS);
}
protected String getTitle(VcsContext context) {
return com.intellij.CvsBundle.message("action.name.delete.tag");
return CvsBundle.message("action.name.delete.tag");
}
protected CvsHandler getCvsHandler(CvsContext context) {
DeleteTagDialog deleteTagDialog = new DeleteTagDialog(collectFiles(context),
context.getProject());
final FilePath[] selectedFiles = context.getSelectedFilePaths();
final DeleteTagDialog deleteTagDialog = new DeleteTagDialog(selectedFiles, context.getProject());
deleteTagDialog.show();
if (!deleteTagDialog.isOK())
return CvsHandler.NULL;
return CommandCvsHandler.createRemoveTagAction(context.getSelectedFiles(),
deleteTagDialog.getTagName());
}
if (!deleteTagDialog.isOK()) return CvsHandler.NULL;
private Collection<FilePath> collectFiles(VcsContext context) {
return Arrays.asList(context.getSelectedFilePaths());
return CommandCvsHandler.createRemoveTagAction(selectedFiles, deleteTagDialog.getTagName());
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -54,7 +54,7 @@ import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.VcsConfiguration;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.update.UpdatedFiles;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VfsUtilCore;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.Consumer;
import org.jetbrains.annotations.NotNull;
@@ -71,6 +71,7 @@ import java.util.*;
* @author lesya
*/
public class CommandCvsHandler extends CvsHandler {
private static final Logger LOG = Logger.getInstance("#com.intellij.cvsSupport2.cvshandlers.CommandCvsHandler");
protected final CvsOperation myCvsOperation;
@@ -161,16 +162,25 @@ public class CommandCvsHandler extends CvsHandler {
return new UpdateHandler(files, updateSettings, project, updatedFiles);
}
public static CvsHandler createBranchOrTagHandler(FilePath[] selectedFiles, String branchName,
boolean switchToThisAction, boolean overrideExisting,
boolean isTag, boolean makeNewFilesReadOnly, Project project) {
public static CvsHandler createTagHandler(FilePath[] selectedFiles, String tagName, boolean switchToThisTag,
boolean overrideExisting, boolean makeNewFilesReadOnly, Project project) {
final CompositeOperation operation = new CompositeOperation();
operation.addOperation(new BranchOperation(selectedFiles, branchName, overrideExisting, isTag));
if (switchToThisAction) {
operation.addOperation(new TagOperation(selectedFiles, tagName, false, overrideExisting));
if (switchToThisTag) {
operation.addOperation(new UpdateOperation(selectedFiles, tagName, makeNewFilesReadOnly, project));
}
return new CommandCvsHandler(CvsBundle.message("operation.name.create.tag"), operation,
FileSetToBeUpdated.selectedFiles(selectedFiles));
}
public static CvsHandler createBranchHandler(FilePath[] selectedFiles, String branchName, boolean switchToThisBranch,
boolean overrideExisting, boolean makeNewFilesReadOnly, Project project) {
final CompositeOperation operation = new CompositeOperation();
operation.addOperation(new BranchOperation(selectedFiles, branchName, overrideExisting));
if (switchToThisBranch) {
operation.addOperation(new UpdateOperation(selectedFiles, branchName, makeNewFilesReadOnly, project));
}
return new CommandCvsHandler(isTag ? CvsBundle.message("operation.name.create.tag")
: CvsBundle.message("operation.name.create.branch"), operation,
return new CommandCvsHandler(CvsBundle.message("operation.name.create.branch"), operation,
FileSetToBeUpdated.selectedFiles(selectedFiles));
}
@@ -204,7 +214,8 @@ public class CommandCvsHandler extends CvsHandler {
final CommandCvsHandler result = new CommandCvsHandler(title, operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
if (tagFilesAfterCommit) {
result.addOperation(new TagOperation(selectedFiles, tagName, CvsConfiguration.getInstance(project).OVERRIDE_EXISTING_TAG_FOR_PROJECT));
result.addOperation(new TagOperation(selectedFiles, tagName, false,
CvsConfiguration.getInstance(project).OVERRIDE_EXISTING_TAG_FOR_PROJECT));
}
return result;
@@ -225,7 +236,7 @@ public class CommandCvsHandler extends CvsHandler {
operation.addFile(info.getFile(), info.getKeywordSubstitution());
}
return new CommandCvsHandler(CvsBundle.message("action.name.add"), operation,
FileSetToBeUpdated.selectedFiles(VfsUtil.toVirtualFileArray(addedFiles)),
FileSetToBeUpdated.selectedFiles(VfsUtilCore.toVirtualFileArray(addedFiles)),
VcsConfiguration.getInstance(project).getAddRemoveOption());
}
@@ -246,13 +257,13 @@ public class CommandCvsHandler extends CvsHandler {
final VirtualFile cvsAdminDirectory = CvsVfsUtil.findFileByIoFile(new File(parentFile, CvsUtil.CVS));
if (cvsAdminDirectory != null) result.add(cvsAdminDirectory);
}
return VfsUtil.toVirtualFileArray(result);
return VfsUtilCore.toVirtualFileArray(result);
}
public static CvsHandler createRestoreFileHandler(final VirtualFile parent,
String name,
boolean makeNewFilesReadOnly) {
final File ioFile = new File(VfsUtil.virtualToIoFile(parent), name);
final File ioFile = new File(VfsUtilCore.virtualToIoFile(parent), name);
final Entry entry = CvsEntriesManager.getInstance().getEntryFor(parent, name);
@@ -267,7 +278,7 @@ public class CommandCvsHandler extends CvsHandler {
@Override
public void run() {
final List<VcsException> errors = cvsHandler.getErrors();
if (errors != null && (! errors.isEmpty())) return;
if (errors != null && !errors.isEmpty()) return;
if (entry != null) {
entry.setRevision(revision);
@@ -299,7 +310,7 @@ public class CommandCvsHandler extends CvsHandler {
return new CommandCvsHandler(CvsBundle.message("operation.name.unedit"), operation, FileSetToBeUpdated.selectedFiles(selectedFiles));
}
public static CvsHandler createRemoveTagAction(VirtualFile[] selectedFiles, String tagName) {
public static CvsHandler createRemoveTagAction(FilePath[] selectedFiles, String tagName) {
return new CommandCvsHandler(CvsBundle.message("action.name.delete.tag"), new TagOperation(selectedFiles, tagName, true, false),
FileSetToBeUpdated.EMPTY);
}
@@ -434,9 +445,8 @@ public class CommandCvsHandler extends CvsHandler {
null);
compositeOperation.addOperation(checkoutFileOperation);
}
return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"), compositeOperation, FileSetToBeUpdated.allFiles(), true);
return new CommandCvsHandler(CvsBundle.message("action.name.get.file.from.repository"),
compositeOperation, FileSetToBeUpdated.allFiles(), true);
}
private static String getAlternativeCheckoutPath(CvsLightweightFile cvsLightweightFile, File workingDirectory) {
@@ -78,6 +78,7 @@ public class CvsMessagesTranslator implements IFileInfoListener, IMessageListene
new CvsMessagePattern("cvs server: cannot make path to *: Permission denied"),
new CvsMessagePattern("cvs server: cannot find module `*' - ignored"),
new CvsMessagePattern("W * : * already exists on version * : NOT MOVING tag to version *"),
new CvsMessagePattern("W * : * already exists on branch * : NOT MOVING tag to branch *"),
new CvsMessagePattern(new String[]{"cvs server: ", "*", " added independently by second party"}, 2),
new CvsMessagePattern("cvs server: failed to create lock directory for `*' (*#cvs.lock): No such file or directory"),
new CvsMessagePattern("cvs server: failed to obtain dir lock in repository `*'"),
@@ -145,15 +146,12 @@ public class CvsMessagesTranslator implements IFileInfoListener, IMessageListene
myListener.addFileMessage(message, myCvsFileSystem);
return;
}
if (isMessage(message)) {
lastMessage = MessageType.MESSAGE;
myListener.addMessage(message);
return;
}
if (!error) return;
final CvsMessagePattern errorMessagePattern = getErrorMessagePattern(message, ERRORS_PATTERNS);
if (errorMessagePattern != null) {
if (message.contains(CORRECT_ABOVE_ERRORS_FIRST_PREFIX)) {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,25 +29,25 @@ public class BranchOperation extends CvsOperationOnFiles{
private final String myBranchName;
private final boolean myOverrideExisting;
private final boolean myIsTag;
public BranchOperation(FilePath[] files, String branchName,
boolean overrideExisting, boolean isTag) {
public BranchOperation(FilePath[] files, String branchName, boolean overrideExisting) {
myBranchName = branchName;
myOverrideExisting = overrideExisting;
myIsTag = isTag;
for (int i = 0; i < files.length; i++) {
addFile(files[i].getIOFile());
for (FilePath file : files) {
addFile(file.getIOFile());
}
}
protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
TagCommand result = new TagCommand();
result.setMakeBranchTag(!myIsTag);
result.setTag(myBranchName);
result.setOverrideExistingTag(myOverrideExisting);
addFilesToCommand(root, result);
return result;
final TagCommand tagCommand = new TagCommand();
tagCommand.setMakeBranchTag(true);
tagCommand.setTag(myBranchName);
tagCommand.setOverrideExistingTag(myOverrideExisting);
if (myOverrideExisting) {
tagCommand.setAllowMoveDeleteBranchTag(true);
}
addFilesToCommand(root, tagCommand);
return tagCommand;
}
protected String getOperationName() {
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2009 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,7 +19,6 @@ import com.intellij.cvsSupport2.connections.CvsRootProvider;
import com.intellij.cvsSupport2.cvsoperations.common.CvsExecutionEnvironment;
import com.intellij.cvsSupport2.cvsoperations.common.CvsOperationOnFiles;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vfs.VirtualFile;
import org.netbeans.lib.cvsclient.command.Command;
import org.netbeans.lib.cvsclient.command.tag.TagCommand;
@@ -27,30 +26,22 @@ import org.netbeans.lib.cvsclient.command.tag.TagCommand;
* author: lesya
*/
public class TagOperation extends CvsOperationOnFiles{
private final String myTag;
private final boolean myRemoveTag;
private final boolean myOverrideExisting;
public TagOperation(VirtualFile[] files, String tag, boolean removeTag, boolean overrideExisting) {
for (VirtualFile file : files) {
addFile(file);
}
myRemoveTag = removeTag;
myTag = tag;
myOverrideExisting = overrideExisting;
}
public TagOperation(FilePath[] files, String tag, boolean overrideExisting) {
public TagOperation(FilePath[] files, String tag, boolean removeTag, boolean overrideExisting) {
for (FilePath file : files) {
addFile(file.getIOFile());
}
myRemoveTag = false;
myTag = tag;
myRemoveTag = removeTag;
myOverrideExisting = overrideExisting;
}
protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
TagCommand tagCommand = new TagCommand();
final TagCommand tagCommand = new TagCommand();
addFilesToCommand(root, tagCommand);
tagCommand.setTag(myTag);
tagCommand.setDeleteTag(myRemoveTag);
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,7 +32,10 @@ import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.VcsException;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.util.containers.HashSet;
import org.jetbrains.annotations.Nullable;
import org.netbeans.lib.cvsclient.command.log.LogInformation;
@@ -57,7 +60,7 @@ public class TagsHelper {
try {
final CvsCommandOperation operation = tagsProvider.getOperation();
if (operation == null) return null;
BranchesProvider branchesProvider = getBranchesProvider(operation, project);
final BranchesProvider branchesProvider = getBranchesProvider(operation, project);
return chooseFrom(branchesProvider.getAllBranches(), branchesProvider.getAllRevisions());
}
catch (VcsException e) {
@@ -81,26 +84,22 @@ public class TagsHelper {
field.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String branchName = TagsHelper.chooseBranch(files, project);
final String branchName = chooseBranch(files, project);
if (branchName != null) field.setText(branchName);
}
});
}
public static Collection<String> getAllBranches(List<LogInformation> log) {
HashSet<String> branches = new HashSet<String>();
final HashSet<String> branches = new HashSet<String>();
for (final LogInformation logInformation : log) {
collectBranches(logInformation, branches);
}
return branches;
}
private static void collectBranches(LogInformation logInformation,
HashSet<String> branches) {
List<SymbolicName> allSymbolicNames = logInformation.getAllSymbolicNames();
private static void collectBranches(LogInformation logInformation, HashSet<String> branches) {
final List<SymbolicName> allSymbolicNames = logInformation.getAllSymbolicNames();
for (final SymbolicName symbolicName : allSymbolicNames) {
branches.add(symbolicName.getName());
}
@@ -114,23 +113,32 @@ public class TagsHelper {
private static BranchesProvider getBranchesProvider(CvsOperation operation, Project project) throws VcsException {
LOG.assertTrue(operation instanceof BranchesProvider);
CvsOperationExecutor executor = new CvsOperationExecutor(true, project,
new ModalityContextImpl(ModalityState.defaultModalityState()
));
CommandCvsHandler handler = new CommandCvsHandler(CvsBundle.message("load.tags.operation.name"), operation, true);
final CvsOperationExecutor executor =
new CvsOperationExecutor(true, project, new ModalityContextImpl(ModalityState.defaultModalityState()));
final CommandCvsHandler handler = new CommandCvsHandler(CvsBundle.message("load.tags.operation.name"), operation, true);
executor.performActionSync(handler, CvsOperationExecutorCallback.EMPTY);
CvsResult executionResult = executor.getResult();
final CvsResult executionResult = executor.getResult();
if (executionResult.hasErrors()) throw executionResult.composeError();
return (BranchesProvider)operation;
}
private static Collection<String> collectAllBranches(Collection<FilePath> files,
Project project) throws VcsException {
ArrayList<String> result = new ArrayList<String>();
private static Collection<String> collectAllBranches(Collection<FilePath> files, Project project) throws VcsException {
if (files.isEmpty()) {
return result;
return Collections.emptyList();
}
return getBranchesProvider(new LogOperation(files), project).getAllBranches();
final Collection<FilePath> roots = new HashSet<FilePath>();
final Set<VirtualFile> seen = new HashSet<VirtualFile>();
for(FilePath filePath : files) {
final VirtualFile root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(filePath);
if (root == null || !seen.add(root)) {
continue;
}
roots.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
}
if (roots.isEmpty()) {
return Collections.emptyList();
}
return getBranchesProvider(new LogOperation(roots), project).getAllBranches();
}
private static void showErrorMessage(VcsException e1) {
@@ -141,8 +149,7 @@ public class TagsHelper {
@Nullable
private static String chooseFrom(Collection<String> tags, Collection<CvsRevisionNumber> revisions) {
if (tags == null) return null;
Collection<String> revisionsNames = collectSortedRevisionsNames(revisions);
final Collection<String> revisionsNames = collectSortedRevisionsNames(revisions);
if (tags.isEmpty() && revisionsNames.isEmpty()) {
Messages.showMessageDialog(CvsBundle.message("message.no.tags.found"), CvsBundle.message("operation.name.select.tag"),
Messages.getInformationIcon());
@@ -153,19 +160,18 @@ public class TagsHelper {
if (selectTagDialog.isOK()) {
return selectTagDialog.getTag();
}
return null;
}
private static Collection<String> collectSortedTags(Collection<String> tags) {
ArrayList<String> result = new ArrayList<String>(tags);
final ArrayList<String> result = new ArrayList<String>(tags);
Collections.sort(result);
return result;
}
private static Collection<String> collectSortedRevisionsNames(Collection<CvsRevisionNumber> revisions) {
if (revisions == null) return new ArrayList<String>();
ArrayList<CvsRevisionNumber> list = new ArrayList<CvsRevisionNumber>(revisions);
final ArrayList<CvsRevisionNumber> list = new ArrayList<CvsRevisionNumber>(revisions);
Collections.sort(list, new Comparator<CvsRevisionNumber>() {
@Override
public int compare(CvsRevisionNumber o, CvsRevisionNumber o1) {
@@ -173,7 +179,7 @@ public class TagsHelper {
}
});
ArrayList<String> result = new ArrayList<String>();
final ArrayList<String> result = new ArrayList<String>();
for (final CvsRevisionNumber aList : list) {
result.add(aList.toString());
}
@@ -181,13 +187,10 @@ public class TagsHelper {
}
public static Collection<CvsRevisionNumber> getAllRevisions(List<LogInformation> logs) {
ArrayList<CvsRevisionNumber> result = new ArrayList<CvsRevisionNumber>();
final ArrayList<CvsRevisionNumber> result = new ArrayList<CvsRevisionNumber>();
for (final LogInformation log : logs) {
collectRevisions(log, result);
}
return result;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,15 +21,9 @@ import com.intellij.cvsSupport2.ui.experts.importToCvs.CvsFieldValidator;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.FilePath;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
import com.intellij.openapi.vcs.actions.VcsContextFactory;
import com.intellij.openapi.vfs.VirtualFile;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.HashSet;
import java.util.Arrays;
/**
* author: lesya
@@ -43,38 +37,23 @@ public class CreateTagDialog extends CvsTagDialog {
private JLabel myTagOrBranchLabel;
private JLabel myErrorLabel;
public CreateTagDialog(final Collection<FilePath> files, final Project project, boolean isTag) {
myTagOrBranchLabel.setText(isTag ? CvsBundle.message("label.tag.name") : CvsBundle.message("label.branch.name"));
mySwitchToThisTag.setText(
isTag ? CvsBundle.message("checkbox.switch.to.this.tag") : CvsBundle.message("checkbox.switch.to.this.branch"));
myTagName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
String branchName = TagsHelper.chooseBranch(collectVcsRoots(project, files), project);
if (branchName != null)
myTagName.setText(branchName);
}
});
setTitle((isTag ? CvsBundle.message("operation.name.create.tag") : CvsBundle.message("operation.name.create.branch")));
public CreateTagDialog(final FilePath[] files, final Project project, boolean isTag) {
if (isTag) {
myTagOrBranchLabel.setText(CvsBundle.message("label.tag.name"));
mySwitchToThisTag.setText(CvsBundle.message("checkbox.switch.to.this.tag"));
myOverrideExisting.setText(CvsBundle.message("checkbox.create.tag.override.existing"));
}
else {
myTagOrBranchLabel.setText(CvsBundle.message("label.branch.name"));
mySwitchToThisTag.setText(CvsBundle.message("checkbox.switch.to.this.branch"));
myOverrideExisting.setText(CvsBundle.message("checkbox.create.tag.override.existing.branch"));
}
TagsHelper.addChooseBranchAction(myTagName, Arrays.asList(files), project);
setTitle(isTag ? CvsBundle.message("operation.name.create.tag") : CvsBundle.message("operation.name.create.branch"));
CvsFieldValidator.installOn(this, myTagName.getTextField(), myErrorLabel);
init();
}
public static Collection<FilePath> collectVcsRoots(final Project project, final Collection<FilePath> files) {
Collection<FilePath> result = new HashSet<FilePath>();
for(FilePath filePath: files) {
final VirtualFile root = ProjectLevelVcsManager.getInstance(project).getVcsRootFor(filePath);
if (root != null) {
result.add(VcsContextFactory.SERVICE.getInstance().createFilePathOn(root));
}
}
return result;
}
public String getTagName() {
return myTagName.getText();
}
@@ -106,5 +85,4 @@ public class CreateTagDialog extends CvsTagDialog {
public boolean tagFieldIsActive() {
return true;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2011 JetBrains s.r.o.
* Copyright 2000-2012 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,41 +23,24 @@ import com.intellij.openapi.ui.TextFieldWithBrowseButton;
import com.intellij.openapi.vcs.FilePath;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collection;
import java.util.Arrays;
/**
* author: lesya
*/
public class DeleteTagDialog extends CvsTagDialog {
private TextFieldWithBrowseButton myTagName;
private JPanel myPanel;
private final Collection<FilePath> myFiles;
private final Project myProject;
private JLabel myErrorLabel;
public DeleteTagDialog(Collection<FilePath> files, Project project) {
myFiles = files;
myProject = project;
myTagName.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
selectTag();
}
});
public DeleteTagDialog(final FilePath[] files, final Project project) {
TagsHelper.addChooseBranchAction(myTagName, Arrays.asList(files), project);
CvsFieldValidator.installOn(this, myTagName.getTextField(), myErrorLabel);
setTitle(CvsBundle.message("action.name.delete.tag"));
init();
}
private void selectTag() {
String branchName = TagsHelper.chooseBranch(CreateTagDialog.collectVcsRoots(myProject, myFiles), myProject);
if (branchName != null)
myTagName.setText(branchName);
}
public String getTagName() {
return myTagName.getText();
}
@@ -81,5 +64,4 @@ public class DeleteTagDialog extends CvsTagDialog {
public boolean tagFieldIsActive() {
return true;
}
}