Package org.tmatesoft.svn.core

Examples of org.tmatesoft.svn.core.SVNErrorMessage


                      repository = null;
                    }
                } else if (entry.getURL() != null){
                    url = entry.getSVNURL();
                } else {
                    SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_MISSING_URL,
                        "''{0}'' has no URL", path);
                    SVNErrorManager.error(err, SVNLogType.WC);
                }
            } finally {
                wcAccess.close();
            }
        }
        String repoPath = "";
        Map locations = null;
        SVNURL rootURL = null;

        if (repository == null) {
            repository = createRepository(url, null, null, true);
        } else {
            // path relative to repository location.
            repoPath = SVNPathUtil.getPathAsChild(repository.getLocation().toString(), url.toString());
            if (repoPath == null) {
                repoPath = "";
            }
        }

        if (pegRevisionNumber < 0) {
            pegRevisionNumber = getRevisionNumber(revision, youngestRevNumber, repository, path);
        }

        if (revision == start && revision == SVNRevision.HEAD) {
            startRevisionNumber = pegRevisionNumber;
        } else {
            startRevisionNumber = getRevisionNumber(start, youngestRevNumber, repository, path);
        }

        if (!end.isValid()) {
            endRevisionNumber = startRevisionNumber;
        } else {
            endRevisionNumber = getRevisionNumber(end, youngestRevNumber, repository, path);
        }

        if (endRevisionNumber == pegRevisionNumber && startRevisionNumber == pegRevisionNumber) {
            SVNRepositoryLocation[] result = new SVNRepositoryLocation[2];
            result[0] = new SVNRepositoryLocation(url, startRevisionNumber);
            result[1] = new SVNRepositoryLocation(url, endRevisionNumber);
            return result;
        }

        rootURL = repository.getRepositoryRoot(true);
        long[] revisionsRange = startRevisionNumber == endRevisionNumber ? new long[] { startRevisionNumber } :
            new long[] {startRevisionNumber, endRevisionNumber};

        try {
            locations = repository.getLocations(repoPath, (Map) null, pegRevisionNumber, revisionsRange);
        } catch (SVNException e) {
            if (e.getErrorMessage() != null && e.getErrorMessage().getErrorCode() == SVNErrorCode.RA_NOT_IMPLEMENTED) {
                locations = getLocations10(repository, pegRevisionNumber, startRevisionNumber, endRevisionNumber);
            } else {
                throw e;
            }
        }

        // try to get locations with 'log' method.
        SVNLocationEntry startPath = (SVNLocationEntry) locations.get(new Long(startRevisionNumber));
        SVNLocationEntry endPath = (SVNLocationEntry) locations.get(new Long(endRevisionNumber));
       
        if (startPath == null) {
            Object source = path != null ? (Object) path : (Object) url;
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_UNRELATED_RESOURCES, "Unable to find repository location for ''{0}'' in revision ''{1}''", new Object[] {source, new Long(startRevisionNumber)});
            SVNErrorManager.error(err, SVNLogType.WC);
        }
        if (endPath == null) {
            Object source = path != null ? (Object) path : (Object) url;
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_UNRELATED_RESOURCES, "The location for ''{0}'' for revision {1} does not exist in the " +
                    "repository or refers to an unrelated object", new Object[] {source, new Long(endRevisionNumber)});
            SVNErrorManager.error(err, SVNLogType.WC);
        }
       
        SVNRepositoryLocation[] result = new SVNRepositoryLocation[2];
View Full Code Here


   
    private Map getLocations10(SVNRepository repos, final long pegRevision, final long startRevision, final long endRevision) throws SVNException {
        final String path = repos.getRepositoryPath("");
        final SVNNodeKind kind = repos.checkPath("", pegRevision);
        if (kind == SVNNodeKind.NONE) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "path ''{0}'' doesn't exist at revision {1}", new Object[] {path, new Long(pegRevision)});
            SVNErrorManager.error(err, SVNLogType.WC);
        }
        long logStart = pegRevision;
        logStart = Math.max(startRevision, logStart);
        logStart = Math.max(endRevision, logStart);
        long logEnd = pegRevision;
        logStart = Math.min(startRevision, logStart);
        logStart = Math.min(endRevision, logStart);
       
        LocationsLogEntryHandler handler = new LocationsLogEntryHandler(path, startRevision, endRevision, pegRevision, kind, getEventDispatcher());
        repos.log(new String[] {""}, logStart, logEnd, true, false, handler);
       
        String pegPath = handler.myPegPath == null ? handler.myCurrentPath : handler.myPegPath;
        String startPath = handler.myStartPath == null ? handler.myCurrentPath : handler.myStartPath;
        String endPath = handler.myEndPath == null ? handler.myCurrentPath : handler.myEndPath;
       
        if (pegPath == null) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.FS_NOT_FOUND, "path ''{0}'' in revision {1} is an unrelated object", new Object[] {path, new Long(logStart)});
            SVNErrorManager.error(err, SVNLogType.WC);
        }
        Map result = new SVNHashMap();
        result.put(new Long(startRevision), new SVNLocationEntry(-1, startPath));
        result.put(new Long(endRevision), new SVNLocationEntry(-1, endPath));
View Full Code Here

        }
        if (prevPath == null) {
            if (kind == SVNNodeKind.DIR) {
                prevPath = path;
            } else {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_UNRELATED_RESOURCES, "Missing changed-path information for ''{0}'' in revision {1}", new Object[] {path, new Long(logEntry.getRevision())});
                SVNErrorManager.error(err, SVNLogType.WC);
            }           
        }
        return prevPath;
    }
