private @NotNull GitFileRevision createParentRevision(@NotNull VirtualFile root,
                                                        @NotNull GitFileRevision currentRevision,
                                                        @NotNull String parentHash,
                                                        @Nullable List<? extends VcsFileRevision> revisions) throws VcsException {
    if (revisions != null) {
      for (VcsFileRevision revision : revisions) {
        if (((GitFileRevision)revision).getHash().equals(parentHash)) {
          return (GitFileRevision)revision;
        }
      }
    }

    FilePath currentRevisionPath = currentRevision.getPath();
    if (currentRevisionPath.isDirectory()) {
      // for directories the history doesn't follow renames
      return makeRevisionFromHash(currentRevisionPath, parentHash);
    }

    // can't limit by the path: in that case rename information will be missed
    Collection<Change> changes = GitChangeUtils.getDiff(myProject, root, parentHash, currentRevision.getHash(), null);
    for (Change change : changes) {
      ContentRevision afterRevision = change.getAfterRevision();
      ContentRevision beforeRevision = change.getBeforeRevision();
      if (afterRevision != null && afterRevision.getFile().equals(currentRevisionPath)) {
        // if the file was renamed, taking the path how it was in the parent; otherwise the path didn't change
        FilePath path = (beforeRevision != null ? beforeRevision.getFile() : afterRevision.getFile());
        return makeRevisionFromHash(path, parentHash);
      }
    }
    LOG.error(String.format("Could not find parent revision. Will use the path from parent revision. Current revision: %s, parent hash: %s",
                            currentRevision, parentHash));
    return makeRevisionFromHash(currentRevisionPath, parentHash);
  }
private @NotNull GitFileRevision createParentRevision(@NotNull VirtualFile root,
                                                        @NotNull GitFileRevision currentRevision,
                                                        @NotNull String parentHash,
                                                        @Nullable List<? extends VcsFileRevision> revisions)