Java Code Examples for org.tmatesoft.svn.core.SVNURL#parseURIEncoded()

The following examples show how to use org.tmatesoft.svn.core.SVNURL#parseURIEncoded() . 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: SubversionCommit.java    From Getaviz with Apache License 2.0 6 votes vote down vote up
private String createDiffDescription(long revision, String cleanedFilePath) throws SVNException {
	String returnable = null;
	final SvnOperationFactory svnOperationFactory = new SvnOperationFactory();
	try {
		final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
		final SvnDiffGenerator diffGenerator = new SvnDiffGenerator();
		final SvnDiff diff = svnOperationFactory.createDiff();
		SVNURL currentRepoFilePath = SVNURL.parseURIEncoded(repo.getLocation().toString() + "/" + cleanedFilePath);
		List<SVNFileRevision> revisions = new ArrayList<SVNFileRevision>();
		repo.getFileRevisions(cleanedFilePath, revisions, 0, entry.getRevision());
		diff.setSources(SvnTarget.fromURL(currentRepoFilePath, SVNRevision.create(getLastCommitWhenChanged(revision, revisions))),
				SvnTarget.fromURL(currentRepoFilePath, SVNRevision.create(revision)));
		diff.setUseGitDiffFormat(true);
		diff.setDiffGenerator(diffGenerator);
		diff.setOutput(byteArrayOutputStream);
		diff.setDepth(SVNDepth.EMPTY);
		diff.run();
		returnable = new String(byteArrayOutputStream.toByteArray());
	} finally {
		svnOperationFactory.dispose();
	}
	return returnable;
}
 
Example 2
Source File: SubversionRepositoryInitializer.java    From Getaviz with Apache License 2.0 5 votes vote down vote up
public SVNRepository initRepository(boolean cached) throws SVNException, MalformedURLException {
	SVNRepository repo = null;
	SVNURL svnUrl = SVNURL.parseURIEncoded(url);
	if (url.startsWith(HTTP_SCHEME + SCHEME_SEPARATOR) || url.startsWith(HTTPS_SCHEME + SCHEME_SEPARATOR)) {
		DAVRepositoryFactory.setup();
		repo = DAVRepositoryFactory.create(svnUrl);
		repo.testConnection();
		if(cached) {
			TmpDirCreator tmpDirCreator = new TmpDirCreator(url);
			File tempDir = tmpDirCreator.getLocalTempDir();
			SVNURL cachedRepoPath = SVNURL.parseURIEncoded(FILE_SCHEME + SCHEME_SEPARATOR + tempDir);
			if(!tempDir.exists()){
				messageOutputStream.println("Caching subversion repository " + svnUrl + " This can take a while...");
				tempDir.mkdirs();
				cachedRepoPath = SVNRepositoryFactory.createLocalRepository(tempDir, true, true);
				tmpDirCreator.writeIdFileToTempDir();
				SVNRepository targetRepo = SVNRepositoryFactory.create(cachedRepoPath);
				SVNRepositoryReplicator replicator = SVNRepositoryReplicator.newInstance();
				replicator.setReplicationHandler(new ProgressBarReplicationHandler(repo.getLatestRevision()));
				replicator.replicateRepository(repo, targetRepo, -1, -1);
				messageOutputStream.println("\nCaching finished succesfully...");
			}
			svnUrl = cachedRepoPath;
			FSRepositoryFactory.setup();
			repo = FSRepositoryFactory.create(svnUrl);
		}
	} else if (url.startsWith(SVN_SCHEME + SCHEME_SEPARATOR)) {
		SVNRepositoryFactoryImpl.setup();
		repo = SVNRepositoryFactoryImpl.create(svnUrl);
	} else if (url.startsWith(FILE_SCHEME + SCHEME_SEPARATOR)) {
		FSRepositoryFactory.setup();
		repo = FSRepositoryFactory.create(svnUrl);
	} else
		throw new MalformedURLException(String.format("URL %s is not an supported SVN url!", url));
	repo.testConnection();
	return repo;
}
 
Example 3
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 4
Source File: DeltaParams.java    From git-as-svn with GNU General Public License v2.0 5 votes vote down vote up
DeltaParams(
    @NotNull int[] rev,
    @NotNull String path,
    @NotNull String targetPath,
    boolean textDeltas,
    @NotNull Depth depth,
    @NotNull SendCopyFrom sendCopyFrom,
    /*
     * Broken-minded SVN feature we're unlikely to support EVER.
     * <p>
     * If {@code ignoreAncestry} is {@code false} and file was deleted and created back between source and target revisions,
     * SVN server sends two deltas for this file - deletion and addition. The only effect that this behavior produces is
     * increased number of tree conflicts on client.
     * <p>
     * Worse, in SVN it is possible to delete file and create it back in the same commit, effectively breaking its history.
     */
    @SuppressWarnings("UnusedParameters") boolean ignoreAncestry,
    boolean includeInternalProps,
    int lowRevision
) throws SVNException {
  this.rev = rev;
  this.path = path;
  this.targetPath = targetPath.isEmpty() ? null : SVNURL.parseURIEncoded(targetPath);
  this.depth = depth;
  this.sendCopyFrom = sendCopyFrom;
  this.textDeltas = textDeltas;
  this.includeInternalProps = includeInternalProps;
  this.lowRevision = lowRevision;
}
 
Example 5
Source File: ClientInfo.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
public ClientInfo(int protocolVersion, @NotNull String[] capabilities, @NotNull String url, @NotNull String raClient) throws SVNException {
  this.protocolVersion = protocolVersion;
  this.capabilities = capabilities;
  this.url = SVNURL.parseURIEncoded(url);
  this.raClient = raClient;
}
 
Example 6
Source File: ReparentCmd.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
public Params(@NotNull String url) throws SVNException {
  this.url = SVNURL.parseURIEncoded(url);
}
 
Example 7
Source File: CommitCmd.java    From git-as-svn with GNU General Public License v2.0 4 votes vote down vote up
public CopyParams(@NotNull String copyFrom, int rev) throws SVNException {
  this.copyFrom = copyFrom.isEmpty() ? null : SVNURL.parseURIEncoded(copyFrom);
  this.rev = rev;
}