Search in sources :

Example 1 with VcsTaskHandler

use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.

the class TaskBranchesTest method testSuggestBranchName.

public void testSuggestBranchName() {
    initRepositories("community", "idea");
    VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject());
    assertEquals(1, handlers.length);
    VcsTaskHandler handler = handlers[0];
    String startName = "-Hello, this is long name with : and $";
    assertFalse(handler.isBranchNameValid(startName));
    String cleanUpBranchName = handler.cleanUpBranchName(startName);
    assertTrue(handler.isBranchNameValid(cleanUpBranchName));
}
Also used : VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Example 2 with VcsTaskHandler

use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.

the class TaskBranchesTest method _testCurrentTasks.

public void _testCurrentTasks() throws Exception {
    initRepositories("foo", "bar");
    VcsTaskHandler handler = VcsTaskHandler.getAllHandlers(getProject())[0];
    VcsTaskHandler.TaskInfo[] tasks = handler.getAllExistingTasks();
    assertEquals(1, tasks.length);
    VcsTaskHandler.TaskInfo defaultTask = tasks[0];
    assertEquals(1, handler.getCurrentTasks().length);
    VcsTaskHandler.TaskInfo task = handler.startNewTask("new");
    assertEquals(2, handler.getAllExistingTasks().length);
    assertEquals(1, handler.getCurrentTasks().length);
    handler.closeTask(task, defaultTask);
    VcsTaskHandler.TaskInfo[] existingTasks = handler.getAllExistingTasks();
    assertEquals(Arrays.asList(existingTasks).toString(), 1, existingTasks.length);
    assertEquals(1, handler.getCurrentTasks().length);
}
Also used : VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Example 3 with VcsTaskHandler

use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.

the class TaskManagerImpl method createBranch.

public void createBranch(LocalTask task, LocalTask previousActive, String name, @Nullable VcsTaskHandler.TaskInfo branchFrom) {
    VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
    for (VcsTaskHandler handler : handlers) {
        VcsTaskHandler.TaskInfo[] info = handler.getCurrentTasks();
        if (previousActive != null && previousActive.getBranches(false).isEmpty()) {
            addBranches(previousActive, info, false);
        }
        addBranches(task, info, true);
        if (info.length == 0 && branchFrom != null) {
            addBranches(task, new VcsTaskHandler.TaskInfo[] { branchFrom }, true);
        }
        addBranches(task, new VcsTaskHandler.TaskInfo[] { handler.startNewTask(name) }, false);
    }
}
Also used : VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Example 4 with VcsTaskHandler

use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.

the class TaskBranchesTest method testVcsTaskHandler.

public void testVcsTaskHandler() throws Exception {
    List<Repository> repositories = initRepositories("community", "idea");
    Repository repository = repositories.get(0);
    String defaultBranchName = getDefaultBranchName();
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(getProject());
    assertEquals(1, handlers.length);
    VcsTaskHandler handler = handlers[0];
    VcsTaskHandler.TaskInfo defaultInfo = handler.getAllExistingTasks()[0];
    assertEquals(defaultBranchName, defaultInfo.getName());
    assertEquals(2, defaultInfo.getRepositories().size());
    final String first = "first";
    VcsTaskHandler.TaskInfo firstInfo = handler.startNewTask(first);
    repository.update();
    assertEquals(first, firstInfo.getName());
    assertEquals(2, firstInfo.getRepositories().size());
    assertEquals(2, getNumberOfBranches(repository));
    assertEquals(first, repository.getCurrentBranchName());
    handler.switchToTask(defaultInfo, null);
    repository.update();
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    final String second = "second";
    VcsTaskHandler.TaskInfo secondInfo = handler.startNewTask(second);
    repository.update();
    assertEquals(3, getNumberOfBranches(repository));
    assertEquals(second, repository.getCurrentBranchName());
    handler.switchToTask(firstInfo, null);
    createAndCommitChanges(repository);
    handler.closeTask(secondInfo, firstInfo);
    repository.update();
    assertEquals(2, getNumberOfBranches(repository));
}
Also used : Repository(com.intellij.dvcs.repo.Repository) VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Example 5 with VcsTaskHandler

use of com.intellij.openapi.vcs.VcsTaskHandler in project intellij-community by JetBrains.

the class TaskManagerImpl method getAllBranches.

