Search in sources :

Example 1 with ISVNLogMessageCallback

use of org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback in project subclipse by subclipse.

the class Cache method refresh.

public void refresh(List refreshedNodes, ISVNInfo info, IProgressMonitor monitor, int unitWorked) {
    ISVNLogMessageCallback callback = new ISVNLogMessageCallback() {

        public void singleMessage(ISVNLogMessage message) {
            update(message, true);
        }
    };
    revisionsTempFile = new File(root, "revisionsTemp");
    logMessagesTempFile = new File(root, "logMessagesTemp");
    revisionsTempFile.delete();
    logMessagesTempFile.delete();
    try {
        revisionsTempFile.createNewFile();
        logMessagesTempFile.createNewFile();
    } catch (IOException e) {
        Activator.handleError(e);
    }
    List revisions = new ArrayList();
    Iterator iter = refreshedNodes.iterator();
    while (iter.hasNext()) {
        Node node = (Node) iter.next();
        revisions.add(Long.toString(node.getRevision()));
    }
    startTempUpdate();
    RandomAccessFile file = null;
    ISVNClientAdapter client = null;
    try {
        client = SVNProviderPlugin.getPlugin().getSVNClient();
        file = new RandomAccessFile(logMessagesFile, "r");
        int revInt = new Long(getLatestRevision()).intValue();
        while (file.getFilePointer() < file.length()) {
            ISVNLogMessage lm = readNext(file, true);
            level = 0;
            int index = revisions.indexOf(lm.getRevision().toString());
            if (index == -1) {
                update(lm, true);
                if (lm.hasChildren() && lm.getChildMessages() != null) {
                    updateChildren(lm, true);
                }
                monitor.worked(unitWorked / revInt);
            } else {
                Node updateNode = (Node) refreshedNodes.get(index);
                SVNRevision updateRevision = new SVNRevision.Number(updateNode.getRevision());
                client.getLogMessages(new SVNUrl(info.getRepository() + updateNode.getPath()), updateRevision, updateRevision, updateRevision, false, true, 0, true, ISVNClientAdapter.DEFAULT_LOG_PROPERTIES, callback);
                monitor.worked(unitWorked);
            // updateRevision = (ISVNLogMessage)refreshedMessages.get(index);
            // monitor.worked(unitWorked);
            }
            if (monitor.isCanceled()) {
                break;
            }
        }
    } catch (Exception e) {
    } finally {
        closeFile(file);
        SVNProviderPlugin.getPlugin().getSVNClientManager().returnSVNClient(client);
    }
    finishTempUpdate();
    if (monitor.isCanceled()) {
        revisionsTempFile.delete();
        logMessagesTempFile.delete();
        return;
    }
    revisionsFile.delete();
    logMessagesFile.delete();
    revisionsTempFile.renameTo(revisionsFile);
    logMessagesTempFile.renameTo(logMessagesFile);
}
Also used : SVNUrl(org.tigris.subversion.svnclientadapter.SVNUrl) ArrayList(java.util.ArrayList) IOException(java.io.IOException) ISVNLogMessage(org.tigris.subversion.svnclientadapter.ISVNLogMessage) IOException(java.io.IOException) ISVNLogMessageCallback(org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback) RandomAccessFile(java.io.RandomAccessFile) Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) SVNRevision(org.tigris.subversion.svnclientadapter.SVNRevision) RandomAccessFile(java.io.RandomAccessFile) File(java.io.File) ISVNClientAdapter(org.tigris.subversion.svnclientadapter.ISVNClientAdapter)

Aggregations

File (java.io.File)1 IOException (java.io.IOException)1 RandomAccessFile (java.io.RandomAccessFile)1 ArrayList (java.util.ArrayList)1 Iterator (java.util.Iterator)1 List (java.util.List)1 ISVNClientAdapter (org.tigris.subversion.svnclientadapter.ISVNClientAdapter)1 ISVNLogMessage (org.tigris.subversion.svnclientadapter.ISVNLogMessage)1 ISVNLogMessageCallback (org.tigris.subversion.svnclientadapter.ISVNLogMessageCallback)1 SVNRevision (org.tigris.subversion.svnclientadapter.SVNRevision)1 SVNUrl (org.tigris.subversion.svnclientadapter.SVNUrl)1