Search in sources :

Example 6 with HgVersion

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

the class HgHistoryUtil method readAllHashes.

@NotNull
public static List<TimedVcsCommit> readAllHashes(@NotNull Project project, @NotNull VirtualFile root, @NotNull final Consumer<VcsUser> userRegistry, @NotNull List<String> params) throws VcsException {
    final VcsLogObjectsFactory factory = getObjectsFactoryWithDisposeCheck(project);
    if (factory == null) {
        return Collections.emptyList();
    }
    HgVcs hgvcs = HgVcs.getInstance(project);
    assert hgvcs != null;
    HgVersion version = hgvcs.getVersion();
    String[] templates = ArrayUtil.toStringArray(HgBaseLogParser.constructDefaultTemplate(version));
    HgCommandResult result = getLogResult(project, root, version, -1, params, HgChangesetUtil.makeTemplate(templates));
    return getCommitRecords(project, result, new HgBaseLogParser<TimedVcsCommit>() {

        @Override
        protected TimedVcsCommit convertDetails(@NotNull String rev, @NotNull String changeset, @NotNull SmartList<HgRevisionNumber> parents, @NotNull Date revisionDate, @NotNull String author, @NotNull String email, @NotNull List<String> attributes) {
            List<Hash> parentsHash = new SmartList<>();
            for (HgRevisionNumber parent : parents) {
                parentsHash.add(factory.createHash(parent.getChangeset()));
            }
            userRegistry.consume(factory.createUser(author, email));
            return factory.createTimedCommit(factory.createHash(changeset), parentsHash, revisionDate.getTime());
        }
    });
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) SmartList(com.intellij.util.SmartList) HgVersion(org.zmlx.hg4idea.util.HgVersion) NotNull(org.jetbrains.annotations.NotNull)

Example 7 with HgVersion

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

the class HgLogProvider method readFullDetails.

@Override
public void readFullDetails(@NotNull VirtualFile root, @NotNull List<String> hashes, @NotNull Consumer<VcsFullCommitDetails> commitConsumer) throws VcsException {
    // this method currently is very slow and time consuming
    // so indexing is not to be used for mercurial for now
    HgVcs hgvcs = HgVcs.getInstance(myProject);
    assert hgvcs != null;
    final HgVersion version = hgvcs.getVersion();
    final String[] templates = HgBaseLogParser.constructFullTemplateArgument(true, version);
    HgCommandResult logResult = HgHistoryUtil.getLogResult(myProject, root, version, -1, HgHistoryUtil.prepareHashes(hashes), HgChangesetUtil.makeTemplate(templates));
    if (logResult == null)
        return;
    if (!logResult.getErrorLines().isEmpty())
        throw new VcsException(logResult.getRawError());
    HgHistoryUtil.createFullCommitsFromResult(myProject, root, logResult, version, false).forEach(commitConsumer::consume);
}
Also used : HgCommandResult(org.zmlx.hg4idea.execution.HgCommandResult) HgVcs(org.zmlx.hg4idea.HgVcs) VcsException(com.intellij.openapi.vcs.VcsException) HgVersion(org.zmlx.hg4idea.util.HgVersion)

Example 8 with HgVersion

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

the class HgVersionTest method testParseSupported.

public void testParseSupported() throws Exception {
    for (TestHgVersion test : commonTests) {
        HgVersion version = HgVersion.parseVersionAndExtensionInfo(test.output, Collections.<String>emptyList());
        assertEqualVersions(version, test);
        assertTrue(version.isSupported());
    }
}
Also used : HgVersion(org.zmlx.hg4idea.util.HgVersion)

Example 9 with HgVersion

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

the class HgVersionTest method testParseUnsupported.

public void testParseUnsupported() throws Exception {
    TestHgVersion unsupportedVersion = new TestHgVersion("Mercurial Distributed SCM (version 1.5.1)", 1, 5, 1);
    HgVersion parsedVersion = HgVersion.parseVersionAndExtensionInfo(unsupportedVersion.output, Collections.<String>emptyList());
    assertEqualVersions(parsedVersion, unsupportedVersion);
    assertFalse(parsedVersion.isSupported());
}
Also used : HgVersion(org.zmlx.hg4idea.util.HgVersion)

Example 10 with HgVersion

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

the class HgVersionTest method assertEqualVersions.

private static void assertEqualVersions(HgVersion actual, TestHgVersion expected) throws Exception {
    Field field = HgVersion.class.getDeclaredField("myMajor");
    field.setAccessible(true);
    final int major = field.getInt(actual);
    field = HgVersion.class.getDeclaredField("myMiddle");
    field.setAccessible(true);
    final int middle = field.getInt(actual);
    field = HgVersion.class.getDeclaredField("myMinor");
    field.setAccessible(true);
    final int minor = field.getInt(actual);
    assertEquals(major, expected.major);
    assertEquals(middle, expected.middle);
    assertEquals(minor, expected.minor);
    HgVersion versionFromTest = new HgVersion(expected.major, expected.middle, expected.minor);
    //test equals method
    assertEquals(versionFromTest, actual);
}
Also used : Field(java.lang.reflect.Field) HgVersion(org.zmlx.hg4idea.util.HgVersion)

Aggregations

HgVersion (org.zmlx.hg4idea.util.HgVersion)10 HgCommandResult (org.zmlx.hg4idea.execution.HgCommandResult)7 NotNull (org.jetbrains.annotations.NotNull)5 SmartList (com.intellij.util.SmartList)3 VcsException (com.intellij.openapi.vcs.VcsException)2 HgVcs (org.zmlx.hg4idea.HgVcs)2 Project (com.intellij.openapi.project.Project)1 Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 HgFile (org.zmlx.hg4idea.HgFile)1 HgLogCommand (org.zmlx.hg4idea.command.HgLogCommand)1 HgOutgoingCommand (org.zmlx.hg4idea.command.HgOutgoingCommand)1 HgFileRevisionLogParser (org.zmlx.hg4idea.log.HgFileRevisionLogParser)1