Search in sources :

Example 6 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)

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