Package org.tmatesoft.svn.core.internal.wc

Examples of org.tmatesoft.svn.core.internal.wc.SVNPath


            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
        }
        if (targets.size() > 2) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR), SVNLogType.CLIENT);
        }
        SVNPath switchURL = new SVNPath((String) targets.get(0), true);
        if (!switchURL.isURL()) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.BAD_URL,
                    "''{0}'' doesn not appear to be a URL", switchURL.getTarget()), SVNLogType.CLIENT);
        }
        SVNPath target;
        if (targets.size() == 1) {
            target = new SVNPath("");
        } else {
            target = new SVNPath((String) targets.get(1));
        }
        if (!getSVNEnvironment().isVersioned(target.getTarget())) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.ENTRY_NOT_FOUND,
                    "''{0}'' does not appear to be a working copy path", target.getTarget());
            SVNErrorManager.error(err, SVNLogType.CLIENT);
        }
        SVNUpdateClient client = getSVNEnvironment().getClientManager().getUpdateClient();
        if (!getSVNEnvironment().isQuiet()) {
            client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment(), false, false, false));
        }
       
        SVNDepth depth = getSVNEnvironment().getDepth();
        boolean depthIsSticky = false;
        if (getSVNEnvironment().getSetDepth() != SVNDepth.UNKNOWN) {
            depth = getSVNEnvironment().getSetDepth();
            depthIsSticky = true;
        }
       
        client.doSwitch(target.getFile(), switchURL.getURL(), switchURL.getPegRevision(),
                getSVNEnvironment().getStartRevision(), depth,
                getSVNEnvironment().isForce(), depthIsSticky);   
    }
View Full Code Here


   
    protected void relocate(List targets) throws SVNException {
        if (targets.size() < 2) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
        }
        SVNPath from = new SVNPath((String) targets.get(0));
        SVNPath to = new SVNPath((String) targets.get(1));
        if (from.isURL() != to.isURL() || !from.isURL()) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.INCORRECT_PARAMS,
                    "''{0}'' to ''{1}'' is not a valid relocation", new Object[] {from.getTarget(), to.getTarget()});
            SVNErrorManager.error(err, SVNLogType.CLIENT);
        }
        SVNUpdateClient client = getSVNEnvironment().getClientManager().getUpdateClient();
        if (targets.size() == 2) {
            SVNPath target = new SVNPath("");
            client.doRelocate(target.getFile(), from.getURL(), to.getURL(), getSVNEnvironment().getDepth().isRecursive());
        } else {
            for(int i = 2; i < targets.size(); i++) {
                SVNPath target = new SVNPath((String) targets.get(i));
                client.doRelocate(target.getFile(), from.getURL(), to.getURL(), getSVNEnvironment().getDepth().isRecursive());
            }
        }
    }
View Full Code Here

            depth = SVNDepth.EMPTY;
        }
        SVNWCClient client = getSVNEnvironment().getClientManager().getWCClient();
        for(int i = 0; i < targets.size(); i++) {
            String targetName = (String) targets.get(i);
            SVNPath target = new SVNPath(targetName, true);
            SVNRevision pegRevision = target.getPegRevision();
            if (target.isURL() && pegRevision == SVNRevision.UNDEFINED) {
                pegRevision = SVNRevision.HEAD;
            }
            try {
                if (target.isFile()) {
                    client.doInfo(target.getFile(), pegRevision, getSVNEnvironment().getStartRevision(), depth,
                            getSVNEnvironment().getChangelistsCollection(), this);
                } else {
                    client.doInfo(target.getURL(), pegRevision, getSVNEnvironment().getStartRevision(), depth, this);
                }
            } catch (SVNException e) {
                SVNErrorMessage err = e.getErrorMessage();
                if (err.getErrorCode() == SVNErrorCode.UNVERSIONED_RESOURCE) {
                    getSVNEnvironment().getErr().print(SVNCommandUtil.getLocalPath(target.getTarget()) + ": (Not a versioned resource)\n\n");
                } else if (err.getErrorCode() == SVNErrorCode.RA_ILLEGAL_URL) {
                    getSVNEnvironment().getErr().print(target.getTarget() + ": (Not a valid URL)\n\n");
                } else {
                    throw e;
                }
            }
        }
