コード例 #1
0
  @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(
        new Runnable() {
          public void run() {
            final String intermediate = "intermediate text";
            changeListManager.editComment(list.getName(), intermediate);
            assert changeListManager.findChangeList(listName) != null;
            LocalChangeList list = changeListManager.findChangeList(listName);
            assert intermediate.equals(list.getComment());

            changeListManager.editComment(list.getName(), finalText);
            list = changeListManager.findChangeList(listName);
            assert finalText.equals(list.getComment());
          }
        });

    LocalChangeList changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());

    changeListManager.ensureUpToDate(false);
    changedList = changeListManager.findChangeList(listName);
    assert finalText.equals(changedList.getComment());
  }
コード例 #2
0
  @Test
  public void testMove() 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);
    final LocalChangeList target = changeListManager.addChangeList("target", null);
    changeListManager.moveChangesTo(list, new Change[] {changeListManager.getChange(file)});

    myScheme.doTest(
        new Runnable() {
          public void run() {
            changeListManager.moveChangesTo(
                target, new Change[] {changeListManager.getChange(file)});
            checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
          }
        });

    checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);

    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] {file}, target.getName(), changeListManager);
  }
コード例 #3
0
  @Test
  public void testComplex() throws Exception {
    enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
    final VirtualFile file = createFileInCommand("a.txt", "old content");
    final VirtualFile fileB = createFileInCommand("b.txt", "old content");
    final VirtualFile fileC = createFileInCommand("c.txt", "old content");
    final VirtualFile fileD = createFileInCommand("d.txt", "old content");

    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);

    final LocalChangeList list = changeListManager.addChangeList("test", null);
    final LocalChangeList toBeDeletedList =
        changeListManager.addChangeList("toBeDeletedList", null);
    changeListManager.moveChangesTo(
        list, new Change[] {changeListManager.getChange(file), changeListManager.getChange(fileB)});
    changeListManager.moveChangesTo(
        toBeDeletedList,
        new Change[] {changeListManager.getChange(fileC), changeListManager.getChange(fileD)});
    changeListManager.ensureUpToDate(false);

    final String targetName = "target";
    final String finalName = "final list name";

    myScheme.doTest(
        new Runnable() {
          public void run() {
            final LocalChangeList target = changeListManager.addChangeList(targetName, null);
            changeListManager.moveChangesTo(
                target,
                new Change[] {
                  changeListManager.getChange(file), changeListManager.getChange(fileB)
                });
            checkFilesAreInList(new VirtualFile[] {file, fileB}, targetName, changeListManager);
            changeListManager.editName(targetName, finalName);
            checkFilesAreInList(new VirtualFile[] {file, fileB}, finalName, changeListManager);
            changeListManager.removeChangeList(toBeDeletedList.getName());
            checkFilesAreInList(
                new VirtualFile[] {fileC, fileD}, myDefaulListName, changeListManager);
            changeListManager.moveChangesTo(
                LocalChangeList.createEmptyChangeList(myProject, finalName),
                new Change[] {changeListManager.getChange(fileC)});
            checkFilesAreInList(
                new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
            checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
          }
        });

    checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
    checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);

    changeListManager.ensureUpToDate(false);
    checkFilesAreInList(new VirtualFile[] {file, fileB, fileC}, finalName, changeListManager);
    checkFilesAreInList(new VirtualFile[] {fileD}, myDefaulListName, changeListManager);
  }