Search in sources :

Example 1 with HgFile

use of org.zmlx.hg4idea.HgFile 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 2 with HgFile

use of org.zmlx.hg4idea.HgFile 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)

Example 3 with HgFile

use of org.zmlx.hg4idea.HgFile 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 4 with HgFile

use of org.zmlx.hg4idea.HgFile 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 5 with HgFile

use of org.zmlx.hg4idea.HgFile 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)

Aggregations

HgFile (org.zmlx.hg4idea.HgFile)22 VirtualFile (com.intellij.openapi.vfs.VirtualFile)16 HgFileRevision (org.zmlx.hg4idea.HgFileRevision)9 File (java.io.File)8 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)8 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)5 FilePath (com.intellij.openapi.vcs.FilePath)4 NotNull (org.jetbrains.annotations.NotNull)4 HgAnnotateCommand (org.zmlx.hg4idea.command.HgAnnotateCommand)4 VcsException (com.intellij.openapi.vcs.VcsException)3 ArrayList (java.util.ArrayList)3 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)3 HgRepository (org.zmlx.hg4idea.repo.HgRepository)3 Change (com.intellij.openapi.vcs.changes.Change)2 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)2 HgResolveCommand (org.zmlx.hg4idea.command.HgResolveCommand)2 HgResolveStatusEnum (org.zmlx.hg4idea.command.HgResolveStatusEnum)2 HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)2 HgFileRevisionLogParser (org.zmlx.hg4idea.log.HgFileRevisionLogParser)2 HgAnnotationLine (org.zmlx.hg4idea.provider.annotate.HgAnnotationLine)2