Search in sources :

Example 61 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgUtil method removeFilesFromVcs.

/**
   * Calls 'hg remove' to remove given files from the VCS.
   * @param project
   * @param files files to be removed from the VCS.
   */
public static void removeFilesFromVcs(Project project, List<FilePath> files) {
    final HgRemoveCommand command = new HgRemoveCommand(project);
    for (FilePath filePath : files) {
        final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(project, filePath);
        if (vcsRoot == null) {
            continue;
        }
        command.executeInCurrentThread(new HgFile(vcsRoot, filePath));
    }
}
Also used : HgRemoveCommand(org.zmlx.hg4idea.command.HgRemoveCommand) FilePath(com.intellij.openapi.vcs.FilePath) VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile)

Example 62 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgRepositoryUpdater method after.

@Override
public void after(@NotNull List<? extends VFileEvent> events) {
    // which files in .hg were changed
    boolean branchHeadsChanged = false;
    boolean branchFileChanged = false;
    boolean dirstateFileChanged = false;
    boolean mergeFileChanged = false;
    boolean rebaseFileChanged = false;
    boolean bookmarksFileChanged = false;
    boolean tagsFileChanged = false;
    boolean localTagsFileChanged = false;
    boolean currentBookmarkFileChanged = false;
    boolean mqChanged = false;
    boolean hgIgnoreChanged = false;
    boolean configHgrcChanged = false;
    for (VFileEvent event : events) {
        String filePath = event.getPath();
        if (filePath == null) {
            continue;
        }
        if (myRepositoryFiles.isbranchHeadsFile(filePath)) {
            branchHeadsChanged = true;
        } else if (myRepositoryFiles.isBranchFile(filePath)) {
            branchFileChanged = true;
            DvcsUtil.ensureAllChildrenInVfs(myBranchHeadsDir);
        } else if (myRepositoryFiles.isDirstateFile(filePath)) {
            dirstateFileChanged = true;
        } else if (myRepositoryFiles.isMergeFile(filePath)) {
            mergeFileChanged = true;
        } else if (myRepositoryFiles.isRebaseFile(filePath)) {
            rebaseFileChanged = true;
        } else if (myRepositoryFiles.isBookmarksFile(filePath)) {
            bookmarksFileChanged = true;
        } else if (myRepositoryFiles.isTagsFile(filePath)) {
            tagsFileChanged = true;
        } else if (myRepositoryFiles.isLocalTagsFile(filePath)) {
            localTagsFileChanged = true;
        } else if (myRepositoryFiles.isCurrentBookmarksFile(filePath)) {
            currentBookmarkFileChanged = true;
        } else if (myRepositoryFiles.isMqFile(filePath)) {
            mqChanged = true;
            if (myMqDir == null) {
                myMqDir = VcsUtil.getVirtualFile(myRepositoryFiles.getMQDirPath());
            }
            DvcsUtil.ensureAllChildrenInVfs(myMqDir);
        } else if (myRepositoryFiles.isConfigHgrcFile(filePath)) {
            configHgrcChanged = true;
        } else if (myRepositoryFiles.isHgIgnore(filePath)) {
            hgIgnoreChanged = true;
        }
    }
    if (branchHeadsChanged || branchFileChanged || dirstateFileChanged || mergeFileChanged || rebaseFileChanged || bookmarksFileChanged || currentBookmarkFileChanged || tagsFileChanged || localTagsFileChanged || mqChanged) {
        myUpdateQueue.queue(new MyUpdater("hgrepositoryUpdate"));
    }
    if (configHgrcChanged) {
        myUpdateConfigQueue.queue(new MyUpdater("hgconfigUpdate"));
    }
    if (dirstateFileChanged || hgIgnoreChanged) {
        myRepository.getLocalIgnoredHolder().startRescan();
        final VirtualFile root = myRepository.getRoot();
        myDirtyScopeManager.dirDirtyRecursively(root);
        if (dirstateFileChanged) {
            //update async incoming/outgoing model
            myProject.getMessageBus().syncPublisher(HgVcs.REMOTE_TOPIC).update(myProject, root);
        }
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VFileEvent(com.intellij.openapi.vfs.newvfs.events.VFileEvent)

Example 63 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgRemoteStatusUpdater method updateChangesStatusSynchronously.

private void updateChangesStatusSynchronously(Project project, VirtualFile[] roots, HgChangesetStatus status, boolean incoming) {
    if (!myProjectSettings.isCheckIncomingOutgoing())
        return;
    final List<HgRevisionNumber> changesets = new LinkedList<>();
    for (VirtualFile root : roots) {
        if (incoming) {
            changesets.addAll(new HgIncomingCommand(project).executeInCurrentThread(root));
        } else {
            changesets.addAll(new HgOutgoingCommand(project).executeInCurrentThread(root));
        }
    }
    status.setChanges(changesets.size(), new ChangesetFormatter(status, changesets));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgIncomingCommand(org.zmlx.hg4idea.command.HgIncomingCommand) HgOutgoingCommand(org.zmlx.hg4idea.command.HgOutgoingCommand) LinkedList(java.util.LinkedList)

Example 64 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgHistoryTest method testUncommittedRenamedFileHistory.

public void testUncommittedRenamedFileHistory() throws HgCommandException {
    cd(myRepository);
    VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
    assert subDir != null;
    cd(subDir);
    int namesSize = names.length;
    String beforeName = names[namesSize - 1];
    VirtualFile before = VfsUtil.findFileByIoFile(new File(subDir.getPath(), beforeName), true);
    assert before != null;
    FilePath filePath = VcsUtil.getFilePath(VfsUtilCore.virtualToIoFile(before));
    final String renamed = "renamed";
    hg("mv " + beforeName + " " + renamed);
    myRepository.refresh(false, true);
    List<HgFileRevision> revisions = HgHistoryProvider.getHistory((filePath), myRepository, myProject);
    assertEquals(3, revisions.size());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) FilePath(com.intellij.openapi.vcs.FilePath) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile)

Example 65 with VirtualFile

use of com.intellij.openapi.vfs.VirtualFile in project intellij-community by JetBrains.

the class HgLogTest method parseCopied.

private void parseCopied(@NotNull String sourceFileName) throws HgCommandException {
    cd(myRepository);
    String copiedFileName = "copy".concat(sourceFileName);
    touch(sourceFileName);
    myRepository.refresh(false, true);
    hg("add " + sourceFileName);
    hg("commit -m a ");
    hg("cp " + sourceFileName + " " + copiedFileName);
    myRepository.refresh(false, true);
    hg("commit -m a ");
    HgLogCommand logCommand = new HgLogCommand(myProject);
    logCommand.setFollowCopies(false);
    VirtualFile copiedFile = myRepository.findChild(copiedFileName);
    assert copiedFile != null;
    final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(copiedFile));
    List<HgFileRevision> revisions = logCommand.execute(hgFile, 1, true);
    HgFileRevision rev = revisions.get(0);
    assertTrue(!rev.getAddedFiles().isEmpty());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Aggregations

VirtualFile (com.intellij.openapi.vfs.VirtualFile)5465 File (java.io.File)762 Project (com.intellij.openapi.project.Project)720 Nullable (org.jetbrains.annotations.Nullable)720 NotNull (org.jetbrains.annotations.NotNull)703 PsiFile (com.intellij.psi.PsiFile)571 Module (com.intellij.openapi.module.Module)501 IOException (java.io.IOException)327 ArrayList (java.util.ArrayList)260 Document (com.intellij.openapi.editor.Document)244 PsiElement (com.intellij.psi.PsiElement)209 Test (org.junit.Test)196 ProjectFileIndex (com.intellij.openapi.roots.ProjectFileIndex)124 PsiDirectory (com.intellij.psi.PsiDirectory)124 XmlFile (com.intellij.psi.xml.XmlFile)124 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)116 Editor (com.intellij.openapi.editor.Editor)115 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)101 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)91 List (java.util.List)90