private List<BranchInfo> getAllBranches(final String repo) {
    ArrayList<BranchInfo> infos = new ArrayList<>();
    VcsTaskHandler[] handlers = VcsTaskHandler.getAllHandlers(myProject);
    for (VcsTaskHandler handler : handlers) {
        VcsTaskHandler.TaskInfo[] tasks = handler.getAllExistingTasks();
        for (VcsTaskHandler.TaskInfo info : tasks) {
            infos.addAll(ContainerUtil.filter(BranchInfo.fromTaskInfo(info, false), info1 -> Comparing.equal(info1.repository, repo)));
        }
    }
    return infos;
}
Also used : UIUtil(com.intellij.util.ui.UIUtil) EventDispatcher(com.intellij.util.EventDispatcher) HyperlinkEvent(javax.swing.event.HyperlinkEvent) Tag(com.intellij.util.xmlb.annotations.Tag) com.intellij.openapi.vcs.changes(com.intellij.openapi.vcs.changes) TimeoutException(java.util.concurrent.TimeoutException) ColoredTreeCellRenderer(com.intellij.ui.ColoredTreeCellRenderer) TaskRepositoriesConfigurable(com.intellij.tasks.config.TaskRepositoriesConfigurable) Future(java.util.concurrent.Future) Messages(com.intellij.openapi.ui.Messages) Logger(com.intellij.openapi.diagnostic.Logger) MultiMap(com.intellij.util.containers.MultiMap) XmlSerializationException(com.intellij.util.xmlb.XmlSerializationException) Timer(javax.swing.Timer) ProgressManager(com.intellij.openapi.progress.ProgressManager) AbstractVcs(com.intellij.openapi.vcs.AbstractVcs) VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) Nullable(org.jetbrains.annotations.Nullable) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) XmlSerializerUtil(com.intellij.util.xmlb.XmlSerializerUtil) Function(com.intellij.util.Function) ApplicationManager(com.intellij.openapi.application.ApplicationManager) NotNull(org.jetbrains.annotations.NotNull) Property(com.intellij.util.xmlb.annotations.Property) XmlSerializer(com.intellij.util.xmlb.XmlSerializer) java.util(java.util) com.intellij.notification(com.intellij.notification) ShowSettingsUtil(com.intellij.openapi.options.ShowSettingsUtil) ArrayUtil(com.intellij.util.ArrayUtil) ActionListener(java.awt.event.ActionListener) HttpRequests(com.intellij.util.io.HttpRequests) com.intellij.openapi.components(com.intellij.openapi.components) ProjectLevelVcsManager(com.intellij.openapi.vcs.ProjectLevelVcsManager) TaskSearchSupport(com.intellij.tasks.actions.TaskSearchSupport) ContainerUtil(com.intellij.util.containers.ContainerUtil) AbstractCollection(com.intellij.util.xmlb.annotations.AbstractCollection) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException) Comparing(com.intellij.openapi.util.Comparing) StartupManager(com.intellij.openapi.startup.StartupManager) com.intellij.tasks(com.intellij.tasks) SocketTimeoutException(java.net.SocketTimeoutException) Project(com.intellij.openapi.project.Project) StringUtil(com.intellij.openapi.util.text.StringUtil) Convertor(com.intellij.util.containers.Convertor) DecimalFormat(java.text.DecimalFormat) ActionEvent(java.awt.event.ActionEvent) UnknownHostException(java.net.UnknownHostException) Disposable(com.intellij.openapi.Disposable) TestOnly(org.jetbrains.annotations.TestOnly) TimeUnit(java.util.concurrent.TimeUnit) WorkingContextManager(com.intellij.tasks.context.WorkingContextManager) VcsType(com.intellij.openapi.vcs.VcsType) Element(org.jdom.Element) VcsTaskHandler(com.intellij.openapi.vcs.VcsTaskHandler)

Aggregations

VcsTaskHandler (com.intellij.openapi.vcs.VcsTaskHandler)6 Repository (com.intellij.dvcs.repo.Repository)1 com.intellij.notification (com.intellij.notification)1 Disposable (com.intellij.openapi.Disposable)1 ApplicationManager (com.intellij.openapi.application.ApplicationManager)1 com.intellij.openapi.components (com.intellij.openapi.components)1 Logger (com.intellij.openapi.diagnostic.Logger)1 ShowSettingsUtil (com.intellij.openapi.options.ShowSettingsUtil)1 EmptyProgressIndicator (com.intellij.openapi.progress.EmptyProgressIndicator)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 ProgressManager (com.intellij.openapi.progress.ProgressManager)1 Project (com.intellij.openapi.project.Project)1 StartupManager (com.intellij.openapi.startup.StartupManager)1 Messages (com.intellij.openapi.ui.Messages)1 Comparing (com.intellij.openapi.util.Comparing)1 StringUtil (com.intellij.openapi.util.text.StringUtil)1 AbstractVcs (com.intellij.openapi.vcs.AbstractVcs)1 ProjectLevelVcsManager (com.intellij.openapi.vcs.ProjectLevelVcsManager)1 VcsType (com.intellij.openapi.vcs.VcsType)1