Search in sources :

Example 1 with LocalTask

use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.

the class TaskBranchesTest method testBranchBloating.

public void testBranchBloating() throws Exception {
    Repository repository = initRepository("foo");
    LocalTask defaultTask = myTaskManager.getActiveTask();
    assertNotNull(defaultTask);
    assertEquals(0, defaultTask.getBranches().size());
    LocalTaskImpl foo = myTaskManager.createLocalTask("foo");
    LocalTask localTask = myTaskManager.activateTask(foo, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null);
    repository.update();
    assertEquals(2, localTask.getBranches().size());
    assertEquals(1, defaultTask.getBranches().size());
    myTaskManager.activateTask(localTask, false);
    LocalTaskImpl bar = myTaskManager.createLocalTask("bar");
    LocalTask barTask = myTaskManager.activateTask(bar, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(barTask), null);
    repository.update();
    assertEquals(1, defaultTask.getBranches().size());
}
Also used : Repository(com.intellij.dvcs.repo.Repository) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) LocalTask(com.intellij.tasks.LocalTask)

Example 2 with LocalTask

use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.

the class TaskBranchesTest method testTaskManager.

public void testTaskManager() throws Exception {
    List<Repository> repositories = initRepositories("community", "idea");
    LocalTask defaultTask = myTaskManager.getActiveTask();
    assertNotNull(defaultTask);
    LocalTaskImpl foo = myTaskManager.createLocalTask("foo");
    LocalTask localTask = myTaskManager.activateTask(foo, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null);
    String defaultBranchName = getDefaultBranchName();
    assertEquals(4, localTask.getBranches().size());
    assertEquals(2, localTask.getBranches(true).size());
    assertEquals(2, localTask.getBranches(false).size());
    assertEquals(2, defaultTask.getBranches().size());
    myTaskManager.activateTask(defaultTask, false);
    Repository repository = repositories.get(0);
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    foo = myTaskManager.createLocalTask("foo");
    localTask = myTaskManager.activateTask(foo, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null);
    assertEquals("foo", repository.getCurrentBranchName());
    createAndCommitChanges(repository);
    myTaskManager.mergeBranch(localTask);
    repository.update();
    assertEquals(defaultBranchName, repository.getCurrentBranchName());
    assertEquals(1, getNumberOfBranches(repository));
    myTaskManager.activateTask(defaultTask, false);
    myTaskManager.activateTask(foo, false);
}
Also used : Repository(com.intellij.dvcs.repo.Repository) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) LocalTask(com.intellij.tasks.LocalTask)

Example 3 with LocalTask

use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.

the class TaskBranchesTest method testCommit.

public void testCommit() throws Exception {
    Repository repository = initRepository("foo");
    LocalTask defaultTask = myTaskManager.getActiveTask();
    LocalTaskImpl foo = myTaskManager.createLocalTask("foo");
    final LocalTask localTask = myTaskManager.activateTask(foo, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null);
    createAndCommitChanges(repository);
    myTaskManager.mergeBranch(localTask);
    repository.update();
    assertEquals(getDefaultBranchName(), repository.getCurrentBranchName());
    assertEquals(1, getNumberOfBranches(repository));
}
Also used : Repository(com.intellij.dvcs.repo.Repository) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) LocalTask(com.intellij.tasks.LocalTask)

Example 4 with LocalTask

use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.

the class TaskBranchesTest method testCleanupRemovedBranch.

public void testCleanupRemovedBranch() throws InterruptedException {
    Repository repository = initRepository("foo");
    LocalTask defaultTask = myTaskManager.getActiveTask();
    assertNotNull(defaultTask);
    assertEquals(0, defaultTask.getBranches().size());
    LocalTaskImpl foo = myTaskManager.createLocalTask("foo");
    LocalTask localTask = myTaskManager.activateTask(foo, false);
    myTaskManager.createBranch(localTask, defaultTask, myTaskManager.suggestBranchName(localTask), null);
    assertEquals(2, localTask.getBranches().size());
    assertEquals(1, defaultTask.getBranches().size());
    // let's add non-existing branch
    BranchInfo info = new BranchInfo();
    info.name = "non-existing";
    info.repository = defaultTask.getBranches().get(0).repository;
    defaultTask.addBranch(info);
    repository.update();
    assertEquals("foo", repository.getCurrentBranchName());
    myTaskManager.activateTask(defaultTask, false);
    repository.update();
    assertEquals(getDefaultBranchName(), repository.getCurrentBranchName());
    // do not re-create "non-existing"
    assertEquals(2, getNumberOfBranches(repository));
}
Also used : Repository(com.intellij.dvcs.repo.Repository) LocalTaskImpl(com.intellij.tasks.impl.LocalTaskImpl) BranchInfo(com.intellij.tasks.BranchInfo) LocalTask(com.intellij.tasks.LocalTask)

Example 5 with LocalTask

use of com.intellij.tasks.LocalTask in project intellij-community by JetBrains.

the class TaskCheckinHandlerFactory method createHandler.

@NotNull
@Override
public CheckinHandler createHandler(@NotNull final CheckinProjectPanel panel, @NotNull final CommitContext commitContext) {
    return new CheckinHandler() {

        @Override
        public void checkinSuccessful() {
            final String message = panel.getCommitMessage();
            final Project project = panel.getProject();
            final TaskManagerImpl manager = (TaskManagerImpl) TaskManager.getManager(project);
            if (manager.getState().saveContextOnCommit) {
                Task task = findTaskInRepositories(message, manager);
                if (task == null) {
                    task = manager.createLocalTask(message);
                }
                final LocalTask localTask = manager.addTask(task);
                localTask.setUpdated(new Date());
                ApplicationManager.getApplication().invokeLater(() -> WorkingContextManager.getInstance(project).saveContext(localTask), project.getDisposed());
            }
        }
    };
}
Also used : Project(com.intellij.openapi.project.Project) Task(com.intellij.tasks.Task) LocalTask(com.intellij.tasks.LocalTask) CheckinHandler(com.intellij.openapi.vcs.checkin.CheckinHandler) LocalTask(com.intellij.tasks.LocalTask) Date(java.util.Date) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

LocalTask (com.intellij.tasks.LocalTask)19 Project (com.intellij.openapi.project.Project)7 TaskManager (com.intellij.tasks.TaskManager)7 LocalTaskImpl (com.intellij.tasks.impl.LocalTaskImpl)6 Repository (com.intellij.dvcs.repo.Repository)4 Task (com.intellij.tasks.Task)4 TaskPsiElement (com.intellij.tasks.doc.TaskPsiElement)3 TaskManagerImpl (com.intellij.tasks.impl.TaskManagerImpl)3 ActionEvent (java.awt.event.ActionEvent)3 NotNull (org.jetbrains.annotations.NotNull)3 TaskRepository (com.intellij.tasks.TaskRepository)2 SimpleActionGroup (com.intellij.tools.SimpleActionGroup)2 ListPopupImpl (com.intellij.ui.popup.list.ListPopupImpl)2 NullableFunction (com.intellij.util.NullableFunction)2 ArrayList (java.util.ArrayList)2 DataManager (com.intellij.ide.DataManager)1 Disposable (com.intellij.openapi.Disposable)1 com.intellij.openapi.actionSystem (com.intellij.openapi.actionSystem)1 Presentation (com.intellij.openapi.actionSystem.Presentation)1 ComboBoxAction (com.intellij.openapi.actionSystem.ex.ComboBoxAction)1