Examples of SVNClientManager

  • org.tmatesoft.svn.core.wc.SVNClientManager
    ault options and authentication drivers to use SVNClientManager clientManager = SVNClientManager.newInstance(); ... //2.provided options and default authentication drivers to use ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions); ... //3.provided options and authentication drivers to use ISVNOptions myOptions; ISVNAuthenticationManager myAuthManager; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, myAuthManager); ... //4.provided options driver and user's credentials to make //a default authentication driver use them ISVNOptions myOptions; ... SVNClientManager clientManager = SVNClientManager.newInstance(myOptions, "name", "passw");
    Having instantiated an SVNClientManager in one of these ways, all the SVN*Client objects it will provide you will share those drivers, so you don't need to code much to provide the same drivers to each SVN*Client instance by yourself.
  • With SVNClientManager you don't need to create and keep your SVN*Client objects by youself - SVNClientManager will do all the work for you, so this will certainly bring down your efforts on coding and your code will be clearer and more flexible. All you need is to create an SVNClientManager instance.
  • Actually every SVN*Client object is instantiated only at the moment of the first call to an appropriate SVNClientManager's get method:
     SVNClientManager clientManager; ... //an update client will be created only at that moment when you  //first call this method for getting your update client, but if you //have already called it once before, then the method will return //that update client object instantiated in previous... so, it's //quite cheap, you see..  SVNUpdateClient updateClient = clientManager.getUpdateClient();

  • You can provide a single event handler that will be used by all SVN*Client objects provided by SVNClientManager:
     import org.tmatesoft.svn.core.wc.ISVNEventHandler; ... ISVNEventHandler commonEventHandler; SVNClientManager clientManager = SVNClientManager.newInstance(); ... //will be used by all SVN*Client objects //obtained from your client manager clientManager.setEventHandler(commonEventHandler); 
  • @version 1.3 @author TMate Software Ltd. @since 1.2 @see ISVNEventHandler @see Examples

  • Examples of org.exist.versioning.svn.wc.SVNClientManager

      @Override
      public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
        String uri = args[0].getStringValue();
        SVNRepositoryFactoryImpl.setup();
        SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(false), "", "");

        SVNStatusClient statusClient = manager.getStatusClient();
       
        SVNWCClient wcClient = manager.getWCClient();

        MemTreeBuilder builder = context.getDocumentBuilder();
            builder.startDocument();
            builder.startElement(new QName("status", null, null), null);
       
    View Full Code Here

    Examples of org.exist.versioning.svn.wc.SVNClientManager

         * @param contextSequence
         */
        public Sequence eval(Sequence[] args, Sequence contextSequence) throws XPathException {
            String uri = args[0].getStringValue();
            DefaultSVNOptions options = SVNWCUtil.createDefaultOptions(true);
            SVNClientManager manager = SVNClientManager.newInstance(options, "", "");
           
            try {
          manager.getWCClient().doCleanup(new Resource(uri));
        } catch (SVNException e) {
          throw new XPathException(this, e.getMessage(), e);
        }
           
            return Sequence.EMPTY_SEQUENCE; 
    View Full Code Here

    Examples of org.exist.versioning.svn.wc.SVNClientManager

          password = params[1];
        }
          new WorkingCopy(userName, password);

          SVNRepositoryFactoryImpl.setup();
        SVNClientManager manager = SVNClientManager.newInstance(SVNWCUtil.createDefaultOptions(false), userName, password);
        SVNStatusClient statusClient = manager.getStatusClient();
    //    SVNWCClient wcClient = manager.getWCClient();
        try {
          statusClient.doStatus(new Resource(collection), SVNRevision.HEAD, SVNDepth.getInfinityOrFilesDepth(true), true, true, false, false,  new AddStatusHandler(), null);
        } catch (SVNException e) {
          e.printStackTrace();
    View Full Code Here

    Examples of org.exist.versioning.svn.wc.SVNClientManager

                SamplesUtility.createRepository(reposRoot);
                SVNCommitInfo info = SamplesUtility.createRepositoryTree(reposRoot);
                //print out new revision info
                System.out.println(info);

                SVNClientManager clientManager = SVNClientManager.newInstance();
               
                SVNURL reposURL = SVNURL.fromFile(reposRoot);

                //copy A to A_copy in repository (url-to-url copy)
                SVNCopyClient copyClient = clientManager.getCopyClient();
                SVNURL A_URL = reposURL.appendPath("A", true);
                SVNURL copyTargetURL = reposURL.appendPath("A_copy", true);
                SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, A_URL);
                info = copyClient.doCopy(new SVNCopySource[] { copySource }, copyTargetURL, false, false, true,
                        "copy A to A_copy", null);
                //print out new revision info
                System.out.println(info);
               
                //checkout the entire repository tree
                SamplesUtility.checkOutWorkingCopy(reposURL, wcRoot);

               
                //now make some changes to the A tree
                SamplesUtility.writeToFile(new File(wcRoot, "A/B/lambda"), "New text appended to 'lambda'", true);
                SamplesUtility.writeToFile(new File(wcRoot, "A/mu"), "New text in 'mu'", false);
               
                SVNWCClient wcClient = SVNClientManager.newInstance().getWCClient();
                wcClient.doSetProperty(new File(wcRoot, "A/B"), "spam", SVNPropertyValue.create("egg"), false,
                        SVNDepth.EMPTY, null, null);

                //commit local changes
                SVNCommitClient commitClient = clientManager.getCommitClient();
                commitClient.doCommit(new File[] { wcRoot }, false, "committing changes", null, null, false, false, SVNDepth.INFINITY);

                //now make some local changes to the A_copy tree
                //change file contents of A_copy/B/lambda and A_copy/mu
                SamplesUtility.writeToFile(new File(wcRoot, "A_copy/B/lambda"), "New text in copied 'lambda'", true);
                SamplesUtility.writeToFile(new File(wcRoot, "A_copy/mu"), "New text in copied 'mu'", false);

                //now diff the base revision of the working copy against the repository
                SVNDiffClient diffClient = clientManager.getDiffClient();

                /*
                 * Since we provided no custom ISVNOptions implementation to SVNClientManager, our
                 * manager uses DefaultSVNOptions, which is set to all SVN*Client classes which the
                 * manager produces. So, we can cast ISVNOptions to DefaultSVNOptions.
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

          /*
           * Creates an instance of SVNClientManager providing authentication
           * information (name, password) and an options driver
           */
          SVNClientManager ourClientManager = SVNClientManager
              .newInstance(options);
          SVNUpdateClient updateClient = ourClientManager.getUpdateClient();

          /*
           * Creates the event handler to display information
           */
          ourClientManager.setEventHandler(new SVNEventAdapter() {
            public void handleEvent(SVNEvent event, double progress) {
              SVNEventAction action = event.getAction();
              File curFile = event.getFile();

              String path = curFile.getAbsolutePath();
              path = path.substring(path.indexOf(FOLDER_NAME));

              if (action == SVNEventAction.ADD
                  || action == SVNEventAction.UPDATE_ADD) {
                m_taskOutput.append("Downloading " + path + " \n");

                m_taskOutput.setCaretPosition(m_taskOutput
                    .getDocument().getLength());
                System.out.println("Downloading " + curFile.getName());
              }
              if (action == SVNEventAction.STATUS_COMPLETED
                  || action == SVNEventAction.UPDATE_COMPLETED) {
                setProgress(100);
                m_taskOutput.append("Download completed. ");
                m_taskOutput.setCaretPosition(m_taskOutput
                    .getDocument().getLength());
                System.out.println("Download completed. ");

              }
            }
          });

          /*
           * sets externals not to be ignored during the checkout
           */
          updateClient.setIgnoreExternals(false);

          /*
           * A url of a repository to check out
           */
          SVNURL url = null;
          try {
            url = SVNURL.parseURIDecoded("http://" + SVN_URL);
          } catch (SVNException e2) {
            e2.printStackTrace();
          }
          /*
           * A revision to check out
           */
          SVNRevision revision = SVNRevision.HEAD;

          /*
           * A revision for which you're sure that the url you specify is
           * exactly what you need
           */
          SVNRevision pegRevision = SVNRevision.HEAD;

          /*
           * A local path where a Working Copy will be ckecked out
           */
          File destPath = new File(m_installpath);

          /*
           * returns the number of the revision at which the working copy is
           */
          try {
            System.out.println(m_installpath);
            m_taskOutput.append("Game folder: " + m_installpath + "\n");
            boolean exists = destPath.exists();
            if (!exists) {
              m_taskOutput
                  .append("Installing...\nPlease be patient while PokeNet is downloaded...\n");
              System.out.println("Installing...");
              updateClient.doCheckout(url, destPath, pegRevision,
                  revision, SVNDepth.INFINITY, true);

            } else {
              ourClientManager.getWCClient().doCleanup(destPath);
              m_taskOutput.append("Updating...\n");
              System.out.println("Updating...\n");
              updateClient.doUpdate(destPath, revision,
                  SVNDepth.INFINITY, true, true);
            }
          } catch (SVNException e1) {
            // It's probably locked, lets cleanup and resume.
            e1.printStackTrace();
            try {
              ourClientManager.getWCClient().doCleanup(destPath);
              m_taskOutput.append("Resuming Download...\n");
              System.out.println("Resuming Download...\n");
              updateClient.doUpdate(destPath, revision,
                  SVNDepth.INFINITY, true, true);
            } catch (SVNException e) {
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

        DAVRepositoryFactory.setup();
      }

      private void initClientManager(String url, String username, String password) {
        // 1# instantiate a new object of type SVNClientManager and
        SVNClientManager manager = SVNClientManager.newInstance(defaultOpts, username, password);
        ISVNAuthenticationManager authManager = SVNWCUtil.createDefaultAuthenticationManager(
            username, password);
        manager.setAuthenticationManager(authManager);

        // 2# add the client manager to the pool, for later use
        clientManagers.put(url, manager);
      }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

                return new DefaultPooledObject<SVNClientManager>(obj);
            }

            @Override
            public void destroyObject(final PooledObject<SVNClientManager> p) throws Exception {
                final SVNClientManager m = p.getObject();
                m.dispose();
            }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

        }

        @Override
        public <T> T doWithClientAndRepository(final SvnOperation<T> operation) throws StoreException {
            checkShutdownState();
            SVNClientManager clientManager = null;
            try {
                clientManager = clientManagerPool.borrowObject();
                if (clientManager == null) {
                    throw new StoreException.ReadException("Failed to acquire SVNClientManager");
                }
                // do not explicitly close the session because mayReuse=true
                final SVNRepository repository = clientManager.createRepository(svnUrl, true);

                return operation.execute(repository, clientManager);
            } catch (Exception e) {
                Throwables.propagateIfInstanceOf(e, StoreException.class);
                throw operation.handleException(e);
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

            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();
            }
        }
    View Full Code Here

    Examples of org.tmatesoft.svn.core.wc.SVNClientManager

                SamplesUtility.createRepository(reposRoot);
                SVNCommitInfo info = SamplesUtility.createRepositoryTree(reposRoot);
                //print out new revision info
                System.out.println(info);

                SVNClientManager clientManager = SVNClientManager.newInstance();
                clientManager.setEventHandler(new EventHandler());
               
                SVNURL reposURL = SVNURL.fromFile(reposRoot);

                //copy A to A_copy in repository (url-to-url copy)
                SVNCopyClient copyClient = clientManager.getCopyClient();
                SVNURL A_URL = reposURL.appendPath("A", true);
                SVNURL copyTargetURL = reposURL.appendPath("A_copy", true);
                SVNCopySource copySource = new SVNCopySource(SVNRevision.UNDEFINED, SVNRevision.HEAD, A_URL);
                info = copyClient.doCopy(new SVNCopySource[] { copySource }, copyTargetURL, false, false, true,
                        "copy A to A_copy", null);
                //print out new revision info
                System.out.println(info);
               
                //checkout the entire repository tree
                SamplesUtility.checkOutWorkingCopy(reposURL, wcRoot);

               
                //now make some changes to the A tree
                SamplesUtility.writeToFile(new File(wcRoot, "iota"), "New text appended to 'iota'", true);
                SamplesUtility.writeToFile(new File(wcRoot, "A/mu"), "New text in 'mu'", false);
               
                SVNWCClient wcClient = SVNClientManager.newInstance().getWCClient();
                wcClient.doSetProperty(new File(wcRoot, "A/B"), "spam", SVNPropertyValue.create("egg"), false,
                        SVNDepth.EMPTY, null, null);

                //commit local changes
                SVNCommitClient commitClient = clientManager.getCommitClient();
                commitClient.doCommit(new File[] { wcRoot }, false, "committing changes", null, null, false, false, SVNDepth.INFINITY);
               
                //now diff the base revision of the working copy against the repository
                SVNDiffClient diffClient = clientManager.getDiffClient();
                SVNRevisionRange rangeToMerge = new SVNRevisionRange(SVNRevision.create(1), SVNRevision.HEAD);
               
                diffClient.doMerge(A_URL, SVNRevision.HEAD, Collections.singleton(rangeToMerge),
                        new File(wcRoot, "A_copy"), SVNDepth.UNKNOWN, true, false, false, false);
               
    View Full Code Here
    TOP
    Copyright © 2018 www.massapi.com. All rights reserved.
    All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.