Package org.eclipse.jgit.api.errors

Examples of org.eclipse.jgit.api.errors.PatchApplyException


          apply(f, fh);
          break;
        case DELETE:
          f = getFile(fh.getOldPath(), false);
          if (!f.delete())
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().cannotDeleteFile, f));
          break;
        case RENAME:
          f = getFile(fh.getOldPath(), false);
          File dest = getFile(fh.getNewPath(), false);
          if (!f.renameTo(dest))
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().renameFileFailed, f, dest));
          break;
        case COPY:
          f = getFile(fh.getOldPath(), false);
          byte[] bs = IO.readFully(f);
          FileOutputStream fos = new FileOutputStream(getFile(
              fh.getNewPath(),
              true));
          try {
            fos.write(bs);
          } finally {
            fos.close();
          }
        }
        r.addUpdatedFile(f);
      }
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().patchApplyException, e.getMessage()), e);
    }
    setCallable(false);
    return r;
  }
View Full Code Here


      try {
        File parent = f.getParentFile();
        FileUtils.mkdirs(parent, true);
        FileUtils.createNewFile(f);
      } catch (IOException e) {
        throw new PatchApplyException(MessageFormat.format(
            JGitText.get().createNewFileFailed, f), e);
      }
    return f;
  }
View Full Code Here

        String hunkLine = hunkLines.get(j);
        switch (hunkLine.charAt(0)) {
        case ' ':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          pos++;
          break;
        case '-':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          newLines.remove(hh.getNewStartLine() - 1 + pos);
          break;
        case '+':
View Full Code Here

          apply(f, fh);
          break;
        case DELETE:
          f = getFile(fh.getOldPath(), false);
          if (!f.delete())
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().cannotDeleteFile, f));
          break;
        case RENAME:
          f = getFile(fh.getOldPath(), false);
          File dest = getFile(fh.getNewPath(), false);
          if (!f.renameTo(dest))
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().renameFileFailed, f, dest));
          break;
        case COPY:
          f = getFile(fh.getOldPath(), false);
          byte[] bs = IO.readFully(f);
          FileWriter fw = new FileWriter(getFile(fh.getNewPath(),
              true));
          fw.write(new String(bs));
          fw.close();
        }
        r.addUpdatedFile(f);
      }
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().patchApplyException, e.getMessage()), e);
    }
    setCallable(false);
    return r;
  }
View Full Code Here

      try {
        File parent = f.getParentFile();
        FileUtils.mkdirs(parent, true);
        FileUtils.createNewFile(f);
      } catch (IOException e) {
        throw new PatchApplyException(MessageFormat.format(
            JGitText.get().createNewFileFailed, f), e);
      }
    return f;
  }
View Full Code Here

        String hunkLine = hunkLines.get(j);
        switch (hunkLine.charAt(0)) {
        case ' ':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          pos++;
          break;
        case '-':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          newLines.remove(hh.getNewStartLine() - 1 + pos);
          break;
        case '+':
View Full Code Here

          apply(f, fh);
          break;
        case DELETE:
          f = getFile(fh.getOldPath(), false);
          if (!f.delete())
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().cannotDeleteFile, f));
          break;
        case RENAME:
          f = getFile(fh.getOldPath(), false);
          File dest = getFile(fh.getNewPath(), false);
          if (!f.renameTo(dest))
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().renameFileFailed, f, dest));
          break;
        case COPY:
          f = getFile(fh.getOldPath(), false);
          byte[] bs = IO.readFully(f);
          FileWriter fw = new FileWriter(getFile(fh.getNewPath(),
              true));
          fw.write(new String(bs));
          fw.close();
        }
        r.addUpdatedFile(f);
      }
    } catch (IOException e) {
      throw new PatchApplyException(MessageFormat.format(
          JGitText.get().patchApplyException, e.getMessage()), e);
    }
    setCallable(false);
    return r;
  }
View Full Code Here

    File f = new File(getRepository().getWorkTree(), path);
    if (create)
      try {
        FileUtils.createNewFile(f);
      } catch (IOException e) {
        throw new PatchApplyException(MessageFormat.format(
            JGitText.get().createNewFileFailed, f), e);
      }
    return f;
  }
View Full Code Here

        String hunkLine = hunkLines.get(j);
        switch (hunkLine.charAt(0)) {
        case ' ':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          pos++;
          break;
        case '-':
          if (!newLines.get(hh.getNewStartLine() - 1 + pos).equals(
              hunkLine.substring(1))) {
            throw new PatchApplyException(MessageFormat.format(
                JGitText.get().patchApplyException, hh));
          }
          newLines.remove(hh.getNewStartLine() - 1 + pos);
          break;
        case '+':
View Full Code Here

TOP

Related Classes of org.eclipse.jgit.api.errors.PatchApplyException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.