public void setAutoBases(@NotNull final Collection<VirtualFile> autoBases) {
   final String path =
       myPatch.getBeforeName() == null ? myPatch.getAfterName() : myPatch.getBeforeName();
   for (VirtualFile autoBase : autoBases) {
     final VirtualFile willBeBase = PathMerger.getBase(autoBase, path);
     if (willBeBase != null) {
       myAutoBases.add(willBeBase);
     }
   }
 }
 @Nullable
 public TextFilePatch loadFilePatch(final Project project, CommitContext commitContext)
     throws IOException, PatchSyntaxException {
   List<TextFilePatch> filePatches =
       ShelveChangesManager.loadPatches(project, myPatchPath, commitContext);
   for (TextFilePatch patch : filePatches) {
     if (myBeforePath.equals(patch.getBeforeName())) {
       return patch;
     }
   }
   return null;
 }
  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;
  }
  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();
  }
  public void setNewBase(final VirtualFile base) {
    myBase = base;
    myNewContentRevision = null;
    myCurrentRevision = null;
    myAfterFile = null;
    myConflicts = null;

    final String beforeName = myPatch.getBeforeName();
    if (beforeName != null) {
      myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), beforeName);
      myCurrentBase =
          myIoCurrentBase == null ? null : VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
      myBaseExists = (myCurrentBase != null) && myCurrentBase.exists();
    } else {
      // creation
      final String afterName = myPatch.getAfterName();
      myBaseExists = true;
      myIoCurrentBase = PathMerger.getFile(new File(myBase.getPath()), afterName);
      myCurrentBase = VcsUtil.getVirtualFileWithRefresh(myIoCurrentBase);
    }
  }
 public Couple<String> getKey() {
   return Couple.newOne(myPatch.getBeforeName(), myPatch.getAfterName());
 }