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

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


        long rev = 0;
        if (root != null) {
            FSFS fsfs = root.getOwner();
            SVNProperties props = null;
            if (root instanceof FSRevisionRoot) {
                FSRevisionRoot revisionRoot = (FSRevisionRoot) root;
                rev = revisionRoot.getRevision();
                props = fsfs.getRevisionProperties(rev);
            } else {
                FSTransactionRoot txnRoot = (FSTransactionRoot) root;
                txnName = txnRoot.getTxnID();
                props = fsfs.getTransactionProperties(txnName);
View Full Code Here


        if (!SVNRevision.isValidRevisionNumber(srcRevision)) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NO_SUCH_REVISION, "Relative source revision {0} is not available in current repository", new Long(srcRevision));
            SVNErrorManager.error(err, SVNLogType.FSFS);
        }
       
        FSRevisionRoot copyRoot = myFSFS.createRevisionRoot(srcRevision);
        if (nodeBaton.myCopySourceChecksum != null) {
            FSRevisionNode revNode = copyRoot.getRevisionNode(nodeBaton.myCopyFromPath);
            String hexDigest = revNode.getFileMD5Checksum();
            if (hexDigest != null && !hexDigest.equals(nodeBaton.myCopySourceChecksum)) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CHECKSUM_MISMATCH,
                        "Copy source checksum mismatch on copy from ''{0}''@{1}\n" +
                        " to ''{2}'' in rev based on r{3}:\n" +
View Full Code Here

                compareRevision = cmpRev;
            }
            comparePath = SVNPathUtil.canonicalizePath(comparePath);
            comparePath = SVNPathUtil.getAbsolutePath(comparePath);
           
            FSRevisionRoot compareRoot = null;
            boolean mustDumpProps = false;
            boolean mustDumpText = false;
            String canonicalPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.canonicalizePath(path));
            switch(nodeAction) {
                case SVNAdminHelper.NODE_ACTION_CHANGE:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": change\n");
                    compareRoot = myFSFS.createRevisionRoot(compareRevision);
                    mustDumpProps = FSRepositoryUtil.arePropertiesChanged(compareRoot, comparePath, myRoot, canonicalPath);
                    if (kind == SVNNodeKind.FILE) {
                        mustDumpText = FSRepositoryUtil.areFileContentsChanged(compareRoot, comparePath, myRoot, canonicalPath);
                    }
                    break;
                case SVNAdminHelper.NODE_ACTION_REPLACE:
                    if (!isCopy) {
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": replace\n");
                        if (kind == SVNNodeKind.FILE) {
                            mustDumpText = true;
                        }
                        mustDumpProps = true;
                    } else {
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": delete\n\n");
                        dumpNode(path, kind, SVNAdminHelper.NODE_ACTION_ADD, isCopy, comparePath, compareRevision);
                        mustDumpText = false;
                        mustDumpProps = false;
                    }
                    break;
                case SVNAdminHelper.NODE_ACTION_DELETE:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": delete\n");
                    mustDumpText = false;
                    mustDumpProps = false;
                    break;
                case SVNAdminHelper.NODE_ACTION_ADD:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": add\n");
                    if (!isCopy) {
                        if (kind == SVNNodeKind.FILE) {
                            mustDumpText = true;
                        }
                        mustDumpProps = true;
                    } else {
                        if (cmpRev < myOldestDumpedRevision) {
                            SVNDebugLog.getDefaultLog().logFine(SVNLogType.FSFS,
                                    "WARNING: Referencing data in revision " + cmpRev +
                                    ", which is older than the oldest\nWARNING: dumped revision (" +
                                    myOldestDumpedRevision +
                                    ").  Loading this dump into an empty repository\nWARNING: will fail.\n");
                        }
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_COPYFROM_REVISION + ": " + cmpRev + "\n");
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_COPYFROM_PATH + ": " + cmpPath + "\n");
                        compareRoot = myFSFS.createRevisionRoot(compareRevision);
                        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.getFileMD5Checksum();
                            if (checkSum != null && checkSum.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_COPY_SOURCE_MD5 + ": " + checkSum + "\n");
                            }
                           
                            checkSum = revNode.getFileSHA1Checksum();
                            if (checkSum != null && checkSum.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_COPY_SOURCE_SHA1 + ": " + 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 CountingOutputStream countingStream = new CountingOutputStream(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.getFileMD5Checksum();
                            if (hexDigest != null && hexDigest.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_DELTA_BASE_MD5 + ": " + hexDigest + "\n");
                            }
                           
View Full Code Here

    public void textDeltaEnd(String path) throws SVNException {
    }

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

                defaultGenerator.setNewFile(root, path);
            }
            String rev1 = isOriginalEmpty ? "(rev 0)" : "(rev " + baseRoot.getRevision() + ")";
            String rev2 = null;
            if (root instanceof FSRevisionRoot) {
                FSRevisionRoot revRoot = (FSRevisionRoot) root;
                rev2 = "(rev " + revRoot.getRevision() + ")";
            } else {
                FSTransactionRoot txnRoot = (FSTransactionRoot) root;
                rev2 = "(txn " + txnRoot.getTxnID() + ")";
            }
            generator.displayFileDiff(path, originalFile.myTmpFile, newFile.myTmpFile, rev1, rev2, originalFile.myMimeType, newFile.myMimeType, os);
