@Test
  public void testSwitchedFileAndFolder() throws Exception {
    final String branchUrl = prepareBranchesStructure();

    final SubTree tree = new SubTree(myWorkingCopyDir);

    verify(runSvn("switch", branchUrl + "/root/source/s1.txt", tree.myS1File.getPath()));
    verify(runSvn("switch", branchUrl + "/root/target", tree.myTargetDir.getPath()));

    final ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);

    final Runnable check =
        new Runnable() {
          @Override
          public void run() {
            Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myS1File));
            Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
            Assert.assertEquals(
                FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
            Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
            Assert.assertEquals(
                FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
          }
        };
    myScheme.doTest(check);

    changeListManager.ensureUpToDate(false);
    check.run();

    editFileInCommand(myProject, tree.myS1File, "1234543534543 3543 ");
    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    changeListManager.ensureUpToDate(false);

    final Runnable check2 =
        new Runnable() {
          @Override
          public void run() {
            Assert.assertEquals(FileStatus.MODIFIED, changeListManager.getStatus(tree.myS1File));
            Assert.assertEquals(FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.myS2File));
            Assert.assertEquals(
                FileStatus.NOT_CHANGED, changeListManager.getStatus(tree.mySourceDir));
            Assert.assertEquals(FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetDir));
            Assert.assertEquals(
                FileStatus.SWITCHED, changeListManager.getStatus(tree.myTargetFiles.get(1)));
          }
        };
    myScheme.doTest(check2);

    changeListManager.ensureUpToDate(false);
    check2.run();
  }
  @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(
        new Runnable() {
          @Override
          public void run() {
            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);
  }
  @Test
  public void testSetActive() 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() {
          @Override
          public void run() {
            changeListManager.setDefaultChangeList(target);
            assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
          }
        });

    assert changeListManager.getDefaultChangeList().getName().equals(target.getName());

    changeListManager.ensureUpToDate(false);
    assert changeListManager.getDefaultChangeList().getName().equals(target.getName());
  }
  @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() {
          @Override
          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);
  }
  @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() {
          @Override
          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());
  }