use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.
the class SvnConcurrentChangeListManagerTest method testComplex.
@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(() -> {
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);
}
use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.
the class SvnConcurrentChangeListManagerTest method testRemove.
@Test
public void testRemove() throws Exception {
enableSilentOperation(VcsConfiguration.StandardConfirmation.ADD);
final VirtualFile file = createFileInCommand("a.txt", "old content");
final VirtualFile fileB = createFileInCommand("b.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) });
myScheme.doTest(() -> {
changeListManager.removeChangeList(list.getName());
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
});
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
changeListManager.ensureUpToDate(false);
assert changeListManager.findChangeList(list.getName()) == null;
checkFilesAreInList(new VirtualFile[] { file, fileB }, myDefaulListName, changeListManager);
}
use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.
the class SvnRootsDetector method addNestedRoots.
private void addNestedRoots(final boolean clearState, final Runnable callback) {
final List<VirtualFile> basicVfRoots = ObjectsConvertor.convert(myResult.myTopRoots, real -> real.getVirtualFile());
final ChangeListManager clManager = ChangeListManager.getInstance(myVcs.getProject());
if (clearState) {
// clear what was reported before (could be for currently-not-existing roots)
myNestedCopiesHolder.getAndClear();
}
clManager.invokeAfterUpdate(() -> {
final List<RootUrlInfo> nestedRoots = new ArrayList<>();
for (NestedCopyInfo info : myNestedCopiesHolder.getAndClear()) {
if (NestedCopyType.external.equals(info.getType()) || NestedCopyType.switched.equals(info.getType())) {
RootUrlInfo topRoot = findTopRoot(virtualToIoFile(info.getFile()));
if (topRoot != null) {
// TODO: Seems that type is not set in ForNestedRootChecker as we could not determine it for sure. Probably, for the case
// TODO: (or some other cases) when vcs root from settings belongs is in externals of some other working copy upper
// TODO: the tree (I did not check this). Leave this setter for now.
topRoot.setType(info.getType());
continue;
}
if (!refreshPointInfo(info)) {
continue;
}
}
registerRootUrlFromNestedPoint(info, nestedRoots);
}
myResult.myTopRoots.addAll(nestedRoots);
myMapping.applyDetectionResult(myResult);
callback.run();
}, InvokeAfterUpdateMode.SILENT_CALLBACK_POOLED, null, vcsDirtyScopeManager -> {
if (clearState) {
vcsDirtyScopeManager.filesDirty(null, basicVfRoots);
}
}, null);
}
use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.
the class SvnTreeConflictDataTest method testDir2File_MINE_UNV_THEIRS_MOVE.
@Test
public void testDir2File_MINE_UNV_THEIRS_MOVE() throws Exception {
final String conflictFile = createConflict(TreeConflictData.DirToFile.MINE_UNV_THEIRS_MOVE);
ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
changeListManager.ensureUpToDate(false);
VirtualFile vf = LocalFileSystem.getInstance().refreshAndFindFileByIoFile(new File(myWorkingCopyDir.getPath(), conflictFile));
Assert.assertNotNull(vf);
final Change change = changeListManager.getChange(vf);
Assert.assertTrue(change instanceof ConflictedSvnChange);
TreeConflictDescription beforeDescription = ((ConflictedSvnChange) change).getBeforeDescription();
Assert.assertNotNull(beforeDescription);
final TreeConflictDescription afterDescription = ((ConflictedSvnChange) change).getAfterDescription();
Assert.assertNull(afterDescription);
Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation());
Assert.assertEquals(ConflictAction.ADD, beforeDescription.getConflictAction());
Assert.assertTrue(beforeDescription.isTreeConflict());
ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion();
Assert.assertNull(leftVersion);
final ConflictVersion version = beforeDescription.getSourceRightVersion();
Assert.assertNotNull(version);
Assert.assertTrue(version.isFile());
}
use of com.intellij.openapi.vcs.changes.ChangeListManager in project intellij-community by JetBrains.
the class SvnTreeConflictDataTest method testDir2Dir_MINE_MOVE_THEIRS_EDIT.
@Test
public void testDir2Dir_MINE_MOVE_THEIRS_EDIT() throws Exception {
final String conflictFile = createConflict(TreeConflictData.DirToDir.MINE_MOVE_THEIRS_EDIT);
VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
changeListManager.ensureUpToDate(false);
final Change change = changeListManager.getChange(VcsUtil.getFilePath(new File(myWorkingCopyDir.getPath(), conflictFile), true));
Assert.assertTrue(change instanceof ConflictedSvnChange);
TreeConflictDescription beforeDescription = ((ConflictedSvnChange) change).getBeforeDescription();
Assert.assertNotNull(beforeDescription);
final TreeConflictDescription afterDescription = ((ConflictedSvnChange) change).getAfterDescription();
Assert.assertNull(afterDescription);
Assert.assertEquals(ConflictOperation.UPDATE, beforeDescription.getOperation());
Assert.assertEquals(ConflictAction.EDIT, beforeDescription.getConflictAction());
Assert.assertTrue(beforeDescription.isTreeConflict());
ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion();
Assert.assertNotNull(leftVersion);
Assert.assertTrue(leftVersion.isDirectory());
final ConflictVersion version = beforeDescription.getSourceRightVersion();
Assert.assertNotNull(version);
Assert.assertTrue(version.isDirectory());
}
Aggregations