Search in sources :

Example 51 with VirtualFile

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

the class HgUtil method getRepositoryForFile.

@Nullable
public static HgRepository getRepositoryForFile(@NotNull Project project, @Nullable VirtualFile file) {
    if (file == null || project.isDisposed())
        return null;
    HgRepositoryManager repositoryManager = getRepositoryManager(project);
    VirtualFile root = getHgRootOrNull(project, file);
    return repositoryManager.getRepositoryForRoot(root);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) VcsVirtualFile(com.intellij.openapi.vcs.vfs.VcsVirtualFile) AbstractVcsVirtualFile(com.intellij.openapi.vcs.vfs.AbstractVcsVirtualFile) HgRepositoryManager(org.zmlx.hg4idea.repo.HgRepositoryManager) Nullable(org.jetbrains.annotations.Nullable)

Example 52 with VirtualFile

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

the class HgEncodingTest method testUtfMessageInHistoryWithSpecialCharacters.

//test SpecialCharacters in commit message for default EncodingProject settings
public void testUtfMessageInHistoryWithSpecialCharacters() throws HgCommandException, VcsException {
    cd(myRepository);
    String fileName = "file.txt";
    echo(fileName, "lalala");
    Charset charset = HgEncodingUtil.getDefaultCharset(myProject);
    String comment = "öäüß";
    HgRepository hgRepo = HgRepositoryImpl.getInstance(myRepository, myProject, myProject);
    HgCommitCommand commitCommand = new HgCommitCommand(myProject, hgRepo, comment);
    commitCommand.executeInCurrentThread();
    HgLogCommand logCommand = new HgLogCommand(myProject);
    myRepository.refresh(false, true);
    VirtualFile file = myRepository.findChild(fileName);
    assert file != null;
    List<HgFileRevision> revisions = logCommand.execute(new HgFile(myProject, file), 1, false);
    HgFileRevision rev = revisions.get(0);
    assertEquals(new String(comment.getBytes(charset)), rev.getCommitMessage());
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgCommitCommand(org.zmlx.hg4idea.command.HgCommitCommand) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) Charset(java.nio.charset.Charset) HgRepository(org.zmlx.hg4idea.repo.HgRepository) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand)

Example 53 with VirtualFile

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

the class HgPlatformTest method setUpHgrc.

private static void setUpHgrc(@NotNull VirtualFile repositoryRoot) throws IOException {
    cd(".hg");
    File pluginRoot = new File(PluginPathManager.getPluginHomePath("hg4idea"));
    String pathToHgrc = "testData\\repo\\dot_hg";
    File hgrcFile = new File(new File(pluginRoot, FileUtil.toSystemIndependentName(pathToHgrc)), "hgrc");
    File hgrc = new File(new File(repositoryRoot.getPath(), ".hg"), "hgrc");
    FileUtil.appendToFile(hgrc, FileUtil.loadFile(hgrcFile));
    assertTrue(hgrc.exists());
    repositoryRoot.refresh(false, true);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 54 with VirtualFile

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

the class HgTestUtil method printToFile.

/**
   * Writes the given content to the file.
   *
   * @param file    file which content will be substituted by the given one.
   * @param content new file content
   */
public static void printToFile(@NotNull VirtualFile file, String content) throws FileNotFoundException {
    PrintStream centralPrinter = null;
    try {
        centralPrinter = new PrintStream(new FileOutputStream(new File(file.getPath())));
        centralPrinter.print(content);
        centralPrinter.close();
    } finally {
        if (centralPrinter != null) {
            centralPrinter.close();
        }
    }
}
Also used : PrintStream(java.io.PrintStream) FileOutputStream(java.io.FileOutputStream) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File)

Example 55 with VirtualFile

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

the class HgAnnotationTest method testAnnotationWithVerboseOption.

public void testAnnotationWithVerboseOption() throws VcsException {
    myRepository.refresh(false, true);
    final VirtualFile file = myRepository.findFileByRelativePath(firstCreatedFile);
    assert file != null;
    List<String> users = Arrays.asList(defaultAuthor, author1, author2);
    final HgFile hgFile = new HgFile(myRepository, VfsUtilCore.virtualToIoFile(file));
    final String date = DateFormatUtil.formatPrettyDate(Clock.getTime());
    List<HgAnnotationLine> annotationLines = new HgAnnotateCommand(myProject).execute(hgFile, null);
    for (int i = 0; i < annotationLines.size(); ++i) {
        HgAnnotationLine line = annotationLines.get(i);
        assertEquals(users.get(i), line.get(HgAnnotation.FIELD.USER));
        assertEquals(date, line.get(HgAnnotation.FIELD.DATE));
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgAnnotationLine(org.zmlx.hg4idea.provider.annotate.HgAnnotationLine) HgAnnotateCommand(org.zmlx.hg4idea.command.HgAnnotateCommand)

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