Package org.tmatesoft.svn.core.internal.delta

Examples of org.tmatesoft.svn.core.internal.delta.SVNDeltaReader


            myDeltaOutputStream.delete(0, myDeltaOutputStream.length());
        }
    }

    protected void init() {
        myDeltaReader = new SVNDeltaReader();
        myDeltaOutputStream = new StringBuffer();
        super.init();
    }
View Full Code Here


    protected int getFileRevisionsImpl(String path, long startRevision, long endRevision, boolean includeMergedRevisions,
                                ISVNFileRevisionHandler handler) throws SVNException {
        Long srev = getRevisionObject(startRevision);
        Long erev = getRevisionObject(endRevision);
        SVNDeltaReader deltaReader = new SVNDeltaReader();
        try {
            openConnection();
            Object[] buffer = new Object[]{"get-file-revs",
                    getRepositoryPath(path),
                    srev, erev, Boolean.toString(includeMergedRevisions)};
            write("(w(s(n)(n)w))", buffer);
            authenticate();
            boolean hasRevision = false;
            int count = 0;
            while (true) {
                SVNItem item = readItem(false);
                if (item.getKind() == SVNItem.WORD && "done".equals(item.getWord())) {
                    break;
                }
                hasRevision = true;
                if (item.getKind() != SVNItem.LIST) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Revision entry not a list");
                    SVNErrorManager.error(err, SVNLogType.NETWORK);
                }
                List items = SVNReader.parseTuple("srll?s", item.getItems(), null);
                String name = null;
                SVNFileRevision fileRevision = null;
                if (handler != null) {
                    name = SVNReader.getString(items, 0);
                    long revision = SVNReader.getLong(items, 1);
                    SVNProperties properties = SVNReader.getProperties(items, 2, null);
                    SVNProperties propertiesDelta = SVNReader.getPropertyDiffs(items, 3, null);
                    boolean isMergedRevision = SVNReader.getBoolean(items, 4);

                    if (name != null) {
                        fileRevision = new SVNFileRevision(name, revision,
                                properties, propertiesDelta,
                                isMergedRevision);
                    }
                }

                SVNItem chunkItem = readItem(false);
                if (chunkItem.getKind() != SVNItem.BYTES) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
                    SVNErrorManager.error(err, SVNLogType.NETWORK);
                }
                boolean hasDelta = chunkItem.getBytes().length > 0;

                if (handler != null && fileRevision != null) {
                    handler.openRevision(fileRevision);
                }

                if (hasDelta) {
                    if (handler != null) {
                        handler.applyTextDelta(name == null ? path : name, null);
                    }
                    while (true) {
                        byte[] line = chunkItem.getBytes();
                        if (line == null || line.length == 0) {
                            break;
                        }
                        deltaReader.nextWindow(line, 0, line.length, name == null ? path : name, handler);
                        chunkItem = readItem(false);
                        if (chunkItem.getKind() != SVNItem.BYTES) {
                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
                            SVNErrorManager.error(err, SVNLogType.NETWORK);
                        }
                    }
                    deltaReader.reset(name == null ? path : name, handler);
                    if (handler != null) {
                        handler.textDeltaEnd(name == null ? path : name);
                    }

                }
View Full Code Here

    private Map myTokens;

    public SVNEditModeReader(SVNConnection connection, ISVNEditor editor, boolean forReplay) {
        myConnection = connection;
        myEditor = editor;
        myDeltaReader = new SVNDeltaReader();
        myDone = false;
        myAborted = false;
        myForReplay = forReplay;
        myTokens = new SVNHashMap();
    }
View Full Code Here

                    //
                    InputStream tgt = new FixedSizeInputStream(dumpStream, contentLength);
                    getDeltaGenerator().sendDelta(myCurrentNodeBaton.myPath, tgt, fsConsumer, false);
                } else {
                    buffer = new byte[SVNFileUtil.STREAM_CHUNK_SIZE];
                    SVNDeltaReader deltaReader = null;
                    try {
                        while (contentLength > 0) {
                            int numToRead = contentLength > SVNFileUtil.STREAM_CHUNK_SIZE ? SVNFileUtil.STREAM_CHUNK_SIZE : (int) contentLength;
                            int read = 0;
                            while(numToRead > 0) {
                                int numRead = dumpStream.read(buffer, read, numToRead);
                                if (numRead < 0) {
                                    SVNAdminHelper.generateIncompleteDataError();
                                }
                                read += numRead;
                                numToRead -= numRead;
                            }
                            deltaReader = getDeltaReader();
                            deltaReader.nextWindow(buffer, 0, read, myCurrentNodeBaton.myPath, fsConsumer);
                            contentLength -= read;
                        }
                    } catch (IOException ioe) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getMessage());
                        SVNErrorManager.error(err, ioe, SVNLogType.FSFS);
                    }
                    if (deltaReader != null) {
                        deltaReader.reset(myCurrentNodeBaton.myPath, fsConsumer);
                    }
                    fsConsumer.textDeltaEnd(myCurrentNodeBaton.myPath);
                }
            }
        } catch (SVNException svne) {
View Full Code Here

                propertyValue);
    }

    private SVNDeltaReader getDeltaReader() {
        if (myDeltaReader == null) {
            myDeltaReader = new SVNDeltaReader();
        }
        return myDeltaReader;
    }
