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;
}