Package org.tmatesoft.svn.core.wc

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


       * 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) {
          e.printStackTrace();
        }
      }
View Full Code Here


        if (pair.mySourceKind == SVNNodeKind.DIR) {
            // do checkout
            String srcURL = pair.myOriginalSource;
            SVNURL url = SVNURL.parseURIEncoded(srcURL);
            SVNUpdateClient updateClient = new SVNUpdateClient(getRepositoryPool(), getOptions());
            updateClient.setEventHandler(getEventDispatcher());

            File dstFile = new File(pair.myDst);
            SVNRevision srcRevision = pair.mySourceRevision;
            SVNRevision srcPegRevision = pair.mySourcePegRevision;
            updateClient.doCheckout(url, dstFile, srcPegRevision, srcRevision, SVNDepth.INFINITY, false);

            if (sameRepositories) {
                url = SVNURL.parseURIEncoded(pair.mySource);

                SVNAdminArea dstArea = dstAccess.open(dstFile, true, SVNWCAccess.INFINITE_DEPTH);
View Full Code Here

            if(!userDir.mkdir()) {
                throw new IOException("Could not create directory " + userDir);
            }
        }

        final SVNUpdateClient updateClient = userClientManager.getUpdateClient();
        if (SVNWCUtil.isVersionedDirectory(userDir)) {
            final SVNStatusClient statusClient = userClientManager.getStatusClient();
            final SVNStatus status = statusClient.doStatus(userDir, false);
            final SVNStatusType contentStatus = status.getContentsStatus();
            logger.info("(svn) status for " + userDir + " is " + contentStatus);
            if (contentStatus == SVNStatusType.STATUS_NORMAL) {
                long elapsed = -System.currentTimeMillis();
                if (logger.isDebugEnabled()) {
                    logger.debug("(svn) current r" + status.getRevision().getNumber() " svn update " + svnUrl + " into " + userDir);
                }
                long workingDirRevision = updateClient.doUpdate(userDir, SVNRevision.HEAD, SVNDepth.INFINITY, false, false);
                elapsed += System.currentTimeMillis();
                logger.info(String.format("Updated working directory (%s) to revision %d in %d ms", userDir.getAbsolutePath(), workingDirRevision, elapsed));
            } else {
                logger.warn(String.format("Working directory (%s) is in a bad state: %s Cleaning up and checking out fresh.", userDir.getAbsolutePath(), contentStatus));
                if (logger.isDebugEnabled()) {
                    logger.debug(String.format("Deleting working directory contents (%s)", userDir.getAbsolutePath()));
                }
                deleteDirectoryContents(userDir);
                long elapsed = -System.currentTimeMillis();
                if (logger.isDebugEnabled()) {
                    logger.debug("(svn) svn co " + svnUrl + " into " + userDir);
                }
                long workingDirRevision = updateClient.doCheckout(svnUrl, userDir, null, SVNRevision.HEAD, SVNDepth.INFINITY, false);
                elapsed += System.currentTimeMillis();
                logger.info(String.format("Checked out working directory (%s) to revision %d in %d ms", userDir.getAbsolutePath(), workingDirRevision, elapsed));
            }
        } else {
            long elapsed = -System.currentTimeMillis();
            if (logger.isDebugEnabled()) {
                logger.debug("(svn) svn co " + svnUrl + " into " + userDir);
            }
            long workingDirRevision = updateClient.doCheckout(svnUrl, userDir, null, SVNRevision.HEAD, SVNDepth.INFINITY, false);
            elapsed += System.currentTimeMillis();
            logger.info(String.format("Checked out working directory (%s) to revision %d in %d ms", userDir.getAbsolutePath(), workingDirRevision, elapsed));
        }
    }
