Package org.tmatesoft.svn.core.internal.io.fs

Examples of org.tmatesoft.svn.core.internal.io.fs.FSRevisionNode


    }

    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);
            }
        }
View Full Code Here


                        mustDumpProps = FSRepositoryUtil.arePropertiesChanged(compareRoot, comparePath, myRoot,
                                canonicalPath);
                        if (kind == SVNNodeKind.FILE) {
                            mustDumpText = FSRepositoryUtil.areFileContentsChanged(compareRoot, comparePath,
                                    myRoot, canonicalPath);
                            FSRevisionNode revNode = compareRoot.getRevisionNode(comparePath);
                            String checkSum = revNode.getFileChecksum();
                            if (checkSum != null && checkSum.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_COPY_SOURCE_CHECKSUM + ": " + checkSum + "\n");
                            }
                        }
                    }
                    break;
            }
           
            if (!mustDumpProps && !mustDumpText) {
                writeDumpData("\n\n");
                return;
            }
           
            long contentLength = 0;
            String propContents = null;
            if (mustDumpProps) {
                FSRevisionNode node = myRoot.getRevisionNode(canonicalPath);
                SVNProperties props = node.getProperties(myFSFS);
                SVNProperties oldProps = null;
                if (myUseDeltas && compareRoot != null) {
                    FSRevisionNode cmpNode = myRoot.getRevisionNode(comparePath);
                    oldProps = cmpNode.getProperties(myFSFS);
                    writeDumpData(SVNAdminHelper.DUMPFILE_PROP_DELTA + ": true\n");
                }

                ByteArrayOutputStream encodedProps = new ByteArrayOutputStream();
                SVNAdminHelper.writeProperties(props, oldProps, encodedProps);
                propContents = new String(encodedProps.toByteArray(), "UTF-8");
                contentLength += propContents.length();
                writeDumpData(SVNAdminHelper.DUMPFILE_PROP_CONTENT_LENGTH + ": " + propContents.length() + "\n");
            }
           
            File tmpFile = null;
            if (mustDumpText && kind == SVNNodeKind.FILE) {
                long txtLength = 0;
                FSRevisionNode node = myRoot.getRevisionNode(canonicalPath);

                if (myUseDeltas) {
                    tmpFile = SVNFileUtil.createTempFile("dump", ".tmp");
                    tmpFile.deleteOnExit();
                   
                    InputStream sourceStream = null;
                    InputStream targetStream = null;
                    OutputStream tmpStream = null;
                   
                    SVNDeltaCombiner deltaCombiner = getDeltaCombiner();
                    SVNDeltaGenerator deltaGenerator = getDeltaGenerator();
                    try {
                        if (compareRoot != null && comparePath != null) {
                            sourceStream = compareRoot.getFileStreamForPath(deltaCombiner, comparePath);
                        } else {
                            sourceStream = SVNFileUtil.DUMMY_IN;
                        }
                        targetStream = myRoot.getFileStreamForPath(deltaCombiner, canonicalPath);
                        tmpStream = SVNFileUtil.openFileForWriting(tmpFile);
                        final CountingStream countingStream = new CountingStream(tmpStream, 0)
                        ISVNDeltaConsumer consumer = new ISVNDeltaConsumer() {
                            private boolean isHeaderWritten = false;
                           
                            public OutputStream textDeltaChunk(String path, SVNDiffWindow diffWindow) throws SVNException {
                                try {
                                    if (diffWindow != null) {
                                        diffWindow.writeTo(countingStream, !isHeaderWritten, false);
                                    } else {
                                        SVNDiffWindow.EMPTY.writeTo(countingStream, !isHeaderWritten, false);
                                    }
                                } catch (IOException ioe) {
                                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getLocalizedMessage());
                                    SVNErrorManager.error(err, ioe, SVNLogType.FSFS);
                                }

                                isHeaderWritten = true;
                                return SVNFileUtil.DUMMY_OUT;
                            }

                            public void applyTextDelta(String path, String baseChecksum) throws SVNException {
                            }
                           
                            public void textDeltaEnd(String path) throws SVNException {
                            }
                        };
                       
                        deltaGenerator.sendDelta(null, sourceStream, 0, targetStream, consumer, false);
                        txtLength = countingStream.getPosition();
                       
                        if (compareRoot != null) {
                            FSRevisionNode revNode = compareRoot.getRevisionNode(comparePath);
                            String hexDigest = revNode.getFileChecksum();
                            if (hexDigest != null && hexDigest.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_DELTA_BASE_CHECKSUM + ": " + hexDigest + "\n");
                            }
                        }
                    } finally {
View Full Code Here

                }
            } else {
                FSRoot root = myResource.getRoot();
                String path = myResource.getResourceURI().getPath();
                try {
                    FSRevisionNode node = root.getRevisionNode(path);
                    myProperties = node.getProperties(fsfs);
                } catch (SVNException svne) {
                    exc = svne;
                }

                if (exc == null) {
View Full Code Here

                        "Could not open the transaction tree.", null);
            }
           
            long txnCreatedRevision = -1;
            try {
                FSRevisionNode node = txnRoot.getRevisionNode(reposPath);
                txnCreatedRevision = node.getCreatedRevision();
            } catch (SVNException svne) {
                throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                        "Could not get created-rev of transaction node.", null);
            }
           
            if (SVNRevision.isValidRevisionNumber(txnCreatedRevision)) {
                SVNDebugLog.getDefaultLog().logFine(SVNLogType.DEFAULT, "resource.getRevision(): " + resource.getRevision() + ", txnCreatedRevision: " + txnCreatedRevision);
                SVNDebugLog.getDefaultLog().logFine(SVNLogType.DEFAULT, "resource type: " + resource.getType());
                if (resource.getRevision() < txnCreatedRevision) {
                    throw new DAVException("resource out of date; try updating", null, HttpServletResponse.SC_CONFLICT, null, SVNLogType.NETWORK,
                            Level.FINE, null, DAVXMLUtil.SVN_DAV_ERROR_TAG, DAVElement.SVN_DAV_ERROR_NAMESPACE,
                            SVNErrorCode.FS_CONFLICT.getCode(), null);
                } else if (resource.getRevision() > txnCreatedRevision) {
                    String txnNodeRevID = null;
                    try {
                        FSRevisionNode node = txnRoot.getRevisionNode(reposPath);
                        txnNodeRevID = node.getId().getNodeID();
                    } catch (SVNException svne) {
                        SVNErrorMessage err = svne.getErrorMessage();
                        throw new DAVException("Unable to fetch the node revision id of the version resource within the transaction.", null,
                                HttpServletResponse.SC_CONFLICT, err, SVNLogType.FSFS, Level.FINE, null,
                                DAVXMLUtil.SVN_DAV_ERROR_TAG, DAVElement.SVN_DAV_ERROR_NAMESPACE, err.getErrorCode().getCode(), null);
                    }
                   
                    String urlNodeRevID = null;
                    try {
                        FSRoot root = resource.getRoot();
                        FSRevisionNode node = root.getRevisionNode(reposPath);
                        urlNodeRevID = node.getId().getNodeID();
                    } catch (SVNException svne) {
                        SVNErrorMessage err = svne.getErrorMessage();
                        throw new DAVException("Unable to fetch the node revision id of the version resource within the revision.", null,
                                HttpServletResponse.SC_CONFLICT, err, SVNLogType.FSFS, Level.FINE, null,
                                DAVXMLUtil.SVN_DAV_ERROR_TAG, DAVElement.SVN_DAV_ERROR_NAMESPACE, err.getErrorCode().getCode(), null);
View Full Code Here

        //TODO: log here that we are listing a dir

        myResource.setExists(true);
        myResource.setCollection(false);
        FSRevisionNode node = null;
        Map children = null;
        try {
            node = myRoot.getRevisionNode(myResource.getResourceURI().getPath());
            children = node.getDirEntries(myRoot.getOwner());
        } catch (SVNException svne) {
            throw DAVException.convertError(svne.getErrorMessage(), HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
                    "could not fetch collection members", null);
        }
       
View Full Code Here

        }
    }

    public long getCreatedRevisionUsingFS(String path) throws SVNException {
        path = path == null ? getResourceURI().getPath() : path;
        FSRevisionNode node = myRoot.getRevisionNode(path);
        return node.getCreatedRevision();
    }
View Full Code Here

        return entry.getSize();
    }

    public long getContentLength(String path) throws SVNException {
        path = path == null ? getResourceURI().getPath() : path;
        FSRevisionNode node = myRoot.getRevisionNode(path);
        return node.getFileLength();
    }
