All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.tmatesoft.svn.util.SVNTest Maven / Gradle / Ivy

There is a newer version: 1.1.0.beta
Show newest version
/*
 * ====================================================================
 * Copyright (c) 2004-2006 TMate Software Ltd.  All rights reserved.
 *
 * This software is licensed as described in the file COPYING, which
 * you should have received as part of this distribution.  The terms
 * are also available at http://tmate.org/svn/license.html.
 * If newer versions of this license are posted there, you may use a
 * newer version instead, at your option.
 * ====================================================================
 */
package org.tmatesoft.svn.util;

import java.io.File;
import java.io.IOException;

import org.tmatesoft.svn.core.SVNException;
import org.tmatesoft.svn.core.SVNURL;
import org.tmatesoft.svn.core.internal.io.dav.DAVRepositoryFactory;
import org.tmatesoft.svn.core.internal.io.svn.SVNRepositoryFactoryImpl;
import org.tmatesoft.svn.core.internal.wc.SVNFileUtil;
import org.tmatesoft.svn.core.wc.ISVNStatusHandler;
import org.tmatesoft.svn.core.wc.SVNClientManager;
import org.tmatesoft.svn.core.wc.SVNRevision;
import org.tmatesoft.svn.core.wc.SVNStatus;
import org.tmatesoft.svn.core.wc.xml.SVNXMLDirEntryHandler;
import org.tmatesoft.svn.core.wc.xml.SVNXMLSerializer;


/**
 * @version 1.0
 * @author  TMate Software Ltd.
 */
public class SVNTest {

    public static void main(String[] args) throws SVNException {
        DAVRepositoryFactory.setup();
        SVNRepositoryFactoryImpl.setup();
        
        SVNClientManager clientManager = SVNClientManager.newInstance();
        clientManager.getStatusClient().doStatus(new File("c:/test/svn/wc/ignore"), true, true, true, false, new ISVNStatusHandler() {
            public void handleStatus(SVNStatus status) throws SVNException {
                new Exception().printStackTrace(System.out);
                System.out.println(status.getRemoteContentsStatus());
            }
        });
        System.exit(0);
        SVNXMLSerializer serializer = new SVNXMLSerializer(System.out);
        SVNXMLDirEntryHandler handler = new SVNXMLDirEntryHandler(serializer);
        
        SVNURL url = SVNURL.parseURIEncoded("http://svn.tmate.org/repos/jsvn/trunk/www");
        
        handler.startDocument();
        handler.startTarget(url.toString());
        clientManager.getLogClient().doList(url, SVNRevision.UNDEFINED, SVNRevision.HEAD, false, handler);
        handler.endTarget();
        handler.endDocument();
        try {
            serializer.flush();
        } catch (IOException e) {
            e.printStackTrace();
        }
        System.exit(0);

        File path = new File("c:/test/svn/wc/checkout/1.0.3/svn");
//        SVNURL url = SVNURL.parseURIEncoded("svn://localhost/svn/trunk");
        SVNFileUtil.deleteAll(path, true);
        long time = System.currentTimeMillis();
        checkout(clientManager, path, url);
        System.out.println("checkout [svn, 1.0.3]: " + (System.currentTimeMillis() - time) + " ms.");
        /*

        path = new File("c:/test/svn/wc/checkout/1.0.3/http");
        url = SVNURL.parseURIEncoded("http://localhost:8080/repos/svn/trunk");

        time = System.currentTimeMillis();
        checkout(clientManager, path, url);
        System.out.println("checkout [http, 1.0.3]: " + (System.currentTimeMillis() - time) + " ms.");
        */
    }

    private static void checkout(SVNClientManager clientManager, File path, SVNURL url) throws SVNException {
        clientManager.getUpdateClient().doCheckout(url, path, SVNRevision.UNDEFINED, SVNRevision.HEAD, true);
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy