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


    public int getFileRevisions(String path, long sRevision, long eRevision, ISVNFileRevisionHandler handler) throws SVNException {
        Long srev = getRevisionObject(sRevision);
        Long erev = getRevisionObject(eRevision);
        int count = 0;
        SVNDeltaReader deltaReader = new SVNDeltaReader();
        try {
            openConnection();
            Object[] buffer = new Object[] { "get-file-revs",
                    getRepositoryPath(path), srev, erev };
            write("(w(s(n)(n)))", buffer);
            authenticate();
            buffer = new Object[5];
            while (true) {
                SVNFileRevision fileRevision = null;
                boolean skipDelta = false;
                try {
                    buffer = read("(SN(*P)(*Z)?S", buffer, false);
                    if (buffer[4] != null && ((String) buffer[4]).length() == 0) {
                        buffer[4] = null;
                        skipDelta = true;
                    } else {
                        read(")", null, false);
                    }
                    count++;
                } catch (SVNException e) {
                    read("x", buffer, true);
                    read("[()]", buffer, true);
                    return count;
                }
                String name = null;
                if (handler != null) {
                    name = (String) buffer[0];
                    long revision = SVNReader.getLong(buffer, 1);
                    Map properties = SVNReader.getMap(buffer, 2);
                    Map propertiesDelta = SVNReader.getMap(buffer, 3);
                    if (name != null) {
                        fileRevision = new SVNFileRevision(name, revision,
                                properties, propertiesDelta);
                    }
                    buffer[2] = null;
                    buffer[3] = null;
                }
                if (handler != null && fileRevision != null) {
                    handler.openRevision(fileRevision);
                }
                if (skipDelta) {
                    if (handler != null) {
                        handler.closeRevision(name == null ? path : name);
                    }
                    continue;
                }
                boolean windowRead = false;
                while (true) {
                    byte[] line = (byte[]) read("?W?B", buffer, true)[1];
                    if (line == null) {
                        // may be failure
                        read("[]", buffer, true);
                        break;
                    } else if (line.length == 0) {
                        // empty line, delta end.
                        break;
                    }
                    // apply delta here.
                    if (!windowRead) {
                        if (handler != null) {
                            handler.applyTextDelta(name == null ? path : name, null);
                            windowRead = true;
                        }
                    }
                    deltaReader.nextWindow(line, 0, line.length, name == null ? path : name, handler);
                }
                deltaReader.reset(name == null ? path : name, handler);
                if (windowRead) {
                    handler.textDeltaEnd(name == null ? path : name);
                }
                if (handler != null) {
                    handler.closeRevision(name == null ? path : name);
View Full Code Here

    private SVNDeltaReader myDeltaReader;
    private String myFilePath;

    public void setEditor(ISVNEditor editor) {
        myEditor = editor;
        myDeltaReader = new SVNDeltaReader();
    }
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

    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

    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

                    //
                    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

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

    protected void init() {
        myDeltaReader = new SVNDeltaReader();
        myDeltaOutputStream = new StringBuffer();
        super.init();
    }
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.