[git] method parse accepts specific parent revision, not list of all parents

This commit is contained in:
Julia Beliaeva
2017-07-12 18:05:28 +03:00
parent 3159dacebb
commit b909e10a05
3 changed files with 12 additions and 9 deletions
+8 -6
View File
@@ -178,7 +178,7 @@ public final class GitCommit extends VcsCommitMetadataImpl implements VcsFullCom
@NotNull
private ParsedChanges parseChanges() throws VcsException {
List<Change> mergedChanges = parseStatusInfo(getMergedStatusInfo(), ContainerUtil.map(getParents(), Hash::asString));
List<Change> mergedChanges = parseStatusInfo(getMergedStatusInfo(), 0);
List<Collection<Change>> changes = computeChanges(mergedChanges);
ParsedChanges parsedChanges = new ParsedChanges(mergedChanges, changes);
myChanges.compareAndSet(this, parsedChanges);
@@ -230,17 +230,19 @@ public final class GitCommit extends VcsCommitMetadataImpl implements VcsFullCom
else {
List<Collection<Change>> changes = ContainerUtil.newArrayListWithCapacity(myChangesOutput.size());
for (int i = 0; i < myChangesOutput.size(); i++) {
List<GitLogStatusInfo> statusInfos = myChangesOutput.get(i);
changes.add(parseStatusInfo(statusInfos, Collections.singletonList(getParents().get(i).asString())));
changes.add(parseStatusInfo(myChangesOutput.get(i), i));
}
return changes;
}
}
@NotNull
private List<Change> parseStatusInfo(@NotNull List<GitLogStatusInfo> changes,
@NotNull List<String> parentHashes) throws VcsException {
return GitChangesParser.parse(myProject, getRoot(), changes, getId().asString(), new Date(getCommitTime()), parentHashes);
private List<Change> parseStatusInfo(@NotNull List<GitLogStatusInfo> changes, int parentIndex) throws VcsException {
String parentHash = null;
if (parentIndex < getParents().size()) {
parentHash = getParents().get(parentIndex).asString();
}
return GitChangesParser.parse(myProject, getRoot(), changes, getId().asString(), new Date(getCommitTime()), parentHash);
}
/*
@@ -40,9 +40,9 @@ public class GitChangesParser {
@NotNull List<GitLogStatusInfo> statusInfos,
@NotNull String hash,
@NotNull Date date,
@NotNull List<String> parentsHashes) throws VcsException {
@Nullable String parentsHash) throws VcsException {
GitRevisionNumber thisRevision = new GitRevisionNumber(hash, date);
GitRevisionNumber parentRevision = parentsHashes.isEmpty() ? null : new GitRevisionNumber(parentsHashes.get(0));
GitRevisionNumber parentRevision = parentsHash == null ? null : new GitRevisionNumber(parentsHash);
List<Change> result = new ArrayList<>();
for (GitLogStatusInfo statusInfo : statusInfos) {
@@ -256,7 +256,8 @@ class GitLogRecord {
@NotNull
public List<Change> parseChanges(@NotNull Project project, @NotNull VirtualFile vcsRoot) throws VcsException {
return GitChangesParser.parse(project, vcsRoot, myStatusInfo, getHash(), getDate(), Arrays.asList(getParentsHashes()));
String[] hashes = getParentsHashes();
return GitChangesParser.parse(project, vcsRoot, myStatusInfo, getHash(), getDate(), hashes.length == 0 ? null : hashes[0]);
}
/**