private @NotNull ShelvedChangeList createShelfFromChanges(@NotNull Collection<? extends Change> changes,
                                                            String commitMessage,
                                                            boolean markToBeDeleted,
                                                            boolean honorExcludedFromCommit) throws VcsException, IOException {
    if (changes.isEmpty()) {
      LOG.warn("Creating an empty shelved list", new Throwable());
    }
    LOG.debug("Shelving of " + changes.size() + " changes...");

    try {
      return computeWithSpanThrows(myTracer, Shelve.TotalShelving.getName(), (span) -> {
        span.setAttribute("changesSize", changes.size());

        Path schemePatchDir = generateUniqueSchemePatchDir(commitMessage, true);
        List<Change> textChanges = new ArrayList<>();
        final List<ShelvedBinaryFile> binaryFiles = new ArrayList<>();
        for (Change change : changes) {
          if (ChangesUtil.getFilePath(change).getIOFile().isDirectory()) {
            continue;
          }
          if (IdeaTextPatchBuilder.isBinaryRevision(change.getBeforeRevision()) ||
              IdeaTextPatchBuilder.isBinaryRevision(change.getAfterRevision())) {
            binaryFiles.add(shelveBinaryFile(schemePatchDir, change));
          }
          else {
            textChanges.add(change);
          }
        }

        if (textChanges.isEmpty() && binaryFiles.isEmpty()) {
          LOG.warn("Created an empty shelved list, ignored changes: " + changes);
        }

        Path patchFile = getPatchFileInConfigDir(schemePatchDir);
        List<FilePatch> patches = new ArrayList<>(buildAndSavePatchInBatches(patchFile, textChanges, honorExcludedFromCommit));

        ShelvedChangeList changeList = new ShelvedChangeList(patchFile, commitMessage.replace('\n', ' '), binaryFiles,
                                                             createShelvedChangesFromFilePatches(myProject, patchFile, patches));
        changeList.markToDelete(markToBeDeleted);
        changeList.setName(schemePatchDir.getFileName().toString());
        ProgressManager.checkCanceled();
        schemeManager.addScheme(changeList, false);
        return changeList;
      });
    }
    catch (IOException | VcsException | RuntimeException e) {
      throw e;
    }
    catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
private @NotNull ShelvedChangeList createShelfFromChanges(@NotNull Collection<? extends Change> changes,
                                                            String commitMessage,
                                                            boolean markToBeDeleted,
                                                            boolean honorExcludedFromCommit)