private static List<CommittedChangeList> writeChangesInReadAction(final ChangesCacheFile cacheFile,
                                                                    @NotNull List<? extends CommittedChangeList> newChanges)
    throws IOException {
    // ensure that changes are loaded before taking read action, to avoid stalling UI
    for (CommittedChangeList changeList : newChanges) {
      changeList.getChanges();
    }
    final Ref<IOException> ref = new Ref<>();
    final List<CommittedChangeList> savedChanges = ReadAction.compute(() -> {
      try {
        return cacheFile.writeChanges(newChanges);    // skip duplicates;
      }
      catch (IOException e) {
        ref.set(e);
        return null;
      }
    });
    if (!ref.isNull()) {
      throw ref.get();
    }
    return savedChanges;
  }
private static List<CommittedChangeList> writeChangesInReadAction(final ChangesCacheFile cacheFile,
                                                                    @NotNull List<? extends CommittedChangeList> newChanges)