public static boolean isAncestor(File parent, File child) { if (parent == null || child == null) { return false; } if (parent.equals(child)) { return true; } final String parentPath = parent.getPath().replace(File.separatorChar, '/'); final String childPath = child.getPath().replace(File.separatorChar, '/'); return SVNPathUtil.isAncestor(parentPath, childPath); }
private void removeAbsentChildren(File targetWCPath, Map<File, MergePath> childrenWithMergeInfo) { for (Iterator<File> children = childrenWithMergeInfo.keySet().iterator(); children.hasNext();) { File childPath = children.next(); MergePath child = (MergePath) childrenWithMergeInfo.get(childPath); String topDir = targetWCPath.getAbsolutePath().replace(File.separatorChar, '/'); String childPathStr = child.absPath.getAbsolutePath().replace(File.separatorChar, '/'); if (child != null && (child.absent || child.scheduledForDeletion) && SVNPathUtil.isAncestor(topDir, childPathStr)) { children.remove(); } } }
protected static int findNearestAncestor(Object[] childrenWithMergeInfoArray, boolean pathIsOwnAncestor, File path) { if (childrenWithMergeInfoArray == null) { return 0; } int ancestorIndex = 0; for (int i = 0; i < childrenWithMergeInfoArray.length; i++) { MergePath child = (MergePath) childrenWithMergeInfoArray[i]; String childPath = child.absPath.getAbsolutePath().replace(File.separatorChar, '/'); String pathStr = path.getAbsolutePath().replace(File.separatorChar, '/'); if (SVNPathUtil.isAncestor(childPath, pathStr) && (!childPath.equals(pathStr) || pathIsOwnAncestor)) { ancestorIndex = i; } } return ancestorIndex; }
private int findNearestAncestor(Object[] childrenWithMergeInfoArray, boolean pathIsOwnAncestor, File path) { if (childrenWithMergeInfoArray == null) { return 0; } int ancestorIndex = 0; for (int i = 0; i < childrenWithMergeInfoArray.length; i++) { MergePath child = (MergePath) childrenWithMergeInfoArray[i]; String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); String pathStr = path.getAbsolutePath().replace(File.separatorChar, '/'); if (SVNPathUtil.isAncestor(childPath, pathStr) && (!childPath.equals(pathStr) || pathIsOwnAncestor)) { ancestorIndex = i; } } return ancestorIndex; }
private int findNearestAncestor(Object[] childrenWithMergeInfoArray, boolean pathIsOwnAncestor, File path) { if (childrenWithMergeInfoArray == null) { return 0; } int ancestorIndex = 0; for (int i = 0; i < childrenWithMergeInfoArray.length; i++) { MergePath child = (MergePath) childrenWithMergeInfoArray[i]; String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); String pathStr = path.getAbsolutePath().replace(File.separatorChar, '/'); if (SVNPathUtil.isAncestor(childPath, pathStr) && (!childPath.equals(pathStr) || pathIsOwnAncestor)) { ancestorIndex = i; } } return ancestorIndex; }
private int findNearestAncestor(Object[] childrenWithMergeInfoArray, boolean pathIsOwnAncestor, File path) { if (childrenWithMergeInfoArray == null) { return 0; } int ancestorIndex = 0; for (int i = 0; i < childrenWithMergeInfoArray.length; i++) { MergePath child = (MergePath) childrenWithMergeInfoArray[i]; String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); String pathStr = path.getAbsolutePath().replace(File.separatorChar, '/'); if (SVNPathUtil.isAncestor(childPath, pathStr) && (!childPath.equals(pathStr) || pathIsOwnAncestor)) { ancestorIndex = i; } } return ancestorIndex; }
private void removeAbsentChildren(File targetWCPath, List childrenWithMergeInfo) { for (Iterator children = childrenWithMergeInfo.iterator(); children.hasNext();) { MergePath child = (MergePath) children.next(); String topDir = targetWCPath.getAbsolutePath().replace(File.separatorChar, '/'); String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); if (child != null && (child.myIsAbsent || child.myIsScheduledForDeletion) && SVNPathUtil.isAncestor(topDir, childPath)) { if (mySkippedPaths != null) { mySkippedPaths.remove(child.myPath); } children.remove(); } } }
private void removeAbsentChildren(File targetWCPath, List childrenWithMergeInfo) { for (Iterator children = childrenWithMergeInfo.iterator(); children.hasNext();) { MergePath child = (MergePath) children.next(); String topDir = targetWCPath.getAbsolutePath().replace(File.separatorChar, '/'); String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); if (child != null && (child.myIsAbsent || child.myIsScheduledForDeletion) && SVNPathUtil.isAncestor(topDir, childPath)) { if (mySkippedPaths != null) { mySkippedPaths.remove(child.myPath); } children.remove(); } } }
private void removeAbsentChildren(File targetWCPath, List childrenWithMergeInfo) { for (Iterator children = childrenWithMergeInfo.iterator(); children.hasNext();) { MergePath child = (MergePath) children.next(); String topDir = targetWCPath.getAbsolutePath().replace(File.separatorChar, '/'); String childPath = child.myPath.getAbsolutePath().replace(File.separatorChar, '/'); if (child != null && (child.myIsAbsent || child.myIsScheduledForDeletion) && SVNPathUtil.isAncestor(topDir, childPath)) { if (mySkippedPaths != null) { mySkippedPaths.remove(child.myPath); } children.remove(); } } }
protected static MergePath findNearestAncestor(Map<File, MergePath> childrenWithMergeInfo, boolean pathIsAncestor, File localAbsPath) { assert childrenWithMergeInfo != null; for (Map.Entry<File, MergePath> entry : childrenWithMergeInfo.entrySet()) { MergePath child = entry.getValue(); if (SVNPathUtil.isAncestor(SVNFileUtil.getFilePath(child.absPath), SVNFileUtil.getFilePath(localAbsPath)) && (pathIsAncestor || !child.absPath.equals(localAbsPath))) { return child; } } return null; }
private boolean isPathSubtree(File localAbsPath, Collection<File> subtrees) { if (subtrees != null) { for (File pathTouchedByMerge : subtrees) { if (SVNPathUtil.isAncestor(SVNFileUtil.getFilePath(localAbsPath), SVNFileUtil.getFilePath(pathTouchedByMerge))) { return true; } } } return false; }
@Override protected boolean isFilterPassed() throws SVNException { String localRelPath = getColumnString(SVNWCDbSchema.NODES__Fields.local_relpath); if (localRelPath == null) { localRelPath = ""; } String deletedRelPath = (String) getBind(2); if (deletedRelPath == null) { deletedRelPath = ""; } return (SVNPathUtil.isAncestor(deletedRelPath, localRelPath) || localRelPath.equals(deletedRelPath)) && getColumnLong(SVNWCDbSchema.NODES__Fields.op_depth) > 0; }
private static boolean isUnderRoot(File workingCopyDirectory, File relPath) throws SVNException { File fullPath = SVNFileUtil.createFilePath(workingCopyDirectory, relPath); try { String workingCopyDirectoryPath = SVNFileUtil.getFilePath(workingCopyDirectory.getCanonicalFile()); String canonicalFullPath = SVNFileUtil.getFilePath(fullPath.getCanonicalFile()); return canonicalFullPath.equals(workingCopyDirectoryPath) || SVNPathUtil.isAncestor(workingCopyDirectoryPath, canonicalFullPath); } catch (IOException e) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, e); SVNErrorManager.error(errorMessage, SVNLogType.WC); } return false; }
public File toRelPath(File wriAbsPath, File localAbsPath) throws SVNException { assert isAbsolute(localAbsPath); DirParsedInfo parsed = parseDir(wriAbsPath, Mode.ReadOnly); File rootAbsPath = parsed.wcDbDir.getWCRoot().getAbsPath(); return SVNPathUtil.isAncestor(rootAbsPath.getPath(), localAbsPath.getPath()) ? SVNFileUtil.createFilePath(SVNPathUtil.getRelativePath(rootAbsPath.getPath(), localAbsPath.getPath())) : localAbsPath; }
public static File skipAncestor(File parent, File child) { String parentPath = SVNFileUtil.getFilePath(parent); String childPath = SVNFileUtil.getFilePath(child); if (SVNPathUtil.isAncestor(parentPath, childPath)) { return SVNFileUtil.createFilePath(SVNPathUtil.getRelativePath(parentPath, childPath)); } return null; }
private void checkReposMatch(SVNURL reposRootUrl, File localAbsPath, SVNURL url) throws SVNException { if (!SVNPathUtil.isAncestor(reposRootUrl.toString(), url.toString())) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE, "URL ''{0}'' of ''{1}'' is not in repository ''{2}''", url, localAbsPath, reposRootUrl); SVNErrorManager.error(errorMessage, SVNLogType.WC); } }
public void addFile(String path, String copyFromPath, long copyFromRevision) throws SVNException { currentFile = new FileBaton(currentDirectory); currentFile.localAbsPath = SVNFileUtil.createFilePath(anchorAbsPath, path); if (!SVNPathUtil.isAncestor(SVNFileUtil.getFilePath(anchorAbsPath), SVNFileUtil.getFilePath(currentFile.localAbsPath))) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, "Path ''{0}'' is not in the working copy", path); SVNErrorManager.error(errorMessage, SVNLogType.WC); } }
public void addDir(String path, String copyFromPath, long copyFromRevision) throws SVNException { currentDirectory = new DirectoryBaton(currentDirectory); currentDirectory.localAbsPath = SVNFileUtil.createFilePath(anchorAbsPath, path); if (!SVNPathUtil.isAncestor(SVNFileUtil.getFilePath(anchorAbsPath), SVNFileUtil.getFilePath(currentDirectory.localAbsPath))) { SVNErrorMessage errorMessage = SVNErrorMessage.create(SVNErrorCode.WC_OBSTRUCTED_UPDATE, "Path ''{0}'' is not in the working copy", path); SVNErrorManager.error(errorMessage, SVNLogType.WC); } SVNFileUtil.ensureDirectoryExists(currentDirectory.localAbsPath); }
public SVNWCDb.ReposInfo fetchReposInfo(SVNURL url, SVNURL lastRepos, String lastUuid) throws SVNException { if (lastRepos != null && SVNPathUtil.isAncestor(lastRepos.toString(), url.toString())) { SVNWCDb.ReposInfo reposInfo = new SVNWCDb.ReposInfo(); reposInfo.reposRootUrl = lastRepos.toString(); reposInfo.reposUuid = lastUuid; return reposInfo; } SVNRepository repository = getRepositoryAccess().createRepository(url, null, true); SVNWCDb.ReposInfo reposInfo = new SVNWCDb.ReposInfo(); reposInfo.reposRootUrl = repository.getRepositoryRoot(true).toString(); reposInfo.reposUuid = repository.getRepositoryUUID(true); return reposInfo; }
public void openDir(String path, long revision) throws SVNException { myCurrentDirectory = createDirectoryInfo(myCurrentDirectory, path, false); SVNAdminArea adminArea = myCurrentDirectory.getAdminArea(); SVNEntry entry = adminArea.getEntry(adminArea.getThisDirName(), true); entry.setRevision(myTargetRevision); entry.setURL(myCurrentDirectory.URL); entry.setIncomplete(true); if (myRootURL != null && SVNPathUtil.isAncestor(myRootURL, myCurrentDirectory.URL)) { entry.setRepositoryRoot(myRootURL); } if (mySwitchURL != null) { clearWCProperty(myCurrentDirectory.getAdminArea()); } adminArea.saveEntries(false); }