View Full Code Here

                    //
                    InputStream tgt = new FixedSizeInputStream(dumpStream, contentLength);
                    checksum = getDeltaGenerator().sendDelta(myCurrentNodeBaton.myPath, tgt, fsConsumer, true);
                } else {
                    buffer = new byte[SVNFileUtil.STREAM_CHUNK_SIZE];
                    SVNDeltaReader deltaReader = null;
                    try {
                        while (contentLength > 0) {
                            int numToRead = contentLength > SVNFileUtil.STREAM_CHUNK_SIZE ? SVNFileUtil.STREAM_CHUNK_SIZE : (int) contentLength;
                            int read = 0;
                            while(numToRead > 0) {
                                int numRead = dumpStream.read(buffer, read, numToRead);
                                if (numRead < 0) {
                                    SVNAdminHelper.generateIncompleteDataError();
                                }
                                read += numRead;
                                numToRead -= numRead;
                            }
                            deltaReader = getDeltaReader();
                            deltaReader.nextWindow(buffer, 0, read, myCurrentNodeBaton.myPath, fsConsumer);
                            contentLength -= read;
                        }
                    } catch (IOException ioe) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR, ioe.getMessage());
                        SVNErrorManager.error(err, ioe, SVNLogType.FSFS);
                    }
                    if (deltaReader != null) {
                        deltaReader.reset(myCurrentNodeBaton.myPath, fsConsumer);
                    }
                    fsConsumer.textDeltaEnd(myCurrentNodeBaton.myPath);
                    checksum = fsConsumer.getChecksum();
                }
            }
View Full Code Here

                propertyValue);
    }

    private SVNDeltaReader getDeltaReader() {
        if (myDeltaReader == null) {
            myDeltaReader = new SVNDeltaReader();
        }
        return myDeltaReader;
    }
View Full Code Here

    protected int getFileRevisionsImpl(String path, long startRevision, long endRevision, boolean includeMergedRevisions,
                                ISVNFileRevisionHandler handler) throws SVNException {
        Long srev = getRevisionObject(startRevision);
        Long erev = getRevisionObject(endRevision);
        SVNDeltaReader deltaReader = new SVNDeltaReader();
        try {
            openConnection();
            Object[] buffer = new Object[]{"get-file-revs",
                    getRepositoryPath(path),
                    srev, erev, Boolean.toString(includeMergedRevisions)};
            write("(w(s(n)(n)w))", buffer);
            authenticate();
            boolean hasRevision = false;
            int count = 0;
            while (true) {
                SVNItem item = readItem(false);
                if (item.getKind() == SVNItem.WORD && "done".equals(item.getWord())) {
                    break;
                }
                hasRevision = true;
                if (item.getKind() != SVNItem.LIST) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Revision entry not a list");
                    SVNErrorManager.error(err, SVNLogType.NETWORK);
                }
                List items = SVNReader.parseTuple("srll?s", item.getItems(), null);
                String name = null;
                SVNFileRevision fileRevision = null;
                if (handler != null) {
                    name = SVNReader.getString(items, 0);
                    long revision = SVNReader.getLong(items, 1);
                    SVNProperties properties = SVNReader.getProperties(items, 2, null);
                    SVNProperties propertiesDelta = SVNReader.getPropertyDiffs(items, 3, null);
                    boolean isMergedRevision = SVNReader.getBoolean(items, 4);

                    if (name != null) {
                        fileRevision = new SVNFileRevision(name, revision,
                                properties, propertiesDelta,
                                isMergedRevision);
                    }
                }

                SVNItem chunkItem = readItem(false);
                if (chunkItem.getKind() != SVNItem.BYTES) {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
                    SVNErrorManager.error(err, SVNLogType.NETWORK);
                }
                boolean hasDelta = chunkItem.getBytes().length > 0;

                if (handler != null && fileRevision != null) {
                    handler.openRevision(fileRevision);
                }

                if (hasDelta) {
                    if (handler != null) {
                        handler.applyTextDelta(name == null ? path : name, null);
                    }
                    while (true) {
                        byte[] line = chunkItem.getBytes();
                        if (line == null || line.length == 0) {
                            break;
                        }
                        deltaReader.nextWindow(line, 0, line.length, name == null ? path : name, handler);
                        chunkItem = readItem(false);
                        if (chunkItem.getKind() != SVNItem.BYTES) {
                            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.RA_SVN_MALFORMED_DATA, "Text delta chunk not a string");
                            SVNErrorManager.error(err, SVNLogType.NETWORK);
                        }
                    }
                    deltaReader.reset(name == null ? path : name, handler);
                    if (handler != null) {
                        handler.textDeltaEnd(name == null ? path : name);
                    }

                }
View Full Code Here

                        if (numRead != numToRead) {
                            SVNAdminHelper.generateIncompleteDataError();
                        }
                       
                        if (isDelta) {
                            SVNDeltaReader deltaReader = getDeltaReader();
                            deltaReader.nextWindow(buffer, 0, numRead, myCurrentNodeBaton.myPath, fsConsumer);
                        } else {
                            getDeltaGenerator().sendDelta(myCurrentNodeBaton.myPath, buffer, numRead, fsConsumer);
                        }
                        contentLength -= numRead;
                    }
View Full Code Here

        myUUIDAction = action;
    }
   
    private SVNDeltaReader getDeltaReader() {
        if (myDeltaReader == null) {
            myDeltaReader = new SVNDeltaReader();
        }
        return myDeltaReader;
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.delta.SVNDeltaReader

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.