View Full Code Here

        long rev = 0;
        if (root != null) {
            FSFS fsfs = root.getOwner();
            SVNProperties props = null;
            if (root instanceof FSRevisionRoot) {
                FSRevisionRoot revisionRoot = (FSRevisionRoot) root;
                rev = revisionRoot.getRevision();
                props = fsfs.getRevisionProperties(rev);
            } else {
                FSTransactionRoot txnRoot = (FSTransactionRoot) root;
                txnName = txnRoot.getTxnID();
                props = fsfs.getTransactionProperties(txnName);
View Full Code Here

                compareRevision = cmpRev;
            }
            comparePath = SVNPathUtil.canonicalizePath(comparePath);
            comparePath = SVNPathUtil.getAbsolutePath(comparePath);
           
            FSRevisionRoot compareRoot = null;
            boolean mustDumpProps = false;
            boolean mustDumpText = false;
            String canonicalPath = SVNPathUtil.getAbsolutePath(SVNPathUtil.canonicalizePath(path));
            switch(nodeAction) {
                case SVNAdminHelper.NODE_ACTION_CHANGE:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": change\n");
                    compareRoot = myFSFS.createRevisionRoot(compareRevision);
                    mustDumpProps = FSRepositoryUtil.arePropertiesChanged(compareRoot, comparePath, myRoot, canonicalPath);
                    if (kind == SVNNodeKind.FILE) {
                        mustDumpText = FSRepositoryUtil.areFileContentsChanged(compareRoot, comparePath, myRoot, canonicalPath);
                    }
                    break;
                case SVNAdminHelper.NODE_ACTION_REPLACE:
                    if (!isCopy) {
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": replace\n");
                        if (kind == SVNNodeKind.FILE) {
                            mustDumpText = true;
                        }
                        mustDumpProps = true;
                    } else {
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": delete\n\n");
                        dumpNode(path, kind, SVNAdminHelper.NODE_ACTION_ADD, isCopy, comparePath, compareRevision);
                        mustDumpText = false;
                        mustDumpProps = false;
                    }
                    break;
                case SVNAdminHelper.NODE_ACTION_DELETE:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": delete\n");
                    mustDumpText = false;
                    mustDumpProps = false;
                    break;
                case SVNAdminHelper.NODE_ACTION_ADD:
                    writeDumpData(SVNAdminHelper.DUMPFILE_NODE_ACTION + ": add\n");
                    if (!isCopy) {
                        if (kind == SVNNodeKind.FILE) {
                            mustDumpText = true;
                        }
                        mustDumpProps = true;
                    } else {
                        if (!myIsVerify && cmpRev < myOldestDumpedRevision) {
                            SVNDebugLog.getDefaultLog().logFine(SVNLogType.FSFS,
                                    "WARNING: Referencing data in revision " + cmpRev +
                                    ", which is older than the oldest\nWARNING: dumped revision (" +
                                    myOldestDumpedRevision +
                                    ").  Loading this dump into an empty repository\nWARNING: will fail.\n");
                        }
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_COPYFROM_REVISION + ": " + cmpRev + "\n");
                        writeDumpData(SVNAdminHelper.DUMPFILE_NODE_COPYFROM_PATH + ": " + cmpPath + "\n");
                        compareRoot = myFSFS.createRevisionRoot(compareRevision);
                        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.getFileMD5Checksum();
                            if (checkSum != null && checkSum.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_COPY_SOURCE_MD5 + ": " + checkSum + "\n");
                            }
                           
                            checkSum = revNode.getFileSHA1Checksum();
                            if (checkSum != null && checkSum.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_COPY_SOURCE_SHA1 + ": " + 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 = compareRoot.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");
            }
            if (mustDumpText && kind == SVNNodeKind.FILE) {
                long txtLength = 0;
                FSRevisionNode node = myRoot.getRevisionNode(canonicalPath);

                if (myUseDeltas) {
                    tmpFile = SVNFileUtil.createTempFile("dump", ".tmp");
                   
                    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 CountingOutputStream countingStream = new CountingOutputStream(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.getFileMD5Checksum();
                            if (hexDigest != null && hexDigest.length() > 0) {
                                writeDumpData(SVNAdminHelper.DUMPFILE_TEXT_DELTA_BASE_MD5 + ": " + hexDigest + "\n");
                            }
                           
View Full Code Here

    public void textDeltaEnd(String path) throws SVNException {
    }

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

                defaultGenerator.setNewFile(root, path);
            }
            String rev1 = isOriginalEmpty ? "(rev 0)" : "(rev " + baseRoot.getRevision() + ")";
            String rev2 = null;
            if (root instanceof FSRevisionRoot) {
                FSRevisionRoot revRoot = (FSRevisionRoot) root;
                rev2 = "(rev " + revRoot.getRevision() + ")";
            } else {
                FSTransactionRoot txnRoot = (FSTransactionRoot) root;
                rev2 = "(txn " + txnRoot.getTxnID() + ")";
            }
            generator.displayFileDiff(path, originalFile.myTmpFile, newFile.myTmpFile, rev1, rev2, originalFile.myMimeType, newFile.myMimeType, os);
View Full Code Here

        if (!SVNRevision.isValidRevisionNumber(srcRevision)) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NO_SUCH_REVISION, "Relative source revision {0} is not available in current repository", new Long(srcRevision));
            SVNErrorManager.error(err, SVNLogType.FSFS);
        }
       
        FSRevisionRoot copyRoot = myFSFS.createRevisionRoot(srcRevision);
        if (nodeBaton.myCopySourceChecksum != null) {
            FSRevisionNode revNode = copyRoot.getRevisionNode(nodeBaton.myCopyFromPath);
            String hexDigest = revNode.getFileMD5Checksum();
            if (hexDigest != null && !hexDigest.equals(nodeBaton.myCopySourceChecksum)) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CHECKSUM_MISMATCH,
                        "Copy source checksum mismatch on copy from ''{0}''@{1}\n" +
                        " to ''{2}'' in rev based on r{3}:\n" +
View Full Code Here

TOP

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

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.