View Full Code Here

        if (getSVNEnvironment().getStartRevision() != SVNRevision.UNDEFINED &&
                getSVNEnvironment().getStartRevision() != SVNRevision.HEAD) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.UNSUPPORTED_FEATURE,
                    "Cannot specify revision (except HEAD) with move operation"), SVNLogType.CLIENT);
        }
        SVNPath dst = new SVNPath((String) targets.remove(targets.size() - 1));
        if (!dst.isURL()) {
            if (getSVNEnvironment().getMessage() != null || getSVNEnvironment().getFileData() != null || getSVNEnvironment().getRevisionProperties() != null) {
                SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_UNNECESSARY_LOG_MESSAGE,
                "Local, non-commit operations do not take a log message or revision properties"), SVNLogType.CLIENT);
            }
        }

        SVNCopyClient client = getSVNEnvironment().getClientManager().getCopyClient();
        if (!getSVNEnvironment().isQuiet()) {
            client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment()));
        }
        client.setCommitHandler(getSVNEnvironment());
        Collection sources = new ArrayList();
        for (Iterator ts = targets.iterator(); ts.hasNext();) {
            String targetName = (String) ts.next();
            SVNPath source = new SVNPath(targetName);
            if (source.isURL()) {
                sources.add(new SVNCopySource(SVNRevision.HEAD, SVNRevision.UNDEFINED, source.getURL()));
            } else {
                sources.add(new SVNCopySource(getSVNEnvironment().getStartRevision(), SVNRevision.UNDEFINED, source.getFile()));
            }
        }
        SVNCopySource[] copySources = (SVNCopySource[]) sources.toArray(new SVNCopySource[sources.size()]);
        try {
            if (dst.isURL()) {
View Full Code Here

        if (targets.size() != 1) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                "Exactly one file argument required"), SVNLogType.CLIENT);
        }
       
        SVNPath target = new SVNPath((String) targets.get(0));
        if (!target.isFile()) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                "Exactly one file argument required"), SVNLogType.CLIENT);
        }
        SVNPropertyValue propertyValue = SVNPropertyValue.create(SVNRevisionProperty.LOG, getEnvironment().readFromFile(target.getFile()));
        SVNURL url = SVNURL.fromFile(repos);
        FSRepository repository = (FSRepository) SVNRepositoryFactory.create(url);
        long rev = getRevisionNumber(getSVNAdminEnvironment().getStartRevision(), repository.getLatestRevision(), repository);

        repository.setRevisionPropertyValue(rev, SVNRevisionProperty.LOG, propertyValue, getSVNAdminEnvironment().isBypassHooks());
