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;
  }
Ejemplo n.º 2
0
 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");
 }