public static File getCommonFileAncestor(File file1, File file2) { String path1 = file1.getAbsolutePath(); String path2 = file2.getAbsolutePath(); path1 = validateFilePath(path1); path2 = validateFilePath(path2); String commonPath = getCommonPathAncestor(path1, path2); if (commonPath != null) { return new File(commonPath); } return null; }
public static boolean isChildOf(File parentFile, File childFile) { if (parentFile == null || childFile == null) { return false; } childFile = new File(SVNPathUtil.validateFilePath(childFile .getParentFile().getAbsolutePath())); parentFile = new File(SVNPathUtil.validateFilePath(parentFile .getAbsolutePath())); while (childFile != null) { if (childFile.equals(parentFile)) { return true; } childFile = childFile.getParentFile(); } return false; }
public static String formatCertificatePath(String path) { path = new File(path).getAbsolutePath(); path = SVNPathUtil.validateFilePath(path); if (SVNFileUtil.isWindows && path.length() >= 3 && path.charAt(1) == ':' && path.charAt(2) == '/' && Character.isLowerCase(path.charAt(0))) { path = Character.toUpperCase(path.charAt(0)) + path.substring(1); } return path; } }
private SvnTarget(File file, SVNRevision pegRevision) { this.file = new File(SVNPathUtil.validateFilePath(file.getAbsolutePath())); setPegRevision(pegRevision); }
private boolean verifyPaths(SVNFileType srcType, SVNFileType dstType, SvnCopyPair copyPair, int copyPairsCount, boolean move) throws SVNException { if (srcType == SVNFileType.NONE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.NODE_UNKNOWN_KIND, "Path ''{0}'' does not exist", copyPair.source); SVNErrorManager.error(err, SVNLogType.WC); } if (dstType != SVNFileType.NONE) { if (move && copyPairsCount == 1) { File srcDir = SVNFileUtil.getFileDir(copyPair.source); File dstDir = SVNFileUtil.getFileDir(copyPair.dst); if (srcDir.equals(dstDir)) { // check if it is case-only rename if (copyPair.source.getName().equalsIgnoreCase(copyPair.dst.getName())) { copyPair.dstParent = new File(SVNPathUtil.validateFilePath(dstDir.getAbsolutePath())); copyPair.baseName = SVNFileUtil.getFileName(copyPair.dst); return true; } } } SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_EXISTS, "Path ''{0}'' already exists", copyPair.dst); SVNErrorManager.error(err, SVNLogType.WC); } return false; }
String path = SVNPathUtil.validateFilePath(sshAuth.getPrivateKeyFile().getAbsolutePath()); values.put("passphrase", sshAuth.getPassphrase()); values.put("key", path);
String addedPathStr = SVNPathUtil.validateFilePath(addedPath.getAbsolutePath()); String targetMergePathStr = SVNPathUtil.validateFilePath(targetMergePath.myPath.getAbsolutePath()); String commonAncestorPath = SVNPathUtil.getCommonPathAncestor(addedPathStr, targetMergePathStr); String relativeAddedPath = SVNPathUtil.getRelativePath(commonAncestorPath, addedPathStr);
path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())).getAbsoluteFile(); try { if (!force) {
String addedPathStr = SVNPathUtil.validateFilePath(addedPath.getAbsolutePath()); String targetMergePathStr = SVNPathUtil.validateFilePath(targetMergePath.myPath.getAbsolutePath()); String commonAncestorPath = SVNPathUtil.getCommonPathAncestor(addedPathStr, targetMergePathStr); String relativeAddedPath = SVNPathUtil.getRelativePath(commonAncestorPath, addedPathStr);
} else { String srcParentPath = srcParent.getAbsolutePath().replace(File.separatorChar, '/'); srcParentPath = SVNPathUtil.validateFilePath(srcParentPath); String dstParentPath = dstParent.getAbsolutePath().replace(File.separatorChar, '/'); dstParentPath = SVNPathUtil.validateFilePath(dstParentPath); if (srcType == SVNFileType.DIRECTORY && SVNPathUtil.isAncestor(srcParentPath, dstParentPath)) {
private boolean move(Collection<SvnCopyPair> pairs) throws SVNException { for (SvnCopyPair copyPair : pairs) { Collection<File> lockPaths = new HashSet<File>(); Collection<File> lockedPaths = new HashSet<File>(); checkCancelled(); File sourceParent = new File(SVNPathUtil.validateFilePath(SVNFileUtil.getParentFile(copyPair.source).getAbsolutePath())); if (sourceParent.equals(copyPair.dstParent) || SVNWCUtils.isChild(sourceParent, copyPair.dstParent)) { lockPaths.add(sourceParent); } else if (SVNWCUtils.isChild(copyPair.dstParent, sourceParent)) { lockPaths.add(copyPair.dstParent); } else { lockPaths.add(sourceParent); lockPaths.add(copyPair.dstParent); } try { for (File file : lockPaths) { lockedPaths.add(getWcContext().acquireWriteLock(file, false, true)); } move(getWcContext(), copyPair.source, SVNFileUtil.createFilePath(copyPair.dstParent, copyPair.baseName), getOperation().isMetadataOnly() || getOperation().isVirtual()); } finally { for (File file : lockedPaths) { getWcContext().releaseWriteLock(file); } } } return false; }
} else { String srcParentPath = srcParent.getAbsolutePath().replace(File.separatorChar, '/'); srcParentPath = SVNPathUtil.validateFilePath(srcParentPath); String dstParentPath = dstParent.getAbsolutePath().replace(File.separatorChar, '/'); dstParentPath = SVNPathUtil.validateFilePath(dstParentPath); if (srcType == SVNFileType.DIRECTORY && SVNPathUtil.isAncestor(srcParentPath, dstParentPath)) {
} else { String srcParentPath = srcParent.getAbsolutePath().replace(File.separatorChar, '/'); srcParentPath = SVNPathUtil.validateFilePath(srcParentPath); String dstParentPath = dstParent.getAbsolutePath().replace(File.separatorChar, '/'); dstParentPath = SVNPathUtil.validateFilePath(dstParentPath); if (srcType == SVNFileType.DIRECTORY && SVNPathUtil.isAncestor(srcParentPath, dstParentPath)) {
public static boolean isEntrySwitched(File path, SVNEntry entry) throws SVNException { path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())).getAbsoluteFile(); File parent = path.getParentFile(); if (parent == null) {
public static boolean isEntrySwitched(File path, SVNEntry entry) throws SVNException { path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())).getAbsoluteFile(); File parent = path.getParentFile(); if (parent == null) {
public static boolean isEntrySwitched(File path, SVNEntry entry) throws SVNException { path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())).getAbsoluteFile(); File parent = path.getParentFile(); if (parent == null) {
path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())); SVNWCAccess wcAccess = createWCAccess(); try {
SVNErrorManager.error(err); path = new File(SVNPathUtil.validateFilePath(path.getAbsolutePath())).getAbsoluteFile(); getDiffGenerator().init(path.getAbsolutePath(), path.getAbsolutePath()); if (!(rM == SVNRevision.BASE || rM == SVNRevision.WORKING || rM == SVNRevision.COMMITTED)) {
file = new File(SVNPathUtil.validateFilePath(file.getAbsolutePath())); SVNWCAccess wcAccess = createWCAccess(); SVNAdminAreaInfo adminInfo = null;
copyPair.dstParent = new File(SVNPathUtil.validateFilePath(SVNFileUtil.getParentFile(copyPair.dst).getAbsolutePath())); copyPair.baseName = SVNFileUtil.getFileName(copyPair.dst);