void (@NotNull Collection<? extends Change> changes, @Nullable String commitMessage) { if (changes.size() > 0 && !ChangesUtil.hasFileChanges(changes)) { WaitForProgressToShow.runOrInvokeLaterAboveProgress(() -> Messages .showErrorDialog(myProject, VcsBundle.message("shelve.changes.only.directories"), VcsBundle.message("shelve.changes.action")), null, myProject); return; } try { final ShelvedChangeList list = ShelveChangesManager.getInstance(myProject).shelveChanges(changes, commitMessage, true, false, true); ShelvedChangesViewManager.getInstance(myProject).activateView(list); Change[] changesArray = changes.toArray(Change.EMPTY_CHANGE_ARRAY); LocalChangeList changeList = ChangesUtil.getChangeListIfOnlyOne(myProject, changesArray); if (changeList != null) { ChangeListManager.getInstance(myProject).scheduleAutomaticEmptyChangeListDeletion(changeList, true); } } catch (final Exception ex) { LOG.info(ex); WaitForProgressToShow.runOrInvokeLaterAboveProgress( () -> Messages.showErrorDialog(myProject, VcsBundle.message("create.patch.error.title", ex.getMessage()), CommonBundle.getErrorTitle()), ModalityState.nonModal(), myProject); } }