svn编程

API文档:
http://svnkit.com/javadoc/org/tmatesoft/svn/core/package-summary.html

例子路径:
https://wiki.svnkit.com/Managing_A_Working_Copy

别人写的例子:
http://eatsalt.blog.163.com/blog/static/879402662009102402949523/

public class DefaultSVNResourceGenerator extends AbstractLogEnabled implements SVNResourceGenerator {
    private SVNClientManager svnClientManager;
   
    private SVNURL           repositoryURL;
   
    private void init(String svnUrl, String svnUser, String svnPassword) throws SVNException {
        DAVRepositoryFactory.setup();
        repositoryURL = SVNURL.parseURIEncoded(svnUrl);

        ISVNOptions options = SVNWCUtil.createDefaultOptions(true);

        ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(
            svnUser, svnPassword);

        svnClientManager = SVNClientManager.newInstance(options, authManager);

    }
    public boolean resourceCheckout(String svnUrl, String projectPath, String svnUser,
                                    String svnPassword) throws Exception {
        File projectDir = new File(projectPath);
        if (projectDir.exists())
            deleteDir(projectDir);
       
        if (!projectDir.exists())
            projectDir.mkdirs();
       
        init(svnUrl, svnUser, svnPassword);
       
        SVNUpdateClient updateClient = svnClientManager.getUpdateClient();
        updateClient.setIgnoreExternals(false);

        updateClient.doCheckout(repositoryURL, projectDir, SVNRevision.HEAD, SVNRevision.HEAD,
            SVNDepth.INFINITY, true);
        deleteSvnDir(projectDir);
        return true;
    }
   
    public void deleteSvnDir(File file) {
        if (file.isDirectory()) {
            File svnDir = new File(file, ".svn");
            if (svnDir.exists() && svnDir.isDirectory())
                deleteDir(svnDir);
            File[] fileArray = file.listFiles();
            for (File f : fileArray)
                deleteSvnDir(f);
        }
    }

    public void deleteDir(File file) {
        if (file.isDirectory()) {
            File[] files = file.listFiles();
            for (File f : files)
                deleteDir(f);
        }
        file.delete();
    }
}

你可能感兴趣的:(html,编程,SVN,F#,Blog)