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());
}
});
}
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);
}
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());
}
}
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());
}
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);
}
Aggregations