View Full Code Here

            url = entry.getSVNURL();
            if (revNum != null && revNum.length > 0) {
                revNum[0] = entry.getRevision();
            }
        } else {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_MISSING_URL,
                    "Entry for ''{0}'' has no URL", path);
            SVNErrorManager.error(err, SVNLogType.WC);
        }
        return url;
    }
View Full Code Here

     * Run export example and process error if any.
     */
    try {
      exportExample();
    } catch (SVNException e) {
      SVNErrorMessage err = e.getErrorMessage();
      /*
       * Display all tree of error messages. Utility method
       * SVNErrorMessage.getFullMessage() may be used instead of the loop.
       */
      while (err != null) {
        System.err.println(err.getErrorCode().getCode() + " : "
            + err.getMessage());
        err = err.getChildErrorMessage();
      }
      System.exit(1);
    }
    System.exit(0);
  }
View Full Code Here

    /*
     * Prepare filesystem directory (export destination).
     */
    File exportDir = new File("exportované");
    if (exportDir.exists()) {
      SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.IO_ERROR,
          "Path ''{0}'' already exists", exportDir);
      throw new SVNException(err);
    }
    exportDir.mkdirs();

    /*
     * Create an instance of SVNRepository class. This class is the main
     * entry point for all "low-level" Subversion operations supported by
     * Subversion protocol.
     *
     * These operations includes browsing, update and commit operations. See
     * SVNRepository methods javadoc for more details.
     */
    SVNRepository repository = SVNRepositoryFactory.create(url);

    /*
     * User's authentication information (name/password) is provided via an
     * ISVNAuthenticationManager instance. SVNWCUtil creates a default
     * authentication manager given user's name and password.
     *
     * Default authentication manager first attempts to use provided user
     * name and password and then falls back to the credentials stored in
     * the default Subversion credentials storage that is located in
     * Subversion configuration area. If you'd like to use provided user
     * name and password only you may use BasicAuthenticationManager class
     * instead of default authentication manager:
     *
     * authManager = new BasicAuthenticationsManager(userName,
     * userPassword);
     *
     * You may also skip this point - anonymous access will be used.
     */
    ISVNAuthenticationManager authManager = SVNWCUtil
        .createDefaultAuthenticationManager(userName, userPassword);
    repository.setAuthenticationManager(authManager);

    /*
     * Get type of the node located at URL we used to create SVNRepository. ""
     * (empty string) is path relative to that URL, -1 is value that mya be
     * used to specify HEAD (latest) revision.
     */
    SVNNodeKind nodeKind = repository.checkPath("", -1);
    if (nodeKind == SVNNodeKind.NONE) {
      SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.UNKNOWN,
          "No entry at URL ''{0}''", url);
      throw new SVNException(err);
    } else if (nodeKind == SVNNodeKind.FILE) {
      SVNErrorMessage err = SVNErrorMessage
          .create(
              SVNErrorCode.UNKNOWN,
              "Entry at URL ''{0}'' is a file while directory was expected",
              url);
      throw new SVNException(err);
View Full Code Here

    public void addDir(String path, String copyFromPath,
        long copyFromRevision) throws SVNException {
      File newDir = new File(myRootDirectory, path);
      if (!newDir.exists()) {
        if (!newDir.mkdirs()) {
          SVNErrorMessage err = SVNErrorMessage.create(
              SVNErrorCode.IO_ERROR,
              "error: failed to add the directory ''{0}''.",
              newDir);
          throw new SVNException(err);
        }
View Full Code Here

     */
    public void addFile(String path, String copyFromPath,
        long copyFromRevision) throws SVNException {
      File file = new File(myRootDirectory, path);
      if (file.exists()) {
        SVNErrorMessage err = SVNErrorMessage.create(
            SVNErrorCode.IO_ERROR,
            "error: exported file ''{0}'' already exists!", file);
        throw new SVNException(err);
      }
      try {
        file.createNewFile();
      } catch (IOException e) {
        SVNErrorMessage err = SVNErrorMessage.create(
            SVNErrorCode.IO_ERROR,
            "error: cannot create new  file ''{0}''", file);
        throw new SVNException(err);
      }
    }
View Full Code Here

     * @since                 1.2, SVN 1.5
     */
    public void doDiff(SVNURL url, SVNRevision pegRevision, SVNRevision rN, SVNRevision rM, SVNDepth depth,
            boolean useAncestry, OutputStream result) throws SVNException {
        if (!rN.isValid() || !rM.isValid()) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "Both rN and rM revisions should be specified");           
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        }
        if (rN.isLocal() || rM.isLocal()) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "Both rN and rM revisions must be non-local for a pegged diff of an URL");           
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        }
        getDiffGenerator().init(url.toString(), url.toString());
        doDiffURLURL(url, null, rN, url, null, rM, pegRevision, depth, useAncestry, result);
View Full Code Here

     * @since                 1.2, SVN 1.5
     */
    public void doDiff(File path, SVNRevision pegRevision, SVNRevision rN, SVNRevision rM, SVNDepth depth,
            boolean useAncestry, OutputStream result, Collection changeLists) throws SVNException {
        if (!rN.isValid() || !rM.isValid()) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "Both rN and rM revisions should be specified");           
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        }
        boolean rNisLocal = rN == SVNRevision.BASE || rN == SVNRevision.WORKING;
        boolean rMisLocal = rM == SVNRevision.BASE || rM == SVNRevision.WORKING;
        if (rNisLocal && rMisLocal) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "At least one revision must be non-local for a pegged diff");           
            SVNErrorManager.error(err, SVNLogType.DEFAULT);
        }
        path = path.getAbsoluteFile();
        getDiffGenerator().init(path.getAbsolutePath(), path.getAbsolutePath());
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.SVNErrorMessage

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.