@Override public synchronized Locations getLocations(String application, String profile, String label) { if (label == null) { label = this.defaultLabel; } SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); if (hasText(getUsername())) { svnOperationFactory .setAuthenticationManager(new DefaultSVNAuthenticationManager(null, false, getUsername(), getPassword())); } try { String version; if (new File(getWorkingDirectory(), ".svn").exists()) { version = update(svnOperationFactory, label); } else { version = checkout(svnOperationFactory); } return new Locations(application, profile, label, version, getPaths(application, profile, label)); } catch (SVNException e) { throw new IllegalStateException("Cannot checkout repository", e); } finally { svnOperationFactory.dispose(); } }
private String checkout(SvnOperationFactory svnOperationFactory) throws SVNException { logger.debug("Checking out " + getUri() + " to: " + getWorkingDirectory().getAbsolutePath()); final SvnCheckout checkout = svnOperationFactory.createCheckout(); checkout.setSource(SvnTarget.fromURL(SVNURL.parseURIEncoded(getUri()))); checkout.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); Long id = checkout.run(); if (id == null) { return null; } return id.toString(); }
private String update(SvnOperationFactory svnOperationFactory, String label) throws SVNException { logger.debug("Repo already checked out - updating instead."); try { final SvnUpdate update = svnOperationFactory.createUpdate(); update.setSingleTarget(SvnTarget.fromFile(getWorkingDirectory())); long[] ids = update.run(); StringBuilder version = new StringBuilder(); for (long id : ids) { if (version.length() > 0) { version.append(","); } version.append(id); } return version.toString(); } catch (Exception e) { String message = "Could not update remote for " + label + " (current local=" + getWorkingDirectory().getPath() + "), remote: " + this.getUri() + ")"; if (logger.isDebugEnabled()) { logger.debug(message, e); } else if (logger.isWarnEnabled()) { logger.warn(message); } } final SVNStatus status = SVNClientManager.newInstance().getStatusClient() .doStatus(getWorkingDirectory(), false); return status != null ? status.getRevision().toString() : null; }
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { final SvnCheckout checkout = svnOperationFactory.createCheckout(); checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory)); checkout.setSource(SvnTarget.fromURL(url)); //... other options checkout.run(); }finally { svnOperationFactory.dispose(); }
final SvnOperationFactory operationFactory = new SvnOperationFactory(); try { operationFactory.setRepositoryPool(getRepositoryPool()); operationFactory.setOptions(getOptions()); operationFactory.setEventHandler(getEventDispatcher()); operationFactory.setAutoDisposeRepositoryPool(false); operationFactory.setCanceller(getEventDispatcher()); do { SvnGetProperties getProperties = operationFactory.createGetProperties(); getProperties.setSingleTarget(SvnTarget.fromURL(parentUrl, SVNRevision.HEAD)); getProperties.setRevision(SVNRevision.HEAD); operationFactory.dispose();
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(user, password); svnOperationFactory.setAuthenticationManager(authManager); try { final SvnCheckout checkout = svnOperationFactory.createCheckout(); checkout.setSingleTarget(SvnTarget.fromFile(workingCopyDirectory)); checkout.setSource(SvnTarget.fromURL(url)); //... other options checkout.run(); } finally { svnOperationFactory.dispose(); }
/** * Get version of "omegat/project_save.tmx" in SVN. */ private static String getSVNTmxVersion(File wc) throws Exception { final SvnOperationFactory of = new SvnOperationFactory(); final SvnGetInfo infoOp = of.createGetInfo(); infoOp.setSingleTarget(SvnTarget.fromFile(new File(wc, "omegat/project_save.tmx"))); infoOp.setDepth(SVNDepth.EMPTY); SvnInfo info = infoOp.run(); long r = info.getRevision(); return Long.toString(r); }
public void run() throws SVNException { List targets = getSVNEnvironment().combineTargets(getSVNEnvironment().getTargets(), true); if (targets.isEmpty()) { targets.add(""); } SvnOperationFactory factory = new SvnOperationFactory(); if (!getSVNEnvironment().isQuiet()) { factory.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment())); } SvnUpgrade upgrade = factory.createUpgrade(); for (Iterator ts = targets.iterator(); ts.hasNext();) { String targetName = (String) ts.next(); SVNPath target = new SVNPath(targetName); if (target.isFile()) { getSVNEnvironment().checkCancelled(); upgrade.setSingleTarget(SvnTarget.fromFile(target.getFile())); try { upgrade.run(); } catch (SVNException e) { getSVNEnvironment().handleWarning(e.getErrorMessage(), new SVNErrorCode[] {SVNErrorCode.WC_NOT_DIRECTORY}, getSVNEnvironment().isQuiet()); } } } }
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { final SVNURL url = ...; svnOperationFactory.setAuthenticationManager(new BasicAuthenticationManager("myusername", "mypassword")); final SvnLog log = svnOperationFactory.createLog(); log.addRange(SvnRevisionRange.create(SVNRevision.create(date1), SVNRevision.create(date2))); log.setDiscoverChangedPaths(true); log.setSingleTarget(SvnTarget.fromURL(url)); log.setReceiver(new ISvnObjectReceiver<SVNLogEntry>() { @Override public void receive(SvnTarget target, SVNLogEntry logEntry) throws SVNException { ... } }); log.run(); } finally { svnOperationFactory.dispose(); }
private void checkUpdate(@NotNull String basePath) throws Exception { try (SvnTestServer server = SvnTestServer.createMasterRepository()) { final SvnOperationFactory factory = server.createOperationFactory(); factory.setAutoCloseContext(false); factory.setAutoDisposeRepositoryPool(false); Assert.assertTrue(revisions.size() > 2); final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl().appendPath(basePath, false))); checkout.setSingleTarget(SvnTarget.fromFile(server.getTempDirectory())); checkout.run(); factory.setEventHandler(new ISVNEventHandler() { @Override public void handleEvent(SVNEvent event, double progress) throws SVNException { final Random rand = new Random(0); for (long revision : revisions.subList(1, revisions.size())) { final SvnLog svnLog = factory.createLog(); svnLog.setSingleTarget(SvnTarget.fromURL(server.getUrl())); svnLog.setRevisionRanges(Collections.singletonList(SvnRevisionRange.create(SVNRevision.create(revision - 1), SVNRevision.create(revision)))); final SvnUpdate update = factory.createUpdate(); String lastAdded = null; for (Map.Entry<String, SVNLogEntryPath> entry : paths.entrySet()) {
SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { SvnLog log = svnOperationFactory.createLog(); log.setSingleTarget(SvnTarget.fromURL(SVNURL.parseURIEncoded(url))); log.addRange(SvnRevisionRange.create(SVNRevision.create(0), SVNRevision.HEAD)); log.run(); } finally { svnOperationFactory.dispose();
File workingCopyLocation = new File( ... ); SvnOperationFactory operationFactory = new SvnOperationFactory(); SvnLog logOperation = operationFactory.createLog(); logOperation.setSingleTarget( SvnTarget.fromFile( workingCopyLocation ) ); logOperation.setRevisionRanges( Collections.singleton( SvnRevisionRange.create( SVNRevision.create( 1 ), SVNRevision.HEAD ) ) ); Collection<SVNLogEntry> logEntries = logOperation.run( null ); System.out.println( "logEntries = " + logEntries );
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { final SvnRemoteDelete remoteDelete = svnOperationFactory.createRemoteDelete(); remoteDelete.setSingleTarget(SvnTarget.fromURL(fileUrl)); remoteDelete.setCommitMessage("Delete a file from the repository"); final SVNCommitInfo commitInfo = remoteDelete.run(); if (commitInfo != null) { final long newRevision = commitInfo.getNewRevision(); System.out.println("Removed a file, revision " + newRevision + " created"); } } finally { svnOperationFactory.dispose(); }
final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); try { final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); final SvnDiffGenerator diffGenerator = new SvnDiffGenerator(); diffGenerator.setBasePath(new File("")); final SvnDiff diff = svnOperationFactory.createDiff(); diff.setSources(SvnTarget.fromURL(url1, svnRevision1), SvnTarget.fromURL(url2, svnRevision1)); diff.setDiffGenerator(diffGenerator); diff.setOutput(byteArrayOutputStream); diff.run(); } finally { svnOperationFactory.dispose(); }
protected SVNBasicClient(ISVNAuthenticationManager authManager, ISVNOptions options) { if (authManager == null) { authManager = SVNWCUtil.createDefaultAuthenticationManager(); } if (options == null) { options = SVNWCUtil.createDefaultOptions(true); } this.operationFactory = new SvnOperationFactory(); setOptions(options); this.operationFactory.setAuthenticationManager(authManager); this.operationFactory.setRepositoryPool(new DefaultSVNRepositoryPool(authManager, options)); this.operationFactory.setAutoDisposeRepositoryPool(true); initDefaults(); }
private TreeMap<File, Map<String, SVNMergeRangeList>> getWcExplicitMergeInfoCatalog(File targetAbsPath, SVNDepth depth) throws SVNException { final SvnGetProperties pg = operation.getOperationFactory().createGetProperties(); final Map<File, String> subtreesWithMergeinfo = new TreeMap<File, String>(); pg.setDepth(depth);
public File checkoutFile(String _rev, String _rel_path) { final SvnOperationFactory svnOperationFactory = new SvnOperationFactory(); File f = null; SVNURL url = null; SvnClient.log.error("Error while checking out URL '" + url + "', revision "+ _rev + ": " + e.getMessage()); } finally { svnOperationFactory.dispose();
@NotNull private SvnOperationFactory createOperationFactory(@NotNull String userName, @NotNull String password) { final SVNWCContext wcContext = new SVNWCContext(new DefaultSVNOptions(getTempDirectory(), true), null); wcContext.setSqliteTemporaryDbInMemory(true); wcContext.setSqliteJournalMode(SqlJetPagerJournalMode.MEMORY); final SvnOperationFactory factory = new SvnOperationFactory(wcContext); factory.setAuthenticationManager(BasicAuthenticationManager.newInstance(userName, password.toCharArray())); svnFactories.add(factory); return factory; }
protected SVNClientImpl(SvnOperationFactory svnOperationFactory) { this.configDir = SVNWCUtil.getDefaultConfigurationDirectory().getAbsolutePath(); this.shouldDisposeSvnOperationsFactory = svnOperationFactory == null; this.svnOperationFactory = svnOperationFactory == null ? new SvnOperationFactory() : svnOperationFactory; this.svnOperationFactory.setEventHandler(getEventHandler()); synchronized (SVNClientImpl.class) { instanceCount++; } }
SvnGetInfo getInfo = getOperationsFactory().createGetInfo(); getInfo.setSingleTarget(SvnTarget.fromURL(url, pegRevision)); getInfo.setRevision(revision);