org.tmatesoft.svn.core.wc.SVNUpdateClient Java Examples

The following examples show how to use org.tmatesoft.svn.core.wc.SVNUpdateClient. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TestCheckOut.java    From klask-io with GNU General Public License v3.0 6 votes vote down vote up
private static void checkout(final SVNUpdateClient updateClient, final String checkoutRootPath, final String destRootPath, final String repoPath, final SVNDepth depth) {
    //    updateClient.doExport(
    //        SVNURL.parseURIDecoded(checkoutRootPath + "/" + repoPath),
    //        new File(destRootPath + (!repoPath.isEmpty() ? "/" : "") + repoPath),
    //        SVNRevision.UNDEFINED,
    //        SVNRevision.HEAD,
    //        null,
    //        true,
    //        depth);

    try {
        updateClient.doCheckout(
            SVNURL.parseURIDecoded(checkoutRootPath + "/" + repoPath),
            new File(destRootPath + (!repoPath.isEmpty() ? "/" : "") + repoPath),
            SVNRevision.UNDEFINED,
            SVNRevision.HEAD,
            depth,
            true);
    } catch (final SVNException e) {
        System.err.println("Exception sur le fichier " + checkoutRootPath + "/" + repoPath);
        System.err.println(e.getMessage());
    }
}
 
Example #2
Source File: SvnClient.java    From steady with Apache License 2.0 5 votes vote down vote up
public File checkoutFile(String _rev, String _rel_path) {
	final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
	File f = null;
	SVNURL url = null;
	try {
		// Create subdir for given rev
		final String rel_dir = _rel_path.substring(0, _rel_path.lastIndexOf('/'));
		final Path rev_dir = Paths.get(this.workDir.toString(), _rev, rel_dir);
		Path p = Files.createDirectories(rev_dir);

		// Create SVNURL for specific file
		url = SVNURL.parseURIEncoded(this.rootRepo.getRepositoryRoot(false) + "/" + rel_dir);

		// Perform checkout
		SVNRevision revision = SVNRevision.create(Long.valueOf(_rev));

		SVNUpdateClient clnt = new SVNUpdateClient((ISVNAuthenticationManager)this.authManager, null);
		clnt.doCheckout(url, p.toFile(), revision, revision, SVNDepth.FILES, false); //IMMEDIATES, FILES, INFINITY

		//
		//			final SvnCheckout checkout = svnOperationFactory.createCheckout();
		//			checkout.setSingleTarget(SvnTarget.fromFile(p.toFile()));
		//			checkout.setSource(SvnTarget.fromURL(url));
		//			checkout.setDepth(SVNDepth.IMMEDIATES); //INFINITY
		//			checkout.setRevision(revision);
		//
		//			// Checkout and get file
		//			checkout.run();
		f = Paths.get(this.workDir.toString(), _rev, _rel_path).toFile();
	} catch (Exception e) {
		SvnClient.log.error("Error while checking out URL '" + url + "', revision "+ _rev + ": " + e.getMessage());
	} finally {
		svnOperationFactory.dispose();
	}
	return f;
}
 
Example #3
Source File: TestCheckOut.java    From klask-io with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Méthode traverse.<br>
 * Rôle :
 *
 * @param updateClient
 * @param repository
 * @param checkoutRootPath
 * @param destRootPath
 * @param repoPath
 * @param evictTags        : si on tombe une première fois sur trunk, branches ou tags, alors on n'élague plus les nouvelles occurrences rencontrées
 * @throws SVNException
 */
public static void traverse(final SVNUpdateClient updateClient, final SVNRepository repository, final String checkoutRootPath, final String destRootPath, final String repoPath,
                            final boolean evictTags) throws SVNException {

    System.out.println(repoPath);

    if (!evictTags) {
        checkout(updateClient, checkoutRootPath, destRootPath, repoPath, SVNDepth.INFINITY);
    } else {
        checkout(updateClient, checkoutRootPath, destRootPath, repoPath, SVNDepth.FILES);

        final Collection<SVNDirEntry> entries = repository.getDir(repoPath, -1, null, (Collection) null);
        for (final SVNDirEntry entry : entries) {
            if (entry.getKind() != SVNNodeKind.DIR) {
                continue;
            }
            boolean copieEvict = evictTags;

            if (motsClefsSVN.contains(entry.getName())) {
                copieEvict = false;
            }
            //si on doit encore passer le niveau tags/branches/trunk et que le rép courant n'est pas tags, alors on poursuit
            if (!entry.getName().equalsIgnoreCase(TAGS)) {
                traverse(
                    updateClient,
                    repository,
                    checkoutRootPath,
                    destRootPath,
                    repoPath.equals("") ? entry.getName() : repoPath + "/" + entry.getName(),
                    copieEvict);
            }
        }
    }
}
 
Example #4
Source File: TestCheckOut.java    From klask-io with GNU General Public License v3.0 5 votes vote down vote up
public void checkoutTest() throws SVNException {
    String checkoutPath = "svn://localhost";
    String username = "integration";
    String password = "integration";
    String checkoutRootPath = new File("/home/jeremie/Developpement/checkoutsvn").getAbsolutePath();

    DAVRepositoryFactory.setup();

    final SVNRepository repository = SVNRepositoryFactory.create(SVNURL.parseURIDecoded(checkoutPath));
    repository.setAuthenticationManager(SVNWCUtil.createDefaultAuthenticationManager(username, password));

    final SVNClientManager clientManager = SVNClientManager.newInstance(null, repository.getAuthenticationManager());
    final SVNUpdateClient updateClient = clientManager.getUpdateClient();

    updateClient.setIgnoreExternals(false);

    final SVNNodeKind nodeKind = repository.checkPath("", -1);

    if (nodeKind == SVNNodeKind.NONE) {
        System.err.println("There is no entry at '" + checkoutPath + "'.");
        System.exit(1);
    } else if (nodeKind == SVNNodeKind.FILE) {
        System.err.println("The entry at '" + checkoutPath + "' is a file while a directory was expected.");
        System.exit(1);
    }
    System.out.println("*** CHECKOUT SVN Trunk/Branches ***");
    System.out.println("Checkout source: " + checkoutPath);
    System.out.println("Checkout destination: " + checkoutRootPath);
    System.out.println("...");
    try {
        traverse(updateClient, repository, checkoutPath, checkoutRootPath, "", true);
    } catch (final Exception e) {
        System.err.println("ERROR : " + e.getMessage());
        e.printStackTrace(System.err);
        System.exit(-1);
    }
    System.out.println("");
    System.out.println("Repository latest revision: " + repository.getLatestRevision());
}