private SVNNodeKind getDiskKind(String path) { File file = getFile(path); SVNFileType type = null; type = SVNFileType.getType(file); if (type == SVNFileType.UNKNOWN) { return SVNNodeKind.UNKNOWN; } if (myIsDryRun && isPathDeleted(path)) { return SVNNodeKind.NONE; } return SVNFileType.getNodeKind(type); }
public static CheckSpecialInfo checkSpecialPath(File localAbspath) { CheckSpecialInfo info = new CheckSpecialInfo(); SVNFileType fileType = SVNFileType.getType(localAbspath); info.kind = SVNFileType.getNodeKind(fileType); info.isSpecial = !SVNFileUtil.symlinksSupported() ? false : fileType == SVNFileType.SYMLINK; return info; }
private SVNNodeKind getDiskKind(String path) { File file = getFile(path); SVNFileType type = null; type = SVNFileType.getType(file); if (type == SVNFileType.UNKNOWN) { return SVNNodeKind.UNKNOWN; } if (myIsDryRun && isPathDeleted(path)) { return SVNNodeKind.NONE; } return SVNFileType.getNodeKind(type); }
private SVNNodeKind getDiskKind(String path) { File file = getFile(path); SVNFileType type = null; type = SVNFileType.getType(file); if (type == SVNFileType.UNKNOWN) { return SVNNodeKind.UNKNOWN; } if (myIsDryRun && isPathDeleted(path)) { return SVNNodeKind.NONE; } return SVNFileType.getNodeKind(type); }
private RemoveArtifactInfo removeArtifactFileIfExists(File wriAbsPath, File artifactFileAbsPath) throws SVNException { RemoveArtifactInfo removeArtifactInfo = new RemoveArtifactInfo(); removeArtifactInfo.workItem = null; if (artifactFileAbsPath != null) { SVNNodeKind nodeKind = SVNFileType.getNodeKind(SVNFileType.getType(artifactFileAbsPath)); if (nodeKind == SVNNodeKind.FILE) { removeArtifactInfo.workItem = wqBuildFileRemove(wriAbsPath, artifactFileAbsPath); removeArtifactInfo.fileFound = true; } } return removeArtifactInfo; }
public static boolean getVersionedSubdirs(SVNWCAccess access, File localAbsPath, ArrayList<File> children, boolean isCalculateDoDeleteDir, boolean isSkipMissing) throws SVNException { boolean isDoDeleteDir = false; Map<String, SVNEntry> entries = readEntries(access, localAbsPath); SVNEntry thisDir = null; for (Iterator<String> names = entries.keySet().iterator(); names.hasNext();) { String name = (String) names.next(); SVNEntry entry = (SVNEntry) entries.get(name); /* skip "this dir" */ if ("".equals(name)) { thisDir = entry; continue; } else if (entry == null || entry.getKind() != SVNNodeKind.DIR) { continue; } File childAbsPath = SVNFileUtil.createFilePath(localAbsPath, name); if (isSkipMissing) { SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(childAbsPath)); if (kind != SVNNodeKind.DIR) continue; } children.add(childAbsPath); } if (isCalculateDoDeleteDir) { isDoDeleteDir = (thisDir != null && thisDir.isScheduledForDeletion() && !thisDir.isKeepLocal()); } return isDoDeleteDir; }
public boolean accept(File file) throws SVNException { final SVNFileType fileType = SVNFileType.getType(file); return filterCallback.filter(SVNFileUtil.getFilePath(file), getNodeKind(SVNFileType.getNodeKind(fileType)), fileType == SVNFileType.SYMLINK); } };
public static File ensureDirectoryExists(File path) throws SVNException { SVNFileType type = SVNFileType.getType(path); SVNNodeKind kind = SVNFileType.getNodeKind(type); if (kind != SVNNodeKind.NONE && kind != SVNNodeKind.DIR) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "''{0}'' is not a directory", path); SVNErrorManager.error(error, SVNLogType.WC); } else if (kind == SVNNodeKind.NONE) { boolean created = path.mkdirs(); if (!created) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Unable to make directories", path); SVNErrorManager.error(error, SVNLogType.WC); } } return path; }
public static File ensureDirectoryExists(File path) throws SVNException { SVNFileType type = SVNFileType.getType(path); SVNNodeKind kind = SVNFileType.getNodeKind(type); if (kind != SVNNodeKind.NONE && kind != SVNNodeKind.DIR) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "''{0}'' is not a directory", path); SVNErrorManager.error(error, SVNLogType.WC); } else if (kind == SVNNodeKind.NONE) { boolean created = path.mkdirs(); if (!created) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Unable to make directories", path); SVNErrorManager.error(error, SVNLogType.WC); } } return path; }
public static File ensureDirectoryExists(File path) throws SVNException { SVNFileType type = SVNFileType.getType(path); SVNNodeKind kind = SVNFileType.getNodeKind(type); if (kind != SVNNodeKind.NONE && kind != SVNNodeKind.DIR) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "''{0}'' is not a directory", path); SVNErrorManager.error(error, SVNLogType.WC); } else if (kind == SVNNodeKind.NONE) { boolean created = path.mkdirs(); if (!created) { SVNErrorMessage error = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, "Unable to make directories", path); SVNErrorManager.error(error, SVNLogType.WC); } } return path; }
private static void doArbitraryDirsDiff(File localAbsPath1, File localAbsPath2, File rootAbsPath1, File rootAbsPath2, SVNDepth depth, SVNWCContext context, ISvnDiffCallback callback, ISVNCanceller canceller) throws SVNException { SVNNodeKind kind1 = null; try { kind1 = SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath1.getCanonicalFile())); } catch (IOException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e); SVNErrorManager.error(errorMessage, SVNLogType.WC); } ArbitraryDiffWalker diffWalker = new ArbitraryDiffWalker(); diffWalker.recursingWithinAddedSubtree = (kind1 != SVNNodeKind.DIR); diffWalker.root1AbsPath = rootAbsPath1 != null ? rootAbsPath1 : localAbsPath1; diffWalker.root2AbsPath = rootAbsPath2 != null ? rootAbsPath2 : localAbsPath2; diffWalker.recursingWithinAdmDir = false; if (depth.compareTo(SVNDepth.IMMEDIATES) <= 0) { arbitraryDiffThisDir(diffWalker, localAbsPath1, depth, context, callback, canceller); } else if (depth == SVNDepth.INFINITY) { walkDirectory(diffWalker.recursingWithinAddedSubtree ? localAbsPath2 : localAbsPath1, diffWalker, context, callback, canceller); } }
public static void doArbitraryNodesDiff(SvnTarget target1, SvnTarget target2, SVNDepth depth, SVNWCContext context, ISvnDiffCallback callback, ISVNCanceller canceller) throws SVNException { File path1 = target1.getFile(); File path2 = target2.getFile(); SVNNodeKind kind1 = SVNFileType.getNodeKind(SVNFileType.getType(path1)); SVNNodeKind kind2 = SVNFileType.getNodeKind(SVNFileType.getType(path2)); if (kind1 != kind2) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.NODE_UNEXPECTED_KIND, "''{0}'' is not the same node kind as ''{1}''", path1, path2); SVNErrorManager.error(errorMessage, SVNLogType.WC); } if (depth == SVNDepth.UNKNOWN) { depth = SVNDepth.INFINITY; } if (kind1 == SVNNodeKind.FILE) { doArbitraryFilesDiff(path1, path2, SVNFileUtil.createFilePath(SVNFileUtil.getFileName(path1)), false, false, null, context, callback, canceller); } else if (kind1 == SVNNodeKind.DIR) { doArbitraryDirsDiff(path1, path2, null, null, depth, context, callback, canceller); } else { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.NODE_UNEXPECTED_KIND, "''{0}'' is not a file or directory", kind1 == SVNNodeKind.NONE ? path1 : path2); SVNErrorManager.error(errorMessage, SVNLogType.WC); } }
public void runOperation(SVNWCContext ctx, File wcRootAbspath, SVNSkel workItem) throws SVNException { File localRelPath = SVNFileUtil.createFilePath(workItem.first().next().getValue()); File localAbsPath = SVNFileUtil.createFilePath(wcRootAbspath, localRelPath); SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath)); if (kind != SVNNodeKind.NONE && kind != SVNNodeKind.DIR) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_NOT_DIRECTORY, "''{0}'' is not a directory", localAbsPath); SVNErrorManager.error(errorMessage, SVNLogType.WC); } else if (kind == SVNNodeKind.NONE) { SVNFileUtil.ensureDirectoryExists(localAbsPath); } else { SVNErrorManager.assertionFailure(kind == SVNNodeKind.DIR, null, SVNLogType.WC); } } }
public static boolean checkPristine(SVNWCDbRoot root, SvnChecksum sha1Checksum) throws SVNException { boolean haveRow = false; SVNSqlJetStatement stmt = root.getSDb().getStatement(SVNWCDbStatements.SELECT_PRISTINE_MD5_CHECKSUM); stmt.bindf("s", sha1Checksum); try { haveRow = stmt.next(); } finally { stmt.reset(); } if (haveRow) { File pristineAbspath = getPristineFileName(root, sha1Checksum, false); SVNNodeKind kindOnDisk = SVNFileType.getNodeKind(SVNFileType.getType(pristineAbspath)); if (kindOnDisk != SVNNodeKind.FILE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_DB_ERROR, "The pristine text with checksum ''{0}'' was found in the DB but not on disk", sha1Checksum); SVNErrorManager.error(err, SVNLogType.WC); } } return haveRow; }
public SVNCommitInfo closeEdit() throws SVNException { final SVNNodeKind localKind = SVNFileType.getNodeKind(SVNFileType.getType(myPath)); final SVNNodeKind kind = myWCContext.readKind(myPath, false); File anchor_abspath; String target_name; boolean skip_root; if (kind == SVNNodeKind.FILE && localKind == SVNNodeKind.FILE) { anchor_abspath = SVNFileUtil.getFileDir(myPath); target_name = SVNFileUtil.getFileName(myPath); skip_root = true; } else if (kind == SVNNodeKind.DIR && localKind == SVNNodeKind.DIR) { anchor_abspath = myPath; target_name = null; skip_root = false; } else { anchor_abspath = SVNFileUtil.getFileDir(myPath); target_name = SVNFileUtil.getFileName(myPath); skip_root = false; } SVNFileType fileType = SVNFileType.getType(anchor_abspath); getDirStatus(anchor_abspath, target_name, skip_root, null, null, fileType, myGlobalIgnores, myDepth, myIsReportAll, true, getDefaultHandler()); return null; }
private void doExternalsInfo(Map<File, File> externals, SVNDepth depth) throws SVNException { for (Map.Entry<File, File> entry : externals.entrySet()) { final File localAbsPath = entry.getKey(); final File definingAbsPath = entry.getValue(); final Structure<StructureFields.ExternalNodeInfo> externalNodeInfoStructure = SvnWcDbExternals.readExternal(getWcContext(), localAbsPath, definingAbsPath, StructureFields.ExternalNodeInfo.kind, StructureFields.ExternalNodeInfo.revision); if (externalNodeInfoStructure != null) { ISVNWCDb.SVNWCDbKind externalKind = externalNodeInfoStructure.get(StructureFields.ExternalNodeInfo.kind); long optRev = externalNodeInfoStructure.lng(StructureFields.ExternalNodeInfo.revision); if (externalKind != SVNWCDbKind.Dir) { continue; } final SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(localAbsPath)); if (kind != SVNNodeKind.DIR) { continue; } handleEvent(SVNEventFactory.createSVNEvent(localAbsPath, SVNNodeKind.UNKNOWN, null, SVNRepository.INVALID_REVISION, SVNStatusType.UNKNOWN, SVNStatusType.UNKNOWN, SVNStatusType.LOCK_UNKNOWN, SVNEventAction.INFO_EXTERNAL, SVNEventAction.INFO_EXTERNAL, null, null)); final SvnOperationFactory operationFactory = getOperation().getOperationFactory(); final SvnGetInfo getInfo = operationFactory.createGetInfo(); getInfo.setSingleTarget(SvnTarget.fromFile(localAbsPath)); getInfo.setFetchExcluded(getOperation().isFetchExcluded()); getInfo.setFetchActualOnly(getOperation().isFetchActualOnly()); getInfo.setIncludeExternals(getOperation().isIncludeExternals()); getInfo.run(); } } }
public SVNSkel wqBuildFileMove(File srcAbspath, File dstAbspath) throws SVNException { assert (SVNFileUtil.isAbsolute(srcAbspath)); assert (SVNFileUtil.isAbsolute(dstAbspath)); SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(srcAbspath)); if (kind == SVNNodeKind.NONE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND, "''{0}'' not found", srcAbspath); SVNErrorManager.error(err, SVNLogType.WC); } // getDb().getWCRoot(dirAbspath) SVNSkel workItem = SVNSkel.createEmptyList(); workItem.prependPath(getRelativePath(dstAbspath)); workItem.prependPath(getRelativePath(srcAbspath)); workItem.prependString(WorkQueueOperation.FILE_MOVE.getOpName()); SVNSkel result = SVNSkel.createEmptyList(); result.appendChild(workItem); return result; }
public SVNSkel wqBuildFileMove(File anchorPath, File srcAbspath, File dstAbspath) throws SVNException { assert (SVNFileUtil.isAbsolute(srcAbspath)); assert (SVNFileUtil.isAbsolute(dstAbspath)); SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(srcAbspath)); if (kind == SVNNodeKind.NONE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND, "''{0}'' not found", srcAbspath); SVNErrorManager.error(err, SVNLogType.WC); } File srcRelPath = getDb().toRelPath(anchorPath, srcAbspath); File dstRelPath = getDb().toRelPath(anchorPath, dstAbspath); SVNSkel workItem = SVNSkel.createEmptyList(); workItem.prependPath(dstRelPath); workItem.prependPath(srcRelPath); workItem.prependString(WorkQueueOperation.FILE_MOVE.getOpName()); SVNSkel result = SVNSkel.createEmptyList(); result.appendChild(workItem); return result; }
public static SVNSkel wqBuildFileCopyTranslated(SVNWCDb db, File localAbspath, File srcAbspath, File dstAbspath) throws SVNException { assert (SVNFileUtil.isAbsolute(localAbspath)); assert (SVNFileUtil.isAbsolute(srcAbspath)); assert (SVNFileUtil.isAbsolute(dstAbspath)); SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(srcAbspath)); if (kind == SVNNodeKind.NONE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_PATH_NOT_FOUND, "''{0}'' not found", srcAbspath); SVNErrorManager.error(err, SVNLogType.WC); } SVNSkel workItem = SVNSkel.createEmptyList(); workItem.prependPath(getRelativePath(db, dstAbspath)); workItem.prependPath(getRelativePath(db, srcAbspath)); workItem.prependPath(getRelativePath(db, localAbspath)); workItem.prependString(WorkQueueOperation.FILE_COPY_TRANSLATED.getOpName()); SVNSkel result = SVNSkel.createEmptyList(); result.appendChild(workItem); return result; }
private void doDiffWCWC(SvnTarget target1, SVNRevision revision1, SvnTarget target2, SVNRevision revision2, SVNDepth depth, boolean useAncestry, ISVNDiffStatusHandler handler) throws SVNException { assert !target1.isURL(); assert !target2.isURL(); File path1 = target1.getFile(); File path2 = target2.getFile(); if (!path1.equals(path2) || (!(revision1 == SVNRevision.BASE && revision2 == SVNRevision.WORKING))) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS, "Summarized diffs are only supported between a path's text-base and its working files at this time"); SVNErrorManager.error(errorMessage, SVNLogType.WC); } SVNNodeKind kind = SVNFileType.getNodeKind(SVNFileType.getType(path1)); String targetString1 = (kind == SVNNodeKind.DIR) ? "" : SVNFileUtil.getFileName(path1); File basePath = (kind == SVNNodeKind.DIR) ? path1 : SVNFileUtil.getParentFile(path1); SVNURL baseUrl = kind == SVNNodeKind.DIR ? getRepositoryAccess().getTargetURL(target1) : getRepositoryAccess().getTargetURL(SvnTarget.fromFile(SVNFileUtil.getParentFile(target1.getFile()))); ISvnDiffCallback callback = new SvnDiffSummarizeCallback(path1, false, baseUrl, basePath, handler); SvnNgDiffUtil.doDiffWCWC(path1, getRepositoryAccess(), getWcContext(), depth, useAncestry, getOperation().isRecurseIntoDeletedDirectories(), getOperation().getApplicableChangelists(), false, false, null, callback, getOperation().getEventHandler()); }