Search in sources :

Example 56 with VirtualFile

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

the class HgHistoryTest method testFileNameInTargetRevisionAfterRename.

public void testFileNameInTargetRevisionAfterRename() throws HgCommandException {
    cd(myRepository);
    int namesSize = names.length;
    VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
    assert subDir != null;
    VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
    assert vFile != null;
    HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
    HgLogCommand logCommand = new HgLogCommand(myProject);
    logCommand.setFollowCopies(true);
    List<HgFileRevision> revisions = logCommand.execute(hgFile, -1, true);
    for (int i = 0; i < revisions.size(); ++i) {
        HgFile expectedFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
        HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
        assertEquals(expectedFile.getRelativePath(), targetFileName.getRelativePath());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 57 with VirtualFile

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

the class HgHistoryTest method testFileNameInTargetRevisionAfterUpdate.

public void testFileNameInTargetRevisionAfterUpdate() throws HgCommandException {
    cd(myRepository);
    //update to parent revision
    hg("update -r .^");
    //update filenames size which is in use
    int namesSize = names.length - 1;
    //find file with parent revision name
    VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
    assert subDir != null;
    VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
    assert vFile != null;
    HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
    HgLogCommand logCommand = new HgLogCommand(myProject);
    logCommand.setFollowCopies(true);
    List<HgFileRevision> revisions = logCommand.execute(hgFile, -1, true);
    for (int i = 0; i < revisions.size(); ++i) {
        HgFile expectedFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
        HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
        assertEquals(expectedFile.getRelativePath(), targetFileName.getRelativePath());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 58 with VirtualFile

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

the class HgHistoryTest method testFileNameInTargetRevisionFromAffectedFiles.

public void testFileNameInTargetRevisionFromAffectedFiles() throws HgCommandException {
    cd(myRepository);
    int namesSize = names.length;
    VirtualFile subDir = myRepository.findFileByRelativePath(subDirName);
    assert subDir != null;
    VirtualFile vFile = VfsUtil.findFileByIoFile(new File(subDir.getPath(), names[namesSize - 1]), true);
    assert vFile != null;
    HgFile localFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(vFile));
    HgLogCommand logCommand = new HgLogCommand(myProject);
    logCommand.setFollowCopies(true);
    List<HgFileRevision> revisions = logCommand.execute(localFile, -1, true);
    for (int i = 0; i < namesSize; ++i) {
        HgFile hgFile = new HgFile(myRepository, new File(subDir.getPath(), names[namesSize - i - 1]));
        HgFile targetFileName = HgUtil.getFileNameInTargetRevision(myProject, revisions.get(i).getRevisionNumber(), hgFile);
        assertEquals(hgFile.getRelativePath(), targetFileName.getRelativePath());
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) HgFile(org.zmlx.hg4idea.HgFile) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 59 with VirtualFile

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

the class HgPullDialog method onChangeRepository.

private void onChangeRepository() {
    final VirtualFile repo = hgRepositorySelector.getRepository().getRoot();
    final String defaultPath = HgUtil.getRepositoryDefaultPath(project, repo);
    if (!StringUtil.isEmptyOrSpaces(defaultPath)) {
        addPathsFromHgrc(repo);
        myRepositoryURL.setText(HgUtil.removePasswordIfNeeded(defaultPath));
        myCurrentRepositoryUrl = defaultPath;
        onChangePullSource();
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile)

Example 60 with VirtualFile

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

the class HgRunConflictResolverDialog method onChangeRepository.

private void onChangeRepository() {
    VirtualFile repo = repositorySelector.getRepository().getRoot();
    HgResolveCommand command = new HgResolveCommand(project);
    final ModalityState modalityState = ApplicationManager.getApplication().getModalityStateForComponent(getRootPane());
    command.getListAsynchronously(repo, new Consumer<Map<HgFile, HgResolveStatusEnum>>() {

        @Override
        public void consume(Map<HgFile, HgResolveStatusEnum> status) {
            final DefaultListModel model = new DefaultListModel();
            for (Map.Entry<HgFile, HgResolveStatusEnum> entry : status.entrySet()) {
                if (entry.getValue() == HgResolveStatusEnum.UNRESOLVED) {
                    model.addElement(entry.getKey().getRelativePath());
                }
            }
            ApplicationManager.getApplication().invokeLater(new Runnable() {

                @Override
                public void run() {
                    setOKActionEnabled(!model.isEmpty());
                    if (model.isEmpty()) {
                        model.addElement("No conflicts to resolve");
                    }
                    conflictsList.setModel(model);
                }
            }, modalityState);
        }
    });
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgResolveCommand(org.zmlx.hg4idea.command.HgResolveCommand) HgResolveStatusEnum(org.zmlx.hg4idea.command.HgResolveStatusEnum) ModalityState(com.intellij.openapi.application.ModalityState) Map(java.util.Map)

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