Search in sources :

Example 1 with LocalChangeList

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

the class MergeTask method setupDefaultEmptyChangeListForMerge.

private boolean setupDefaultEmptyChangeListForMerge() {
    ChangeListManager changeListManager = ChangeListManager.getInstance(myMergeContext.getProject());
    int i = 0;
    boolean needRefresh = false;
    while (true) {
        String name = myMergeContext.getTitle() + (i > 0 ? " (" + i + ")" : "");
        LocalChangeList changeList = changeListManager.findChangeList(name);
        if (changeList == null) {
            changeListManager.setDefaultChangeList(changeListManager.addChangeList(name, null));
            needRefresh = true;
            break;
        }
        if (changeList.getChanges().isEmpty()) {
            if (!changeList.isDefault()) {
                changeListManager.setDefaultChangeList(changeList);
                needRefresh = true;
            }
            break;
        }
        i++;
    }
    return needRefresh;
}
Also used : LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 2 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testAddPlusMove.

@Test
public void testAddPlusMove() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final LocalChangeList list = changeListManager.addChangeList("test", null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file) });
    final String targetName = "target";
    myScheme.doTest(() -> {
        final LocalChangeList target = changeListManager.addChangeList(targetName, null);
        changeListManager.moveChangesTo(target, new Change[] { changeListManager.getChange(file) });
        checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
    });
    checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] { file }, targetName, changeListManager);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 3 with LocalChangeList

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

the class SvnDeleteTest method testDeletePackage.

// IDEADEV-16066
@Test
public void testDeletePackage() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    enableSilentOperation(VcsConfiguration.StandardConfirmation.REMOVE);
    VirtualFile dir = createDirInCommand(myWorkingCopyDir, "child");
    createFileInCommand(dir, "a.txt", "content");
    runAndVerifyStatus("A child", "A child" + File.separatorChar + "a.txt");
    checkin();
    deleteFileInCommand(dir);
    runAndVerifyStatus("D child", "D child" + File.separatorChar + "a.txt");
    refreshVfs();
    final AlienDirtyScope dirtyScope = new AlienDirtyScope();
    dirtyScope.addDir(VcsUtil.getFilePath(myWorkingCopyDir));
    final List<Change> changesManually = getChangesInScope(dirtyScope);
    Assert.assertEquals(2, changesManually.size());
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    // since ChangeListManager is runnning, it can take dirty scope itself;... it's easier to just take changes from it
    final ChangeListManager clManager = ChangeListManager.getInstance(myProject);
    clManager.ensureUpToDate(false);
    final List<LocalChangeList> lists = clManager.getChangeListsCopy();
    Assert.assertEquals(1, lists.size());
    final Collection<Change> changes = lists.get(0).getChanges();
    Assert.assertEquals(2, changes.size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) Change(com.intellij.openapi.vcs.changes.Change) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) AlienDirtyScope(org.jetbrains.idea.svn.integrate.AlienDirtyScope) Test(org.junit.Test)

Example 4 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testEditComment.

@Test
public void testEditComment() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final String listName = "test";
    final LocalChangeList list = changeListManager.addChangeList(listName, null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file) });
    final String finalText = "final text";
    myScheme.doTest(() -> {
        final String intermediate = "intermediate text";
        changeListManager.editComment(list.getName(), intermediate);
        assert changeListManager.findChangeList(listName) != null;
        LocalChangeList list1 = changeListManager.findChangeList(listName);
        assert intermediate.equals(list1.getComment());
        changeListManager.editComment(list1.getName(), finalText);
        list1 = changeListManager.findChangeList(listName);
        assert finalText.equals(list1.getComment());
    });
    LocalChangeList changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());
    changeListManager.ensureUpToDate(false);
    changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 5 with LocalChangeList

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

the class SvnConcurrentChangeListManagerTest method testRenameList.

@Test
public void testRenameList() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    changeListManager.ensureUpToDate(false);
    final LocalChangeList list = changeListManager.addChangeList("test", null);
    changeListManager.moveChangesTo(list, new Change[] { changeListManager.getChange(file) });
    final String newName = "renamed";
    myScheme.doTest(() -> {
        changeListManager.editName(list.getName(), newName);
        checkFilesAreInList(new VirtualFile[] { file }, newName, changeListManager);
    });
    checkFilesAreInList(new VirtualFile[] { file }, newName, changeListManager);
    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] { file }, newName, changeListManager);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LocalChangeList(com.intellij.openapi.vcs.changes.LocalChangeList) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Aggregations

LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)44 ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)25 VirtualFile (com.intellij.openapi.vfs.VirtualFile)23 Test (org.junit.Test)20 Project (com.intellij.openapi.project.Project)8 Change (com.intellij.openapi.vcs.changes.Change)7 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)5 TaskManager (com.intellij.tasks.TaskManager)3 List (java.util.List)3 Nullable (org.jetbrains.annotations.Nullable)3 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)2 ChangeListInfo (com.intellij.tasks.ChangeListInfo)2 ArrayList (java.util.ArrayList)2 NotNull (org.jetbrains.annotations.NotNull)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 DumbAware (com.intellij.openapi.project.DumbAware)1