mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] no need to create GitRevision number for all of the parents
This commit is contained in:
@@ -23,7 +23,6 @@ import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.history.VcsRevisionNumber;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import git4idea.GitContentRevision;
|
||||
import git4idea.GitRevisionNumber;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -43,22 +42,25 @@ public class GitChangesParser {
|
||||
@NotNull Date date,
|
||||
@NotNull List<String> parentsHashes) throws VcsException {
|
||||
GitRevisionNumber thisRevision = new GitRevisionNumber(hash, date);
|
||||
List<GitRevisionNumber> parentRevisions = ContainerUtil.map(parentsHashes, GitRevisionNumber::new);
|
||||
GitRevisionNumber parentRevision = parentsHashes.isEmpty() ? null : new GitRevisionNumber(parentsHashes.get(0));
|
||||
|
||||
List<Change> result = new ArrayList<>();
|
||||
for (GitLogStatusInfo statusInfo : statusInfos) {
|
||||
result.add(parseChange(project, root, parentRevisions, statusInfo, thisRevision));
|
||||
result.add(parseChange(project, root, thisRevision, parentRevision, statusInfo));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private static Change parseChange(final Project project, final VirtualFile vcsRoot, final List<GitRevisionNumber> parentRevisions,
|
||||
final GitLogStatusInfo statusInfo, final VcsRevisionNumber thisRevision) throws VcsException {
|
||||
@NotNull
|
||||
private static Change parseChange(@NotNull Project project,
|
||||
@NotNull VirtualFile vcsRoot,
|
||||
@NotNull VcsRevisionNumber thisRevision,
|
||||
@Nullable VcsRevisionNumber parentRevision,
|
||||
@NotNull GitLogStatusInfo statusInfo) throws VcsException {
|
||||
final ContentRevision before;
|
||||
final ContentRevision after;
|
||||
FileStatus status = null;
|
||||
final String path = statusInfo.getFirstPath();
|
||||
@Nullable GitRevisionNumber firstParent = parentRevisions.isEmpty() ? null : parentRevisions.get(0);
|
||||
|
||||
switch (statusInfo.getType()) {
|
||||
case ADDED:
|
||||
@@ -73,13 +75,13 @@ public class GitChangesParser {
|
||||
status = FileStatus.MODIFIED;
|
||||
}
|
||||
final FilePath filePath = GitContentRevision.createPath(vcsRoot, path, true, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false, true);
|
||||
after = GitContentRevision.createRevision(filePath, thisRevision, project, null);
|
||||
break;
|
||||
case DELETED:
|
||||
status = FileStatus.DELETED;
|
||||
final FilePath filePathDeleted = GitContentRevision.createPath(vcsRoot, path, true, true);
|
||||
before = GitContentRevision.createRevision(filePathDeleted, firstParent, project, null);
|
||||
before = GitContentRevision.createRevision(filePathDeleted, parentRevision, project, null);
|
||||
after = null;
|
||||
break;
|
||||
case COPIED:
|
||||
@@ -88,13 +90,13 @@ public class GitChangesParser {
|
||||
String secondPath = statusInfo.getSecondPath();
|
||||
final FilePath filePathAfterRename = GitContentRevision.createPath(vcsRoot, secondPath == null ? path : secondPath,
|
||||
false, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, true, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, true, true);
|
||||
after = GitContentRevision.createRevision(filePathAfterRename, thisRevision, project, null);
|
||||
break;
|
||||
case TYPE_CHANGED:
|
||||
status = FileStatus.MODIFIED;
|
||||
final FilePath filePath2 = GitContentRevision.createPath(vcsRoot, path, true, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, firstParent, project, false, true);
|
||||
before = GitContentRevision.createRevision(vcsRoot, path, parentRevision, project, false, true);
|
||||
after = GitContentRevision.createRevision(filePath2, thisRevision, project, null);
|
||||
break;
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user