Search in sources :

Example 1 with ChangeListManager

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

the class SvnFileSystemListener method fillAddedFiles.

private void fillAddedFiles(Project project, SvnVcs vcs, List<VirtualFile> addedVFiles, Map<VirtualFile, File> copyFromMap, Set<VirtualFile> recursiveItems) {
    final Collection<AddedFileInfo> addedFileInfos = myAddedFiles.remove(project);
    final ChangeListManager changeListManager = ChangeListManager.getInstance(project);
    for (AddedFileInfo addedFileInfo : addedFileInfos) {
        final File ioFile = new File(getIOFile(addedFileInfo.myDir), addedFileInfo.myName);
        VirtualFile addedFile = addedFileInfo.myDir.findChild(addedFileInfo.myName);
        if (addedFile == null) {
            addedFile = myLfs.refreshAndFindFileByIoFile(ioFile);
        }
        if (addedFile != null) {
            final Status fileStatus = getFileStatus(vcs, ioFile);
            if (fileStatus == null || !fileStatus.is(StatusType.STATUS_IGNORED)) {
                boolean isIgnored = changeListManager.isIgnoredFile(addedFile);
                if (!isIgnored) {
                    addedVFiles.add(addedFile);
                    copyFromMap.put(addedFile, addedFileInfo.myCopyFrom);
                    if (addedFileInfo.myRecursive) {
                        recursiveItems.add(addedFile);
                    }
                }
            }
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Status(org.jetbrains.idea.svn.status.Status) VirtualFile(com.intellij.openapi.vfs.VirtualFile) ActionWithTempFile(com.intellij.vcsUtil.ActionWithTempFile) VfsUtilCore.virtualToIoFile(com.intellij.openapi.vfs.VfsUtilCore.virtualToIoFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager)

Example 2 with ChangeListManager

use of com.intellij.openapi.vcs.changes.ChangeListManager 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)

Example 3 with ChangeListManager

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

the class SvnTreeConflictDataTest method testDir2File_MINE_MOVE_THEIRS_ADD.

@Test
public void testDir2File_MINE_MOVE_THEIRS_ADD() throws Exception {
    final String conflictFile = createConflict(TreeConflictData.DirToFile.MINE_MOVE_THEIRS_ADD);
    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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TreeConflictDescription(org.jetbrains.idea.svn.conflict.TreeConflictDescription) ConflictVersion(org.jetbrains.idea.svn.conflict.ConflictVersion) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 4 with ChangeListManager

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

the class SvnTreeConflictDataTest method testDir2Dir_MINE_DELETE_THEIRS_EDIT.

// not a conflict in Subversion 1.7.7. "mine" file becomes added
/*@Test
  public void testDir2Dir_MINE_EDIT_THEIRS_DELETE() throws Exception {
    final String conflictFile = createConflict(TreeConflictData.DirToDir.MINE_EDIT_THEIRS_DELETE);

    VcsDirtyScopeManager.getInstance(myProject).markEverythingDirty();
    ChangeListManager changeListManager = ChangeListManager.getInstance(myProject);
    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.DELETE, beforeDescription.getConflictAction());

    Assert.assertTrue(beforeDescription.isTreeConflict());
    ConflictVersion leftVersion = beforeDescription.getSourceLeftVersion();
    Assert.assertNotNull(leftVersion);
    Assert.assertEquals(NodeKind.DIR, leftVersion.getKind());

    final ConflictVersion version = beforeDescription.getSourceRightVersion();
    Assert.assertNotNull(version);
    Assert.assertEquals(NodeKind.NONE, version.getKind());
  }*/
@Test
public void testDir2Dir_MINE_DELETE_THEIRS_EDIT() throws Exception {
    final String conflictFile = createConflict(TreeConflictData.DirToDir.MINE_DELETE_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());
}
Also used : TreeConflictDescription(org.jetbrains.idea.svn.conflict.TreeConflictDescription) ConflictVersion(org.jetbrains.idea.svn.conflict.ConflictVersion) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Example 5 with ChangeListManager

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

the class SvnTreeConflictDataTest method testDir2File_MINE_ADD_THEIRS_MOVE.

@Test
public void testDir2File_MINE_ADD_THEIRS_MOVE() throws Exception {
    final String conflictFile = createConflict(TreeConflictData.DirToFile.MINE_ADD_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());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) TreeConflictDescription(org.jetbrains.idea.svn.conflict.TreeConflictDescription) ConflictVersion(org.jetbrains.idea.svn.conflict.ConflictVersion) Change(com.intellij.openapi.vcs.changes.Change) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) ChangeListManager(com.intellij.openapi.vcs.changes.ChangeListManager) Test(org.junit.Test)

Aggregations

ChangeListManager (com.intellij.openapi.vcs.changes.ChangeListManager)77 VirtualFile (com.intellij.openapi.vfs.VirtualFile)65 Test (org.junit.Test)57 Change (com.intellij.openapi.vcs.changes.Change)42 File (java.io.File)28 LocalChangeList (com.intellij.openapi.vcs.changes.LocalChangeList)24 ConflictVersion (org.jetbrains.idea.svn.conflict.ConflictVersion)23 TreeConflictDescription (org.jetbrains.idea.svn.conflict.TreeConflictDescription)23 ArrayList (java.util.ArrayList)11 VcsException (com.intellij.openapi.vcs.VcsException)6 NotNull (org.jetbrains.annotations.NotNull)4 ContentRevision (com.intellij.openapi.vcs.changes.ContentRevision)3 ProcessOutput (com.intellij.execution.process.ProcessOutput)2 ChangeList (com.intellij.openapi.vcs.changes.ChangeList)2 Nullable (org.jetbrains.annotations.Nullable)2 AccessToken (com.intellij.openapi.application.AccessToken)1 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)1 FileNodeDescriptor (com.intellij.openapi.fileChooser.ex.FileNodeDescriptor)1 FileSystemTreeImpl (com.intellij.openapi.fileChooser.ex.FileSystemTreeImpl)1 Project (com.intellij.openapi.project.Project)1