View Full Code Here

            //commit local changes
            SVNCommitClient commitClient = clientManager.getCommitClient();
            commitClient.doCommit(new File[] { wcRoot }, false, "committing changes", null, null, false, false, SVNDepth.INFINITY);
           
            //roll back changes in the working copy - update to revision 1
            SVNUpdateClient updateClient = clientManager.getUpdateClient();
            updateClient.doUpdate(wcRoot, SVNRevision.create(1), SVNDepth.INFINITY, false, false);
           
            //now diff the base revision of the working copy against the repository
            SVNDiffClient diffClient = clientManager.getDiffClient();

            /*
 
View Full Code Here

       
        return commitEditor.closeEdit();
    }
   
    public static void checkOutWorkingCopy(SVNURL url, File wcRoot) throws SVNException {
        SVNUpdateClient updateClient = SVNClientManager.newInstance().getUpdateClient();
        updateClient.doCheckout(url, wcRoot, SVNRevision.UNDEFINED, SVNRevision.HEAD, SVNDepth.INFINITY,
                false);
    }
View Full Code Here

    public long[] update(String[] path, Revision revision, int depth, boolean depthIsSticky, boolean ignoreExternals, boolean allowUnverObstructions) throws ClientException {
        if (path == null || path.length == 0) {
            return new long[]{};
        }
        long[] updated = new long[path.length];
        SVNUpdateClient updater = getSVNUpdateClient();
        boolean oldIgnore = updater.isIgnoreExternals();
        updater.setIgnoreExternals(ignoreExternals);
        updater.setEventPathPrefix("");
        SVNDepth svnDepth = JavaHLObjectFactory.getSVNDepth(depth);
        SVNRevision rev = JavaHLObjectFactory.getSVNRevision(revision);
        try {
            for (int i = 0; i < updated.length; i++) {
                updated[i] = updater.doUpdate(new File(path[i]).getAbsoluteFile(), rev, svnDepth,
                        allowUnverObstructions, depthIsSticky);
            }
        } catch (SVNException e) {
            throwException(e);
        } finally {
            updater.setIgnoreExternals(oldIgnore);
            updater.setEventPathPrefix(null);
            resetLog();
            SVNFileUtil.sleepForTimestamp();
        }
        return updated;
    }
View Full Code Here

    public long doExport(String srcPath, String destPath, Revision revision, Revision pegRevision, boolean force, boolean ignoreExternals, boolean recurse, String nativeEOL) throws ClientException {
        return doExport(srcPath, destPath, revision, pegRevision, force, ignoreExternals, JavaHLObjectFactory.infinityOrFiles(recurse), nativeEOL);
    }

    public long doExport(String srcPath, String destPath, Revision revision, Revision pegRevision, boolean force, boolean ignoreExternals, int depth, String nativeEOL) throws ClientException {
        SVNUpdateClient updater = getSVNUpdateClient();
        boolean oldIgnore = updater.isIgnoreExternals();
        updater.setIgnoreExternals(ignoreExternals);
        try {
            if (isURL(srcPath)) {
                return updater.doExport(SVNURL.parseURIEncoded(srcPath), new File(destPath).getAbsoluteFile(),
                        JavaHLObjectFactory.getSVNRevision(pegRevision), JavaHLObjectFactory.getSVNRevision(revision), nativeEOL, force, JavaHLObjectFactory.getSVNDepth(depth));
            }
            return updater.doExport(new File(srcPath).getAbsoluteFile(), new File(destPath).getAbsoluteFile(),
                    JavaHLObjectFactory.getSVNRevision(pegRevision), JavaHLObjectFactory.getSVNRevision(revision), nativeEOL, force, JavaHLObjectFactory.getSVNDepth(depth));
        } catch (SVNException e) {
            throwException(e);
        } finally {
            updater.setIgnoreExternals(oldIgnore);
            resetLog();
        }
        return -1;
    }
View Full Code Here

            resetLog();
        }
    }

    public void relocate(String from, String to, String path, boolean recurse) throws ClientException {
        SVNUpdateClient client = getSVNUpdateClient();
        try {
            client.doRelocate(new File(path).getAbsoluteFile(), SVNURL.parseURIEncoded(from), SVNURL.parseURIEncoded(to), recurse);
        } catch (SVNException e) {
            throwException(e);
        } finally {
            resetLog();
        }
View Full Code Here

        return doSwitch(path, url, revision, Revision.HEAD, JavaHLObjectFactory.unknownOrFiles(recurse), false, false, false);
    }

    public long doSwitch(String path, String url, Revision revision, Revision pegRevision, int depth,
            boolean depthIsSticky, boolean ignoreExternals, boolean allowUnverObstructions) throws ClientException {
        SVNUpdateClient updater = getSVNUpdateClient();
        try {
            return updater.doSwitch(new File(path).getAbsoluteFile(), SVNURL.parseURIEncoded(url),
                    JavaHLObjectFactory.getSVNRevision(pegRevision),
                    JavaHLObjectFactory.getSVNRevision(revision), JavaHLObjectFactory.getSVNDepth(depth),
                    allowUnverObstructions, depthIsSticky);
        } catch (SVNException e) {
            throwException(e);
View Full Code Here

    public long checkout(String moduleName, String destPath, Revision revision, Revision pegRevision, boolean recurse, boolean ignoreExternals) throws ClientException {
        return checkout(moduleName, destPath, revision, pegRevision, JavaHLObjectFactory.infinityOrFiles(recurse), ignoreExternals, false);
    }

    public long checkout(String moduleName, String destPath, Revision revision, Revision pegRevision, int depth, boolean ignoreExternals, boolean allowUnverObstructions) throws ClientException {
        SVNUpdateClient updater = getSVNUpdateClient();
        boolean oldIgnoreExternals = updater.isIgnoreExternals();
        updater.setIgnoreExternals(ignoreExternals);
        try {
            File path = new File(destPath).getAbsoluteFile();
            return updater.doCheckout(SVNURL.parseURIEncoded(moduleName), path, JavaHLObjectFactory.getSVNRevision(pegRevision),
                    JavaHLObjectFactory.getSVNRevision(revision), JavaHLObjectFactory.getSVNDepth(depth), allowUnverObstructions);
        } catch (SVNException e) {
            throwException(e);
        } finally {
            updater.setIgnoreExternals(oldIgnoreExternals);
            resetLog();
        }
        return -1;
    }
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.wc.SVNUpdateClient

Copyright © 2018 www.massapicom. 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.