public InputStream getFileStreamForPath(SVNDeltaCombiner combiner, String path) throws SVNException { FSRevisionNode fileNode = getRevisionNode(path); return FSInputStream.createDeltaStream(combiner, fileNode, getOwner()); }
public static boolean areFileContentsChanged(FSRoot root1, String path1, FSRoot root2, String path2) throws SVNException { if (root1.checkNodeKind(path1) != SVNNodeKind.FILE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "''{0}'' is not a file", path1); SVNErrorManager.error(err, SVNLogType.FSFS); } if (root2.checkNodeKind(path2) != SVNNodeKind.FILE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_GENERAL, "''{0}'' is not a file", path2); SVNErrorManager.error(err, SVNLogType.FSFS); } FSRevisionNode revNode1 = root1.getRevisionNode(path1); FSRevisionNode revNode2 = root2.getRevisionNode(path2); return !areRepresentationsEqual(revNode1, revNode2, false); }
public FSRevisionNode getRevisionNode(String path) throws SVNException { String canonPath = path; FSRevisionNode node = fetchRevNodeFromCache(canonPath); if (node == null) { FSParentPath parentPath = openPath(path, true, false); node = parentPath.getRevNode(); } return node; }
public FSParentPath openPath(String path, boolean lastEntryMustExist, boolean storeParents) throws SVNException { String canonPath = path; FSRevisionNode here = getRootRevisionNode(); String pathSoFar = "/"; child = here; } else { FSRevisionNode cachedRevNode = fetchRevNodeFromCache(pathSoFar); if (cachedRevNode != null) { child = cachedRevNode; } else { try { child = here.getChildDirNode(entry, getOwner()); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_NOT_FOUND) { FSCopyInheritance copyInheritance = getCopyInheritance(parentPath); if (copyInheritance != null) { parentPath.setCopyStyle(copyInheritance.getStyle()); putRevNodeToCache(pathSoFar, child); SVNErrorMessage err = FSErrors.errorNotDirectory(pathSoFar, getOwner()); SVNErrorManager.error(err.wrap("Failure opening ''{0}''", path));
FSRevisionNode revNode1 = root1.getRevisionNode(path1); FSRevisionNode revNode2 = root2.getRevisionNode(path2); if (revNode1.getFileLength() != revNode2.getFileLength()) { return true; InputStream file2IS = null; try { file1IS = root1.getFileStreamForPath(myDeltaCombiner, path1); file2IS = root2.getFileStreamForPath(myDeltaCombiner, path2);
kind = myRoot.checkNodeKind(absPath); if (kind != SVNNodeKind.DIR && kind != SVNNodeKind.FILE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "Filesystem path ''{0}'' is neither a file nor a directory", path); if (isAdd) { FSRoot copyFromRoot = null; FSRevisionNode copyfromNode = myRoot.getRevisionNode(absPath); copyFromPath = copyfromNode.getCopyFromPath(); long copyFromRevision = copyfromNode.getCopyFromRevision(); Map oldProps = null; if (srcRoot != null) { FSRevisionNode srcNode = srcRoot.getRevisionNode(srcPath); oldProps = srcNode.getProperties(myOwner); FSRevisionNode node = myRoot.getRevisionNode(absPath); Map newProps = node.getProperties(myOwner); Map propDiff = FSRepository.getPropsDiffs(oldProps, newProps); try { if (srcRoot != null && srcPath != null) { sourceStream = srcRoot.getFileStreamForPath(myDeltaCombiner, srcPath); } else { sourceStream = SVNFileUtil.DUMMY_IN; targetStream = myRoot.getFileStreamForPath(myDeltaCombiner, absPath); myDeltaGenerator.sendDelta(path, sourceStream, 0, targetStream, editor, false); } finally {
private DiffItem prepareTmpFile(FSRoot root, String path, ISVNDiffGenerator generator) throws SVNException { String mimeType = null; if (root != null) { FSRevisionNode node = root.getRevisionNode(path); SVNProperties nodeProps = node.getProperties(root.getOwner()); mimeType = nodeProps.getStringValue(SVNProperty.MIME_TYPE); if (SVNProperty.isBinaryMimeType(mimeType) && !generator.isForcedBinaryDiff()) { return new DiffItem(mimeType, null); } } File tmpFile = createTempFile(generator); if (root != null) { InputStream contents = null; OutputStream tmpOS = null; try { contents = root.getFileStreamForPath(new SVNDeltaCombiner(), path); tmpOS = SVNFileUtil.openFileForWriting(tmpFile); FSRepositoryUtil.copy(contents, tmpOS, myCancelHandler); } finally { SVNFileUtil.closeFile(contents); SVNFileUtil.closeFile(tmpOS); } } return new DiffItem(mimeType, tmpFile); }
public static boolean arePropertiesChanged(FSRoot root1, String path1, FSRoot root2, String path2) throws SVNException { FSRevisionNode node1 = root1.getRevisionNode(path1); FSRevisionNode node2 = root2.getRevisionNode(path2); return !areRepresentationsEqual(node1, node2, true); }
public boolean isUseLogAddressing() { return getOwner().isUseLogAddressing(); }
protected Map fetchAllChanges(FSFile changesFile, boolean prefolded) throws SVNException { Map changedPaths = new HashMap(); FSPathChange change = readChange(changesFile); while (change != null) { foldChange(changedPaths, change); if ((FSPathChangeKind.FS_PATH_CHANGE_DELETE == change.getChangeKind() || FSPathChangeKind.FS_PATH_CHANGE_REPLACE == change.getChangeKind()) && !prefolded) { for (Iterator curIter = changedPaths.keySet().iterator(); curIter.hasNext();) { String hashKeyPath = (String) curIter.next(); if (change.getPath().equals(hashKeyPath)) { continue; } if (SVNPathUtil.pathIsChild(change.getPath(), hashKeyPath) != null) { curIter.remove(); } } } change = readChange(changesFile); } return changedPaths; }
public static SVNNodeKind checkPath(FSRoot root, String path) throws DAVException { try { return root.checkNodeKind(path); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_NOT_DIRECTORY) { return SVNNodeKind.NONE; } throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR, "Error checking kind of path ''{0}'' in repository", new Object[] { path }); } }
protected SVNProperties getProperties() throws SVNException { FSRoot root = getFSRoot(); if (root instanceof FSTransactionRoot) { return root.getOwner().getTransactionProperties(((FSTransactionRoot) root).getTxnID()); } return root.getOwner().getRevisionProperties(root.getRevision()); }
private String computeSHA1Checksum(FSRoot revision, String filePath) throws SVNException { InputStream is = revision.getFileStreamForPath(getDeltaCombiner(), filePath); SVNChecksumInputStream checksum = null; try { checksum = new SVNChecksumInputStream(is, "SHA1"); } finally { SVNFileUtil.closeFile(checksum); } return checksum != null ? checksum.getDigest() : null; }
public Map detectChanged() throws SVNException { Map changes = getChangedPaths(); if (changes.size() == 0) { return changes; } for (Iterator paths = changes.keySet().iterator(); paths.hasNext();) { String changedPath = (String) paths.next(); FSPathChange change = (FSPathChange) changes.get(changedPath); if (change.getChangeKind() == FSPathChangeKind.FS_PATH_CHANGE_RESET) { paths.remove(); } } return changes; }
FSRevisionNode here = getRootRevisionNode(); String pathSoFar = "/"; child = here; } else { FSRevisionNode cachedRevNode = fetchRevNodeFromCache(pathSoFar); if (cachedRevNode != null) { child = cachedRevNode; } else { try { child = here.getChildDirNode(entry, getOwner()); } catch (SVNException svne) { if (svne.getErrorMessage().getErrorCode() == SVNErrorCode.FS_NOT_FOUND) { FSCopyInheritance copyInheritance = getCopyInheritance(parentPath); if (copyInheritance != null) { parentPath.setCopyStyle(copyInheritance.getStyle()); putRevNodeToCache(pathSoFar, child); SVNErrorMessage err = FSErrors.errorNotDirectory(pathSoFar, getOwner()); SVNErrorManager.error(err.wrap("Failure opening ''{0}''", path), SVNLogType.FSFS);
FSRevisionNode revNode1 = root1.getRevisionNode(path1); FSRevisionNode revNode2 = root2.getRevisionNode(path2); if (revNode1.getFileLength() != revNode2.getFileLength()) { return true; InputStream file2IS = null; try { file1IS = root1.getFileStreamForPath(deltaCombiner, path1); file2IS = root2.getFileStreamForPath(deltaCombiner, path2);
kind = myRoot.checkNodeKind(absPath); if (kind != SVNNodeKind.DIR && kind != SVNNodeKind.FILE) { SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, if (isAdd) { FSRoot copyFromRoot = null; FSRevisionNode copyfromNode = myRoot.getRevisionNode(absPath); copyFromPath = copyfromNode.getCopyFromPath(); long copyFromRevision = copyfromNode.getCopyFromRevision(); SVNProperties oldProps = null; if (srcRoot != null) { FSRevisionNode srcNode = srcRoot.getRevisionNode(srcPath); oldProps = srcNode.getProperties(myOwner); FSRevisionNode node = myRoot.getRevisionNode(absPath); SVNProperties newProps = node.getProperties(myOwner); SVNProperties propDiff = FSRepositoryUtil.getPropsDiffs(oldProps, newProps); String checksum = null; if (myCompareRoot != null && srcRoot != null && srcPath != null) { FSRevisionNode node = srcRoot.getRevisionNode(srcPath); checksum = node.getFileMD5Checksum(); try { if (srcRoot != null && srcPath != null) { sourceStream = srcRoot.getFileStreamForPath(myDeltaCombiner, srcPath); } else { sourceStream = SVNFileUtil.DUMMY_IN;
private DiffItem prepareTmpFile(FSRoot root, String path, ISVNDiffGenerator generator) throws SVNException { String mimeType = null; if (root != null) { FSRevisionNode node = root.getRevisionNode(path); SVNProperties nodeProps = node.getProperties(root.getOwner()); mimeType = nodeProps.getStringValue(SVNProperty.MIME_TYPE); if (SVNProperty.isBinaryMimeType(mimeType) && !generator.isForcedBinaryDiff()) { return new DiffItem(mimeType, null); } } File tmpFile = createTempFile(generator); if (root != null) { InputStream contents = null; OutputStream tmpOS = null; try { contents = root.getFileStreamForPath(new SVNDeltaCombiner(), path); tmpOS = SVNFileUtil.openFileForWriting(tmpFile); FSRepositoryUtil.copy(contents, tmpOS, myCancelHandler); } finally { SVNFileUtil.closeFile(contents); SVNFileUtil.closeFile(tmpOS); } } return new DiffItem(mimeType, tmpFile); }
public static boolean arePropertiesChanged(FSRoot root1, String path1, FSRoot root2, String path2) throws SVNException { FSRevisionNode node1 = root1.getRevisionNode(path1); FSRevisionNode node2 = root2.getRevisionNode(path2); return !areRepresentationsEqual(node1, node2, true); }
public void diff(FSRoot root, long baseRevision, ISVNGNUDiffGenerator generator, OutputStream os) throws SVNException { if (myRootNode != null) { FSRevisionRoot baseRoot = root.getOwner().createRevisionRoot(baseRevision); try { diffImpl(root, baseRoot, "/", "/", myRootNode, generator, os); } finally { cleanup(); } } }