View Full Code Here

        return getProperty(SVNProperty.CHECKSUM);
    }

    public String getMD5Checksum(String path) throws SVNException {
        path = path == null ? getResourceURI().getPath() : path;
        FSRevisionNode node = myRoot.getRevisionNode(path);
        return node.getFileMD5Checksum();
    }
View Full Code Here

    public static long getSafeCreatedRevision(FSRevisionRoot root, String path) {
        long revision = root.getRevision();
        FSFS fsfs = root.getOwner();
        FSID id = null;
        try {
            FSRevisionNode node = root.getRevisionNode(path);
            id = node.getId();
        } catch (SVNException svne) {
            return revision;
        }

        FSNodeHistory history = null;
        long historyRev = -1;
        try {
            history = root.getNodeHistory(path);
            history = history.getPreviousHistory(false);
            historyRev = history.getHistoryEntry().getRevision();
        } catch (SVNException svne) {
            return revision;
        }
       
        FSRevisionRoot otherRoot = null;
        try {
            otherRoot = fsfs.createRevisionRoot(historyRev);
        } catch (SVNException svne) {
            return revision;
        }
       
        FSID otherID = null;
        try {
            FSRevisionNode node = otherRoot.getRevisionNode(path);
            otherID = node.getId();
        } catch (SVNException svne) {
            return revision;
        }
       
        if (id.compareTo(otherID) == 0) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.io.fs.FSRevisionNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.