@Override
    public void apply(
        @NotNull MultiMap<VirtualFile, TextFilePatchInProgress> patchGroups,
        @Nullable LocalChangeList localList,
        @Nullable String fileName,
        @Nullable
            TransparentlyFailedValueI<Map<String, Map<String, CharSequence>>, PatchSyntaxException>
                additionalInfo) {
      final List<FilePatch> patches;
      try {
        patches = ApplyPatchSaveToFileExecutor.patchGroupsToOneGroup(patchGroups, myBaseDir);
      } catch (IOException e) {
        myInner.handleException(e, true);
        return;
      }

      final PatchApplier<BinaryFilePatch> patchApplier =
          new PatchApplier<BinaryFilePatch>(
              myVcs.getProject(), myBaseDir, patches, localList, null, null);
      patchApplier.execute(false, true); // 3
      boolean thereAreCreations = false;
      for (FilePatch patch : patches) {
        if (patch.isNewFile() || !Comparing.equal(patch.getAfterName(), patch.getBeforeName())) {
          thereAreCreations = true;
          break;
        }
      }
      if (thereAreCreations) {
        // restore deletion of old directory:
        myInner.next(new DirectoryAddition()); // 2
      }
      appendResolveConflictToContext(myInner); // 1
      appendTailToContextLast(myInner); // 4
      myInner.ping();
    }
 private static boolean needUnshelve(final FilePatch patch, final List<ShelvedChange> changes) {
   for (ShelvedChange change : changes) {
     if (Comparing.equal(patch.getBeforeName(), change.getBeforePath())) {
       return true;
     }
   }
   return false;
 }