Java Code Examples for org.tmatesoft.svn.core.wc.SVNClientManager#newInstance()
The following examples show how to use
org.tmatesoft.svn.core.wc.SVNClientManager#newInstance() .
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: SvnKitProcessor.java From StatSVN with GNU Lesser General Public License v3.0 | 6 votes |
public SVNClientManager getManager() { if (manager==null) { // initialize DAVRepositoryFactory.setup(); SVNRepositoryFactoryImpl.setup(); FSRepositoryFactory.setup(); //readonly - configuration options are available only for reading DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true); options.setAuthStorageEnabled(false); // Creates an instance of SVNClientManager providing an options driver & username & password if (SvnConfigurationOptions.getSvnUsername()!=null && SvnConfigurationOptions.getSvnPassword()!=null) manager = SVNClientManager.newInstance(options, SvnConfigurationOptions.getSvnUsername(), SvnConfigurationOptions.getSvnPassword()); else manager = SVNClientManager.newInstance(options); } return manager; }
Example 2
Source File: TestCheckOut.java From klask-io with GNU General Public License v3.0 | 5 votes |
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()); }
Example 3
Source File: SvnUpdateTest.java From git-as-svn with GNU General Public License v2.0 | 5 votes |
/** * Bug: svn up doesnt remove file #18 * <pre> * bozaro@landfill:/tmp/test/git-as-svn$ echo > test.txt * bozaro@landfill:/tmp/test/git-as-svn$ svn add test.txt * A test.txt * bozaro@landfill:/tmp/test/git-as-svn$ svn commit -m "Add new file" * Добавляю test.txt * Передаю данные . * Committed revision 58. * bozaro@landfill:/tmp/test/git-as-svn$ svn up -r 57 * Updating '.': * В редакции 57. * bozaro@landfill:/tmp/test/git-as-svn$ ls -l test.txt * -rw-rw-r-- 1 bozaro bozaro 1 авг. 15 00:50 test.txt * bozaro@landfill:/tmp/test/git-as-svn$ * </pre> */ @Test public void addAndUpdate() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SvnOperationFactory factory = server.createOperationFactory(); final SVNClientManager client = SVNClientManager.newInstance(factory); // checkout final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl())); checkout.setSingleTarget(SvnTarget.fromFile(server.getTempDirectory().toFile())); checkout.setRevision(SVNRevision.HEAD); final long revision = checkout.run(); // create file Path newFile = server.getTempDirectory().resolve("somefile.txt"); TestHelper.saveFile(newFile, "Bla Bla Bla"); // add file client.getWCClient().doAdd(newFile.toFile(), false, false, false, SVNDepth.INFINITY, false, true); // set eof property client.getWCClient().doSetProperty(newFile.toFile(), SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE), false, SVNDepth.INFINITY, null, null); // commit new file client.getCommitClient().doCommit(new File[]{newFile.toFile()}, false, "Add file commit", null, null, false, false, SVNDepth.INFINITY); // update for checkout revision client.getUpdateClient().doUpdate(server.getTempDirectory().toFile(), SVNRevision.create(revision), SVNDepth.INFINITY, false, false); // file must be remove Assert.assertFalse(Files.exists(newFile)); } }
Example 4
Source File: SvnObjectPools.java From proctor with Apache License 2.0 | 5 votes |
@Override public SVNClientManager create() throws Exception { if (requiresAuthentication) { final BasicAuthenticationManager authManager = new BasicAuthenticationManager(username, password); return SVNClientManager.newInstance(null, authManager); } else { return SVNClientManager.newInstance(); } }
Example 5
Source File: SvnCheckoutTest.java From git-as-svn with GNU General Public License v2.0 | 4 votes |
/** * <pre> * svn checkout * echo > test.txt * svn commit -m "create test.txt" * rev N * echo foo > test.txt * svn commit -m "modify test.txt" * svn up rev N * </pre> */ @Test public void checkoutAndUpdate() throws Exception { try (SvnTestServer server = SvnTestServer.createEmpty()) { final SVNRepository repo = server.openSvnRepository(); final ISVNEditor editor = repo.getCommitEditor("Initial state", null, false, null); editor.openRoot(-1); editor.addDir("/src", null, -1); editor.addDir("/src/main", null, -1); editor.addFile("/src/main/source.txt", null, -1); editor.changeFileProperty("/src/main/source.txt", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/src/main/source.txt", null, "Source content"); editor.closeDir(); editor.addDir("/src/test", null, -1); editor.addFile("/src/test/test.txt", null, -1); editor.changeFileProperty("/src/test/test.txt", SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE)); sendDeltaAndClose(editor, "/src/test/test.txt", null, "Test content"); editor.closeDir(); editor.closeDir(); editor.closeDir(); editor.closeEdit(); // checkout final SvnOperationFactory factory = server.createOperationFactory(); final SvnCheckout checkout = factory.createCheckout(); checkout.setSource(SvnTarget.fromURL(server.getUrl())); checkout.setSingleTarget(SvnTarget.fromFile(server.getTempDirectory().toFile())); checkout.setRevision(SVNRevision.HEAD); checkout.run(); final Path file = server.getTempDirectory().resolve("src/main/someFile.txt"); final SVNClientManager client = SVNClientManager.newInstance(factory); // create file final SVNCommitInfo commit; { Assert.assertFalse(Files.exists(file)); TestHelper.saveFile(file, "New content"); client.getWCClient().doAdd(file.toFile(), false, false, false, SVNDepth.INFINITY, false, true); client.getWCClient().doSetProperty(file.toFile(), SVNProperty.EOL_STYLE, SVNPropertyValue.create(SVNProperty.EOL_STYLE_NATIVE), false, SVNDepth.INFINITY, null, null); commit = client.getCommitClient().doCommit(new File[]{file.toFile()}, false, "Commit new file", null, null, false, false, SVNDepth.INFINITY); } // modify file { Assert.assertTrue(Files.exists(file)); TestHelper.saveFile(file, "Modified content"); client.getCommitClient().doCommit(new File[]{file.toFile()}, false, "Modify up-to-date commit", null, null, false, false, SVNDepth.INFINITY); } // update to previous commit client.getUpdateClient().doUpdate(server.getTempDirectory().toFile(), SVNRevision.create(commit.getNewRevision()), SVNDepth.INFINITY, false, false); // check no tree conflist ArrayList<String> changeLists = new ArrayList<>(); client.getStatusClient().doStatus(server.getTempDirectory().toFile(), SVNRevision.WORKING, SVNDepth.INFINITY, false, false, true, false, status -> { Assert.assertNull(status.getTreeConflict(), status.getFile().toString()); Assert.assertNull(status.getConflictNewFile(), status.getFile().toString()); }, changeLists); Assert.assertTrue(changeLists.isEmpty()); } }
Example 6
Source File: SvnProctorUtils.java From proctor with Apache License 2.0 | 4 votes |
static void doInWorkingDirectory( final Logger logger, final File userDir, final String username, final String password, final SVNURL svnUrl, final FileBasedProctorStore.ProctorUpdater updater, final String comment) throws IOException, SVNException, Exception { final BasicAuthenticationManager authManager = new BasicAuthenticationManager(username, password); final SVNClientManager userClientManager = SVNClientManager.newInstance(null, authManager); final SVNWCClient wcClient = userClientManager.getWCClient(); try { // Clean up the UserDir SvnProctorUtils.cleanUpWorkingDir(logger, userDir, svnUrl, userClientManager); /* if (previousVersion != 0) { final Collection<?> changesSinceGivenVersion = repo.log(new String[] { "" }, null, previousVersion, -1, false, false); if (! changesSinceGivenVersion.isEmpty()) { // TODO: the baseline version is out of date, so need to go back to the user } } updateClient.doCheckout(checkoutUrl, workingDir, null, SVNRevision.HEAD, SVNDepth.INFINITY, false); */ final FileBasedProctorStore.RcsClient rcsClient = new SvnPersisterCoreImpl.SvnRcsClient(wcClient); final boolean thingsChanged = updater.doInWorkingDirectory(rcsClient, userDir); if (thingsChanged) { final SVNCommitClient commitClient = userClientManager.getCommitClient(); final SVNCommitPacket commit = commitClient.doCollectCommitItems(new File[]{userDir}, false, false, SVNDepth.INFINITY, new String[0]); long elapsed = -System.currentTimeMillis(); final SVNCommitInfo info = commitClient.doCommit(commit, /* keepLocks */ false, comment); elapsed += System.currentTimeMillis(); if (logger.isDebugEnabled()) { final StringBuilder changes = new StringBuilder("Committed " + commit.getCommitItems().length + " changes: "); for (final SVNCommitItem item : commit.getCommitItems()) { changes.append(item.getKind() + " - " + item.getPath() + ", "); } changes.append(String.format(" in %d ms new revision: r%d", elapsed, info.getNewRevision())); logger.debug(changes.toString()); } } } finally { userClientManager.dispose(); } }