View Full Code Here

                SVNErrorManager.error(err, SVNLogType.CLIENT);
            }
            SVNWCClient client = getSVNEnvironment().getClientManager().getWCClient();
            for (Iterator ts = targets.iterator(); ts.hasNext();) {
                String targetName = (String) ts.next();
                SVNPath target = new SVNPath(targetName);
                if (target.isFile()) {
                    if (getSVNEnvironment().getMessage() != null || getSVNEnvironment().getFileData() != null || getSVNEnvironment().getRevisionProperties() != null) {
                        SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_UNNECESSARY_LOG_MESSAGE,
                                "Local, non-commit operations do not take a log message or revision properties");
                        SVNErrorManager.error(err, SVNLogType.CLIENT);
                    }
                    SVNPropertyData property = client.doGetProperty(target.getFile(), propertyName,
                            SVNRevision.UNDEFINED, SVNRevision.WORKING);
                    SVNPropertyValue propertyValue = property != null ? property.getValue() : SVNPropertyValue.create("");
                    byte[] propBytes = SVNPropertyValue.getPropertyAsBytes(propertyValue);                  
                    byte[] bytes = SVNCommandUtil.runEditor(getSVNEnvironment(), getSVNEnvironment().getEditorCommand(), propBytes, "svn-prop");
                    SVNPropertyValue newPropertyValue = SVNPropertyValue.create(propertyName, bytes);
                    if (newPropertyValue != null && !newPropertyValue.equals(propertyValue)) {
                        checkBooleanProperty(propertyName, newPropertyValue);
                        client.doSetProperty(target.getFile(), propertyName, newPropertyValue,
                                getSVNEnvironment().isForce(), SVNDepth.EMPTY, this, null);
                        String message = "Set new value for property ''{0}'' on ''{1}''";
                        String path = SVNCommandUtil.getLocalPath(targetName);
                        message = MessageFormat.format(message, new Object[]{propertyName, path});
                        getSVNEnvironment().getOut().println(message);
                    } else {
                        String message = "No changes to property ''{0}'' on ''{1}''";
                        String path = SVNCommandUtil.getLocalPath(targetName);
                        message = MessageFormat.format(message, new Object[]{propertyName, path});
                        getSVNEnvironment().getOut().println(message);
                    }
                } else {
                    SVNPropertyData property = client.doGetProperty(target.getURL(), propertyName,
                            SVNRevision.UNDEFINED, SVNRevision.HEAD);
                    SVNPropertyValue propertyValue = property != null ? property.getValue() : SVNPropertyValue.create("");
                    byte[] propBytes = SVNPropertyValue.getPropertyAsBytes(propertyValue);                                      
                    byte[] bytes = SVNCommandUtil.runEditor(getSVNEnvironment(), getSVNEnvironment().getEditorCommand(), propBytes, "svn-prop");
                    SVNPropertyValue newPropertyValue = SVNPropertyValue.create(propertyName, bytes);
                    if (newPropertyValue != null && !newPropertyValue.equals(propertyValue)) {
                        checkBooleanProperty(propertyName, newPropertyValue);
                        client.setCommitHandler(getSVNEnvironment());
                        SVNCommitInfo info = client.doSetProperty(target.getURL(), propertyName,
                                newPropertyValue, SVNRevision.HEAD, getSVNEnvironment().getMessage(),
                                getSVNEnvironment().getRevisionProperties(), getSVNEnvironment().isForce(),
                                this);
                        String message = "Set new value for property ''{0}'' on ''{1}''";
                        message = MessageFormat.format(message, new Object[]{propertyName, targetName});
View Full Code Here

        if (targets.size() != 2) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                "Exactly one property name and one file argument required"), SVNLogType.CLIENT);
        }
        String propertyName = (String) targets.get(0);
        SVNPath target = new SVNPath((String) targets.get(1));
        if (!target.isFile()) {
            SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                "Exactly one property name and one file argument required"), SVNLogType.CLIENT);
        }
        SVNPropertyValue propertyValue = SVNPropertyValue.create(propertyName, getEnvironment().readFromFile(target.getFile()));
        SVNURL url = SVNURL.fromFile(repos);
        FSRepository repository = (FSRepository) SVNRepositoryFactory.create(url);
        long rev = getRevisionNumber(getSVNAdminEnvironment().getStartRevision(), repository.getLatestRevision(), repository);

        repository.setRevisionPropertyValue(rev, propertyName, propertyValue,
View Full Code Here

        if (depth == SVNDepth.UNKNOWN) {
            depth = SVNDepth.EMPTY;
        }
        for (Iterator ts = targets.iterator(); ts.hasNext();) {
            String targetName = (String) ts.next();
            SVNPath target = new SVNPath(targetName);
            if (target.isFile()) {
                try {
                    client.doResolve(target.getFile(), depth, choice);
                } catch (SVNException e) {
                    SVNErrorMessage err = e.getErrorMessage();
                    getSVNEnvironment().handleWarning(err, new SVNErrorCode[] {err.getErrorCode()}, getSVNEnvironment().isQuiet());
                }
            }
View Full Code Here

        return true;
    }

    public void run() throws SVNException {
        List targets = getSVNEnvironment().combineTargets(new ArrayList(), true);
        SVNPath source1 = null;
        SVNPath source2 = null;
        SVNPath target = null;
        SVNRevision pegRevision1 = null;
        SVNRevision pegRevision2 = null;
       
        if (targets.size() >= 1) {
            source1 = new SVNPath((String) targets.get(0), true);
            pegRevision1 = source1.getPegRevision();
            if (targets.size() >= 2) {
                source2 = new SVNPath((String) targets.get(1), true);
                pegRevision2 = source2.getPegRevision();
            }
        }
       
        boolean twoSourcesSpecified = true;
        if (targets.size() <= 1) {
            twoSourcesSpecified = false;
        } else if (targets.size() == 2) {
            if (source1.isURL() && !source2.isURL()) {
                twoSourcesSpecified = false;
            }
        }
       
        List rangesToMerge = getSVNEnvironment().getRevisionRanges();
        SVNRevision firstRangeStart = SVNRevision.UNDEFINED;
        SVNRevision firstRangeEnd = SVNRevision.UNDEFINED;
        if (!rangesToMerge.isEmpty()) {
          SVNRevisionRange range = (SVNRevisionRange) rangesToMerge.get(0);
          firstRangeStart = range.getStartRevision();
          firstRangeEnd = range.getEndRevision();
        }
        if (firstRangeStart != SVNRevision.UNDEFINED) {
          if (firstRangeEnd == SVNRevision.UNDEFINED) {
            SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS,
                "Second revision required");
            SVNErrorManager.error(err, SVNLogType.CLIENT);
          }
          twoSourcesSpecified = false;
        }
       
        if (!twoSourcesSpecified) {
            if (targets.size() > 2) {
                SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                    "Too many arguments given"), SVNLogType.CLIENT);
            }
            if (targets.isEmpty()) {
                pegRevision1 = SVNRevision.HEAD;
            } else {
                source2 = source1;
                if (pegRevision1 == null || pegRevision1 == SVNRevision.UNDEFINED) {
                    pegRevision1 = source1.isURL() ? SVNRevision.HEAD : SVNRevision.WORKING;
                }
                if (targets.size() == 2) {
                    target = new SVNPath((String) targets.get(1));
                    if (target.isURL()) {
                      SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                          "Cannot specifify a revision range with two URLs");
                      SVNErrorManager.error(err, SVNLogType.CLIENT);
                    }
                }
            }
        } else {
            if (targets.size() < 2) {
                SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS), SVNLogType.CLIENT);
            } else if (targets.size() > 3) {
                SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CL_ARG_PARSING_ERROR,
                    "Too many arguments given"), SVNLogType.CLIENT);
            }
           
            firstRangeStart = pegRevision1;
            firstRangeEnd = pegRevision2;
           
            if (((firstRangeStart == null || firstRangeStart == SVNRevision.UNDEFINED) && !source1.isURL()) ||
                    ((pegRevision2 == null || pegRevision2 == SVNRevision.UNDEFINED) && !source2.isURL())) {
                SVNErrorManager.error(SVNErrorMessage.create(SVNErrorCode.CLIENT_BAD_REVISION,
                    "A working copy merge source needs an explicit revision"), SVNLogType.CLIENT);
            }
            if (firstRangeStart == null || firstRangeStart == SVNRevision.UNDEFINED) {
                firstRangeStart = SVNRevision.HEAD;
            }
            if (firstRangeEnd == null || firstRangeEnd == SVNRevision.UNDEFINED) {
                firstRangeEnd = SVNRevision.HEAD;
            }
            if (targets.size() >= 3) {
                target = new SVNPath((String) targets.get(2));
            }
        }
       
        if (source1 != null && source2 != null && target == null) {
            if (source1.isURL()) {
                String name1 = SVNPathUtil.tail(source1.getTarget());
                String name2 = SVNPathUtil.tail(source2.getTarget());
                if (name1.equals(name2)) {
                    String decodedPath = SVNEncodingUtil.uriDecode(name1);
                    SVNPath decodedPathTarget = new SVNPath(decodedPath);
                    if (SVNFileType.getType(decodedPathTarget.getFile()) == SVNFileType.FILE) {
                        target = decodedPathTarget;
                    }
                }
            } else if (source1.equals(source2)) {
                String decodedPath = SVNEncodingUtil.uriDecode(source1.getTarget());
                SVNPath decodedPathTarget = new SVNPath(decodedPath);
                if (SVNFileType.getType(decodedPathTarget.getFile()) == SVNFileType.FILE) {
                    target = decodedPathTarget;
                }
            }
        }
        if (target == null) {
            target = new SVNPath("");
        }
        SVNDiffClient client = getSVNEnvironment().getClientManager().getDiffClient();
        if (!getSVNEnvironment().isQuiet()) {
            client.setEventHandler(new SVNNotifyPrinter(getSVNEnvironment()));
        }
