private void deleteListImpl(final ShelvedChangeList changeList) { File file = new File(changeList.PATH); myFileProcessor.delete(file.getName()); for (ShelvedBinaryFile binaryFile : changeList.getBinaryFiles()) { final String path = binaryFile.SHELVED_PATH; if (path != null) { File binFile = new File(path); myFileProcessor.delete(binFile.getName()); } } }
private ShelvedBinaryFile shelveBinaryFile(final Change change) throws IOException { final ContentRevision beforeRevision = change.getBeforeRevision(); final ContentRevision afterRevision = change.getAfterRevision(); File beforeFile = beforeRevision == null ? null : beforeRevision.getFile().getIOFile(); File afterFile = afterRevision == null ? null : afterRevision.getFile().getIOFile(); String shelvedPath = null; if (afterFile != null) { String shelvedName = FileUtil.getNameWithoutExtension(afterFile.getName()); String shelvedExt = FileUtil.getExtension(afterFile.getName()); File shelvedFile = FileUtil.findSequentNonexistentFile( myFileProcessor.getBaseIODir(), shelvedName, shelvedExt); myFileProcessor.saveFile(afterRevision.getFile().getIOFile(), shelvedFile); shelvedPath = shelvedFile.getPath(); } String beforePath = ChangesUtil.getProjectRelativePath(myProject, beforeFile); String afterPath = ChangesUtil.getProjectRelativePath(myProject, afterFile); return new ShelvedBinaryFile(beforePath, afterPath, shelvedPath); }
public static File suggestPatchName( Project project, final String commitMessage, final File file, String extension) { @NonNls String defaultPath = PathUtil.suggestFileName(commitMessage); if (defaultPath.length() == 0) { defaultPath = "unnamed"; } if (defaultPath.length() > (PatchNameChecker.MAX - 10)) { defaultPath = defaultPath.substring(0, PatchNameChecker.MAX - 10); } while (true) { final File nonexistentFile = FileUtil.findSequentNonexistentFile( file, defaultPath, extension == null ? VcsConfiguration.getInstance(project).getPatchFileExtension() : extension); if (nonexistentFile.getName().length() >= PatchNameChecker.MAX) { defaultPath = defaultPath.substring(0, defaultPath.length() - 1); continue; } return nonexistentFile; } }