Package org.tmatesoft.svn.core.wc

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


        if (getCommandLine().getURLCount() == 2 && !getCommandLine().hasPaths()) {
            // diff url1[@r] url2[@r] (case 3)
            SVNURL url1 = SVNURL.parseURIEncoded(getCommandLine().getURL(0));
            SVNURL url2 = SVNURL.parseURIEncoded(getCommandLine().getURL(1));
            SVNRevision peg1 = getCommandLine().getPegRevision(0);
            SVNRevision peg2 = getCommandLine().getPegRevision(1);
            if (peg1 == SVNRevision.UNDEFINED) {
                peg1 = SVNRevision.HEAD;
            }
            if (peg2 == SVNRevision.UNDEFINED) {
                peg2 = SVNRevision.HEAD;
            }

            if (summarize) {
                differ.doDiffStatus(url1, peg1, url2, peg2, recursive, useAncestry, this);
            } else {
                differ.doDiff(url1, peg1, url2, peg2, recursive, useAncestry, out);
            }
        } else {
            SVNRevision rN = SVNRevision.UNDEFINED;
            SVNRevision rM = SVNRevision.UNDEFINED;
            String revStr = (String) getCommandLine().getArgumentValue(SVNArgument.REVISION);

            if (revStr != null) {
                SVNRevision[] revRange = getStartEndRevisions();
                rN = revRange[0];
                rM = revRange[1];
            } else if (revStr == null && getCommandLine().hasArgument(SVNArgument.CHANGE)) {
                long changeRev = Long.parseLong((String) getCommandLine().getArgumentValue(SVNArgument.CHANGE));
                if (changeRev >= 0) {
                    rM = SVNRevision.create(changeRev);
                    rN = SVNRevision.create(changeRev - 1);
                } else {
                    rN = SVNRevision.create(-changeRev);
                    rM = SVNRevision.create((-changeRev) - 1);
                }
            }
           
            if (getCommandLine().hasArgument(SVNArgument.OLD)) {
                // diff [-rN[:M]] --old=url[@r] [--new=url[@r]] [path...] (case2)
                String oldPath = (String) getCommandLine().getArgumentValue(SVNArgument.OLD);
                String newPath = (String) getCommandLine().getArgumentValue(SVNArgument.NEW);
                if (newPath == null) {
                    newPath = oldPath;
                }
                if (oldPath.startsWith("=")) {
                    oldPath = oldPath.substring(1);
                }
                if (newPath.startsWith("=")) {
                    newPath = newPath.substring(1);
                }
                if (oldPath.indexOf('@') > 0) {
                    rN = SVNRevision.parse(oldPath.substring(oldPath.lastIndexOf('@') + 1));
                    oldPath = oldPath.substring(0, oldPath.lastIndexOf('@'));
                }
                if (newPath.indexOf('@') > 0) {
                    rM = SVNRevision.parse(newPath.substring(newPath.lastIndexOf('@') + 1));
                    newPath = newPath.substring(0, newPath.lastIndexOf('@'));
                }
                if (getCommandLine().getPathCount() == 0) {
                    getCommandLine().setPathAt(0, "");
                }
                if (rN == SVNRevision.UNDEFINED) {
                    rN = getCommandLine().isURL(oldPath) ? SVNRevision.HEAD : SVNRevision.BASE;
                }
                if (rM == SVNRevision.UNDEFINED) {
                    rM = getCommandLine().isURL(newPath) ? SVNRevision.HEAD : SVNRevision.WORKING;
                }
               
                for (int i = 0; i < getCommandLine().getPathCount(); i++) {
                    String p = getCommandLine().getPathAt(i);
                    p = p.replace(File.separatorChar, '/');
                    if (".".equals(p)) {
                        p = "";
                    }
                    String oP = SVNPathUtil.append(oldPath, p);
                    String nP = SVNPathUtil.append(newPath, p);
                    try {
                        if (!getCommandLine().isURL(oP) && getCommandLine().isURL(nP)) {
                            File path1 = new File(oP).getAbsoluteFile();
                            SVNURL url2 = SVNURL.parseURIEncoded(nP);
                            // path:url
                            if (summarize) {
                                differ.doDiffStatus(path1, rN, url2, rM, recursive, useAncestry, this);
                            } else {
                                differ.doDiff(path1, rN, url2, rM, recursive, useAncestry, out);
                            }
                        } else if (getCommandLine().isURL(oP) && !getCommandLine().isURL(nP)) {
                            // url:path
                            File path2 = new File(nP).getAbsoluteFile();
                            SVNURL url1 = SVNURL.parseURIEncoded(oP);
                            if (summarize) {
                                differ.doDiffStatus(url1, rN, path2, rM, recursive, useAncestry, this);
                            } else {
                                differ.doDiff(url1, rN, path2, rM, recursive, useAncestry, out);
                            }
                        } else if (getCommandLine().isURL(oP) && getCommandLine().isURL(nP)) {
                            // url:url
                            SVNURL url1 = SVNURL.parseURIEncoded(oP);
                            SVNURL url2 = SVNURL.parseURIEncoded(nP);
                            if (summarize) {
                                differ.doDiffStatus(url1, rN, url2, rM, recursive, useAncestry, this);
                            } else {
                                differ.doDiff(url1, rN, url2, rM, recursive, useAncestry, out);
                            }
                        } else {
                            // path:path
                            File path1 = new File(oP).getAbsoluteFile();
                            File path2 = new File(nP).getAbsoluteFile();
                            if (summarize) {
                                differ.doDiffStatus(path1, rN, path2, rM, recursive, useAncestry, this);
                            } else {
                                differ.doDiff(path1, rN, path2, rM, recursive, useAncestry, out);
                            }
                        }
                    } catch (SVNException e) {
                        differ.getDebugLog().info(e);
                        error = true;
                        println(err, e.getMessage());
                    }
                }
            } else {
                // diff [-rN[:M]] target[@r] [...] (case1)
                SVNRevision r1 = rN;
                SVNRevision r2 = rM;
                r1 = r1 == SVNRevision.UNDEFINED ? SVNRevision.BASE : r1;
                r2 = r2 == SVNRevision.UNDEFINED ? SVNRevision.WORKING : r2;
                boolean peggedDiff =
                    (r1 != SVNRevision.WORKING && r1 != SVNRevision.BASE && r1 != SVNRevision.PREVIOUS) ||
                    (r2 != SVNRevision.WORKING && r2 != SVNRevision.BASE && r2 != SVNRevision.PREVIOUS);
                peggedDiff &= !summarize;
               
                for(int i = 0; i < getCommandLine().getPathCount(); i++) {
                    String path = getCommandLine().getPathAt(i);
                    File path1 = new File(path).getAbsoluteFile();
                    if (peggedDiff) {
                        SVNRevision peg = getCommandLine().getPathPegRevision(i);
                        peg = peg == SVNRevision.UNDEFINED ? SVNRevision.WORKING : peg;
                        differ.doDiff(path1, peg, r1, r2, recursive, useAncestry, out);
                    } else {
                        if (summarize) {
                            differ.doDiffStatus(path1, r1, path1, r2, recursive, useAncestry, this);
                        } else {
                            differ.doDiff(path1, r1, path1, r2, recursive, useAncestry, out);
                        }
                    }
                }
                r1 = rN;
                r2 = rM;
                peggedDiff = r1 != SVNRevision.WORKING && r1 != SVNRevision.BASE;
                peggedDiff &= !summarize;
                r2 = r2 == SVNRevision.UNDEFINED ? SVNRevision.HEAD : r2;
               
                for(int i = 0; i < getCommandLine().getURLCount(); i++) {
                    String url = getCommandLine().getURL(i);
                    SVNURL url1 = SVNURL.parseURIEncoded(url);
                    if (peggedDiff) {
                        SVNRevision peg = getCommandLine().getPegRevision(i);
                        peg = peg == SVNRevision.UNDEFINED ? SVNRevision.HEAD : peg;
                        differ.doDiff(url1, peg, r1, r2, recursive, useAncestry, out);
                    } else {
                        if (summarize) {
                            differ.doDiffStatus(url1, r1, url1, r2, recursive, useAncestry, this);
View Full Code Here


            path = getCommandLine().getPathAt(0);
        } else {
            path = new File(".", SVNEncodingUtil.uriDecode(SVNPathUtil.tail(url))).getAbsolutePath();
        }

        SVNRevision revision = parseRevision(getCommandLine());
        getClientManager().setEventHandler(new SVNCommandEventProcessor(out, err, true));
        SVNUpdateClient updater = getClientManager().getUpdateClient();
        if (getCommandLine().getURLCount() == 1) {
            SVNRevision pegRevision = getCommandLine().getPegRevision(0);
            updater.doCheckout(SVNURL.parseURIEncoded(url), new File(path), pegRevision, revision, !getCommandLine().hasArgument(SVNArgument.NON_RECURSIVE));
        } else {
            for(int i = 0; i < getCommandLine().getURLCount(); i++) {
                String curl = getCommandLine().getURL(i);
                File dstPath = new File(path, SVNEncodingUtil.uriDecode(SVNPathUtil.tail(curl)));
                SVNRevision pegRevision = getCommandLine().getPegRevision(i);
                updater.doCheckout(SVNURL.parseURIEncoded(url), dstPath, pegRevision, revision, !getCommandLine().hasArgument(SVNArgument.NON_RECURSIVE));
            }
        }
  }
View Full Code Here

        }

        getClientManager().setEventHandler(new SVNCommandEventProcessor(out, err, false));
        SVNCopyClient updater = getClientManager().getCopyClient();
        boolean force = getCommandLine().hasArgument(SVNArgument.FORCE);
        SVNRevision srcRevision = SVNRevision.parse((String) getCommandLine().getArgumentValue(SVNArgument.REVISION));
        updater.doCopy(new File(absoluteSrcPath), srcRevision, new File(absoluteDstPath), force, false);
    }
View Full Code Here

        if (getCommandLine().getURLCount() != 2) {
            SVNErrorMessage msg = SVNErrorMessage.create(SVNErrorCode.CL_INSUFFICIENT_ARGS, "Please enter SRC and DST URLs");
            throw new SVNException(msg);
        }
        String srcURL = getCommandLine().getURL(0);
        SVNRevision srcRevision = SVNRevision.parse((String) getCommandLine().getArgumentValue(SVNArgument.REVISION));
        String dstURL = getCommandLine().getURL(1);

        if (matchTabsInURL(srcURL, err) || matchTabsInURL(dstURL, err)) {
            return;
        }
View Full Code Here

    }

    private void runRemoteToLocal(final PrintStream out, PrintStream err) throws SVNException {
        final String srcURL = getCommandLine().getURL(0);
        String dstPath = getCommandLine().getPathAt(0);
        SVNRevision revision = SVNRevision.parse((String) getCommandLine().getArgumentValue(SVNArgument.REVISION));
        if (revision == null || !revision.isValid()) {
            revision = SVNRevision.HEAD;
        }
        getClientManager().setEventHandler(new SVNCommandEventProcessor(out, err, false));
        SVNCopyClient updater = getClientManager().getCopyClient();
        updater.doCopy(SVNURL.parseURIEncoded(srcURL), revision, new File(dstPath));
View Full Code Here

        String srcPath = getCommandLine().getPathAt(0);
        if (matchTabsInPath(srcPath, err) || matchTabsInURL(dstURL, err)) {
            return;
        }
        String message = getCommitMessage();
        SVNRevision revision = SVNRevision.parse((String) getCommandLine().getArgumentValue(SVNArgument.REVISION));
        if (revision == null || !revision.isValid()) {
            revision = SVNRevision.WORKING;
        }
        getClientManager().setEventHandler(new SVNCommandEventProcessor(out, err, false));
        SVNCopyClient updater = getClientManager().getCopyClient();

        SVNRevision srcRevision = SVNRevision.parse((String) getCommandLine().getArgumentValue(SVNArgument.REVISION));
        updater.setEventHandler(null);
        SVNCommitInfo info = updater.doCopy(new File(srcPath), srcRevision, SVNURL.parseURIEncoded(dstURL), message);
        if (info != SVNCommitInfo.NULL) {
            out.println();
            out.println("Committed revision " + info.getNewRevision() + ".");
View Full Code Here

        if (!getCommandLine().hasPaths()) {
            SVNCommand.println(err, "jsvnlook: Repository argument required");
            System.exit(1);
        }
        File reposRoot = new File(getCommandLine().getPathAt(0))
        SVNRevision revision = SVNRevision.HEAD;
        SVNLookClient lookClient = getClientManager().getLookClient();
       
        if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
            String transactionName = (String) getCommandLine().getArgumentValue(SVNArgument.TRANSACTION);
            String log = lookClient.doGetLog(reposRoot, transactionName);
View Full Code Here

            System.exit(1);
        }
        File reposRoot = new File(getCommandLine().getPathAt(0))
       
        SVNRevision[] revRange = getStartEndRevisions();
        SVNRevision rStart = revRange[0];
        SVNRevision rEnd = revRange[1];
       
        myIsQuiet = getCommandLine().hasArgument(SVNArgument.QUIET);
        myOut = err;

        SVNAdminClient adminClient = getClientManager().getAdminClient();
View Full Code Here

            SVNCommand.println(err, "jsvnlook: Repository argument required");
            System.exit(1);
        }
        File reposRoot = new File(getCommandLine().getPathAt(0))
        myOut = out;
        SVNRevision revision = SVNRevision.HEAD;
        SVNLookClient lookClient = getClientManager().getLookClient();
        if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
            String transactionName = (String) getCommandLine().getArgumentValue(SVNArgument.TRANSACTION);
            lookClient.doGetChangedDirectories(reposRoot, transactionName, this);
            return;
View Full Code Here

        return count;
    }

    protected SVNRevision[] getStartEndRevisions() {
        String revStr = (String) getCommandLine().getArgumentValue(SVNArgument.REVISION);
        SVNRevision startRevision = SVNRevision.UNDEFINED;
        SVNRevision endRevision = SVNRevision.UNDEFINED;
        if (revStr != null && revStr.indexOf("}:{") > 0) {
            startRevision = SVNRevision.parse(revStr.substring(0, revStr.indexOf("}:{") + 1));
            endRevision = SVNRevision.parse(revStr.substring(revStr.indexOf("}:{") +2));
        } else if (revStr != null && revStr.indexOf(':') > 0 && revStr.indexOf('{') < 0 && revStr.indexOf('}') < 0 ) {
            startRevision = SVNRevision.parse(revStr.substring(0, revStr.indexOf(':')));
View Full Code Here

TOP

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

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.