View Full Code Here

    public void run() throws SVNException {
        List targets = getSVNEnvironment().combineTargets(getSVNEnvironment().getTargets(), true);
        for (Iterator ts = targets.iterator(); ts.hasNext();) {
            String targetName = (String) ts.next();
            SVNPath target = new SVNPath(targetName);
            if (target.isURL()) {
                SVNErrorMessage err = SVNErrorMessage.create(SVNErrorCode.WC_BAD_PATH, "Must give local path (not URL) as the target of commit");
                SVNErrorManager.error(err, SVNLogType.CLIENT);
            }
        }
        if (targets.isEmpty()) {
            targets.add(".");
        }
        SVNDepth depth = getSVNEnvironment().getDepth();
        if (depth == SVNDepth.UNKNOWN) {
            depth = SVNDepth.INFINITY;
        }
        SVNCommitClient client = getSVNEnvironment().getClientManager().getCommitClient();
        Collection filesList = new ArrayList();
        for (Iterator ts = targets.iterator(); ts.hasNext();) {
            String targetName = (String) ts.next();
            SVNPath target = new SVNPath(targetName);
            if (target.isFile()) {
                filesList.add(target.getFile());
            } else {
                getSVNEnvironment().getOut().println("Skipped '" + targetName + "'");
            }
        }
        if (filesList.isEmpty()) {
View Full Code Here

TOP

Related Classes of org.tmatesoft.svn.core.internal.wc.SVNPath

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.