Search in sources :

Example 6 with HgFileRevision

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

Example 7 with HgFileRevision

use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.

the class HgLogTest method testCommitMessagesWithMultipleLines.

@Test
public void testCommitMessagesWithMultipleLines() throws Exception {
    fillFile(myProjectDir, new String[] { "file.txt" }, "initial contents");
    runHgOnProjectRepo("add", ".");
    runHgOnProjectRepo("commit", "-m", "initial\ncontents");
    fillFile(myProjectDir, new String[] { "file.txt" }, "updated contents");
    runHgOnProjectRepo("commit", "-m", "updated\ncontents");
    List<HgFileRevision> fileLog = new HgLogCommand(myProject).execute(getHgFile("file.txt"), 10, false);
    assertEquals(fileLog.size(), 2, "The file history should show two entries");
}
Also used : HgFileRevision(org.zmlx.hg4idea.HgFileRevision) HgLogCommand(org.zmlx.hg4idea.command.HgLogCommand) Test(org.testng.annotations.Test)

Example 8 with HgFileRevision

use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.

the class HgAnnotationProvider method annotate.

@NotNull
public FileAnnotation annotate(@NotNull VirtualFile file, VcsFileRevision revision) throws VcsException {
    final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, VcsUtil.getFilePath(file.getPath()));
    if (vcsRoot == null) {
        throw new VcsException("vcs root is null for " + file);
    }
    HgRevisionNumber revisionNumber = revision != null ? (HgRevisionNumber) revision.getRevisionNumber() : null;
    final HgFile hgFile = new HgFile(vcsRoot, VfsUtilCore.virtualToIoFile(file));
    HgFile fileToAnnotate = revision instanceof HgFileRevision ? HgUtil.getFileNameInTargetRevision(myProject, revisionNumber, hgFile) : new HgFile(vcsRoot, HgUtil.getOriginalFileName(hgFile.toFilePath(), ChangeListManager.getInstance(myProject)));
    final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(fileToAnnotate, revisionNumber);
    //for uncommitted renamed file we should provide local name otherwise --follow will fail
    final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(revision == null ? hgFile.toFilePath() : fileToAnnotate.toFilePath(), vcsRoot, myProject, null, -1);
    return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revisionNumber != null ? revisionNumber : new HgWorkingCopyRevisionsCommand(myProject).tip(vcsRoot));
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgRevisionNumber(org.zmlx.hg4idea.HgRevisionNumber) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VcsException(com.intellij.openapi.vcs.VcsException) HgAnnotateCommand(org.zmlx.hg4idea.command.HgAnnotateCommand) HgWorkingCopyRevisionsCommand(org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 9 with HgFileRevision

use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.

the class HgAnnotationProvider method annotate.

@NotNull
@Override
public FileAnnotation annotate(@NotNull FilePath path, @NotNull VcsRevisionNumber revision) throws VcsException {
    final VirtualFile vcsRoot = VcsUtil.getVcsRootFor(myProject, path);
    if (vcsRoot == null) {
        throw new VcsException("vcs root is null for " + path);
    }
    final HgFile hgFile = new HgFile(vcsRoot, path);
    final List<HgAnnotationLine> annotationResult = (new HgAnnotateCommand(myProject)).execute(hgFile, (HgRevisionNumber) revision);
    final List<HgFileRevision> logResult = HgHistoryProvider.getHistory(hgFile.toFilePath(), vcsRoot, myProject, (HgRevisionNumber) revision, -1);
    return new HgAnnotation(myProject, hgFile, annotationResult, logResult, revision);
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFile(org.zmlx.hg4idea.HgFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision) VcsException(com.intellij.openapi.vcs.VcsException) HgAnnotateCommand(org.zmlx.hg4idea.command.HgAnnotateCommand) NotNull(org.jetbrains.annotations.NotNull)

Example 10 with HgFileRevision

use of org.zmlx.hg4idea.HgFileRevision in project intellij-community by JetBrains.

the class HgHistoryProvider method reportAppendableHistory.

public void reportAppendableHistory(FilePath filePath, final VcsAppendableHistorySessionPartner partner) throws VcsException {
    final VirtualFile vcsRoot = HgUtil.getHgRootOrThrow(myProject, filePath);
    final List<HgFileRevision> history = getHistory(filePath, vcsRoot, myProject);
    if (history.size() == 0)
        return;
    final VcsAbstractHistorySession emptySession = createAppendableSession(vcsRoot, Collections.emptyList(), null);
    partner.reportCreatedEmptySession(emptySession);
    for (HgFileRevision hgFileRevision : history) {
        partner.acceptRevision(hgFileRevision);
    }
    partner.finished();
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) HgFileRevision(org.zmlx.hg4idea.HgFileRevision)

Aggregations

HgFileRevision (org.zmlx.hg4idea.HgFileRevision)13 HgFile (org.zmlx.hg4idea.HgFile)10 VirtualFile (com.intellij.openapi.vfs.VirtualFile)9 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)7 File (java.io.File)5 HgRevisionNumber (org.zmlx.hg4idea.HgRevisionNumber)3 FilePath (com.intellij.openapi.vcs.FilePath)2 VcsException (com.intellij.openapi.vcs.VcsException)2 NotNull (org.jetbrains.annotations.NotNull)2 HgAnnotateCommand (org.zmlx.hg4idea.command.HgAnnotateCommand)2 HgCommitCommand (org.zmlx.hg4idea.command.HgCommitCommand)2 HgRepository (org.zmlx.hg4idea.repo.HgRepository)2 Change (com.intellij.openapi.vcs.changes.Change)1 Charset (java.nio.charset.Charset)1 Nullable (org.jetbrains.annotations.Nullable)1 Test (org.testng.annotations.Test)1 HgWorkingCopyRevisionsCommand (org.zmlx.hg4idea.command.HgWorkingCopyRevisionsCommand)1