private static FilePatchStatus getStatus(final TextFilePatch patch) {
    final String beforeName = patch.getBeforeName().replace("\\", "/");
    final String afterName = patch.getAfterName().replace("\\", "/");

    if (patch.isNewFile() || (beforeName == null)) {
      return FilePatchStatus.ADDED;
    } else if (patch.isDeletedFile() || (afterName == null)) {
      return FilePatchStatus.DELETED;
    }

    if (beforeName.equals(afterName)) return FilePatchStatus.MODIFIED;
    return FilePatchStatus.MOVED_OR_RENAMED;
  }
 private String loadContent(final TextFilePatch patch) throws ApplyPatchException {
   if (patch.isNewFile()) {
     return patch.getNewFileText();
   }
   if (patch.isDeletedFile()) {
     return null;
   }
   final GenericPatchApplier applier =
       new GenericPatchApplier(getBaseContent(), patch.getHunks());
   if (applier.execute()) {
     return applier.getAfter();
   }
   throw new ApplyPatchException("Apply patch conflict");
 }
  public List<FilePatchInProgress> execute(final List<TextFilePatch> list) {
    final List<TextFilePatch> creations = new LinkedList<TextFilePatch>();

    final PatchBaseDirectoryDetector directoryDetector =
        PatchBaseDirectoryDetector.getInstance(myProject);
    for (TextFilePatch patch : list) {
      if (patch.isNewFile() || (patch.getBeforeName() == null)) {
        creations.add(patch);
        continue;
      }
      final String fileName = patch.getBeforeFileName();
      final Collection<VirtualFile> files =
          ApplicationManager.getApplication()
              .runReadAction(
                  new Computable<Collection<VirtualFile>>() {
                    public Collection<VirtualFile> compute() {
                      return directoryDetector.findFiles(fileName);
                    }
                  });
      for (AutoMatchStrategy strategy : myStrategies) {
        strategy.acceptPatch(patch, files);
      }
    }

    for (AutoMatchStrategy strategy : myStrategies) {
      strategy.beforeCreations();
    }
    // then try to match creations
    for (TextFilePatch creation : creations) {
      for (AutoMatchStrategy strategy : myStrategies) {
        strategy.processCreation(creation);
      }
    }

    for (AutoMatchStrategy strategy : myStrategies) {
      if (strategy.succeeded()) {
        return strategy.getResult();
      }
    }
    return myStrategies.get(myStrategies.size() - 1).getResult();
  }