Package org.tmatesoft.svn.core.wc

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


            resetLog();
        }
    }

    public String[] suggestMergeSources(String path, Revision pegRevision) throws SubversionException {
        SVNDiffClient client = getSVNDiffClient();
        Collection mergeSrcURLs = null;
        try {
            if (isURL(path)) {
                SVNURL url = SVNURL.parseURIEncoded(path);
                mergeSrcURLs = client.doSuggestMergeSources(url,
                        JavaHLObjectFactory.getSVNRevision(pegRevision));
            } else {
                mergeSrcURLs = client.doSuggestMergeSources(new File(path).getAbsoluteFile(),
                    JavaHLObjectFactory.getSVNRevision(pegRevision));
            }
            if (mergeSrcURLs != null) {
                String[] stringURLs = new String[mergeSrcURLs.size()];
                int i = 0;
View Full Code Here


        }
        return null;
    }

    public Mergeinfo getMergeinfo(String path, Revision revision) throws SubversionException {
        SVNDiffClient client = getSVNDiffClient();
        Map mergeInfo = null;
        try {
            if (isURL(path)) {
                mergeInfo = client.doGetMergedMergeInfo(SVNURL.parseURIEncoded(path),
                        JavaHLObjectFactory.getSVNRevision(revision));
            } else {
                mergeInfo = client.doGetMergedMergeInfo(new File(path).getAbsoluteFile(),
                        JavaHLObjectFactory.getSVNRevision(revision));
            }
            return JavaHLObjectFactory.createMergeInfo(mergeInfo);
        } catch (SVNException e) {
            throwException(e);
View Full Code Here

    }

    public void getMergeinfoLog(int kind, String pathOrUrl, Revision pegRevision, String mergeSourceUrl,
                                Revision srcPegRevision, boolean discoverChangedPaths, String[] revprops,
                                final LogMessageCallback callback) throws ClientException {
        SVNDiffClient client = getSVNDiffClient();
        ISVNLogEntryHandler handler = new ISVNLogEntryHandler() {
            public void handleLogEntry(SVNLogEntry logEntry) throws SVNException {
                JavaHLObjectFactory.handleLogMessage(logEntry, callback);
            }
        };
        SVNRevision pegRev = JavaHLObjectFactory.getSVNRevision(pegRevision);
        SVNRevision srcPegRev = JavaHLObjectFactory.getSVNRevision(srcPegRevision);

        try {
            SVNURL mergeSrcURL = SVNURL.parseURIEncoded(mergeSourceUrl);
            if (isURL(pathOrUrl)) {
                SVNURL url = SVNURL.parseURIEncoded(pathOrUrl);
                if (kind == MergeinfoLogKind.eligible) {
                    client.doGetLogEligibleMergeInfo(url, pegRev, mergeSrcURL, srcPegRev, discoverChangedPaths, revprops, handler);
                } else if (kind == MergeinfoLogKind.merged) {
                    client.doGetLogMergedMergeInfo(url, pegRev, mergeSrcURL, srcPegRev, discoverChangedPaths, revprops, handler);
                }
            } else {
                File path = new File(pathOrUrl).getAbsoluteFile();
                if (kind == MergeinfoLogKind.eligible) {
                    client.doGetLogEligibleMergeInfo(path, pegRev, mergeSrcURL, srcPegRev, discoverChangedPaths, revprops, handler);
                } else if (kind == MergeinfoLogKind.merged) {
                    client.doGetLogMergedMergeInfo(path, pegRev, mergeSrcURL, srcPegRev, discoverChangedPaths, revprops, handler);
                }
            }
        } catch (SVNException e) {
            throwException(e);
        } finally {
View Full Code Here

  public void diff(String target1, Revision revision1, String target2,
      Revision revision2, String relativeToDir, String outFileName,
      int depth, String[] changelists, boolean ignoreAncestry,
      boolean noDiffDeleted, boolean force) throws ClientException {
        SVNDiffClient differ = getSVNDiffClient();
        differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted);
        differ.getDiffGenerator().setForcedBinaryDiff(force);
        differ.setOptions(getOptions());
        SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(revision1);
        SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(revision2);
        try {
            differ.getDiffGenerator().setBasePath(getDiffBasePath(relativeToDir));
            OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName));
            if (!isURL(target1) && !isURL(target2)) {
                differ.doDiff(new File(target1).getAbsoluteFile(), rev1,
                        new File(target2).getAbsoluteFile(), rev2,
                        JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out,
                        JavaHLObjectFactory.getChangeListsCollection(changelists));
            } else if (isURL(target1) && isURL(target2)) {
                SVNURL url1 = SVNURL.parseURIEncoded(target1);
                SVNURL url2 = SVNURL.parseURIEncoded(target2);
                differ.doDiff(url1, rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out);
            } else if (!isURL(target1) && isURL(target2)) {
                SVNURL url2 = SVNURL.parseURIEncoded(target2);
                differ.doDiff(new File(target1).getAbsoluteFile(), rev1,
                        url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out,
                        JavaHLObjectFactory.getChangeListsCollection(changelists));
            } else if (isURL(target1) && !isURL(target2)) {
                SVNURL url1 = SVNURL.parseURIEncoded(target1);
                differ.doDiff(url1, rev1, new File(target2).getAbsoluteFile(), rev2,
                        JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out,
                        JavaHLObjectFactory.getChangeListsCollection(changelists));
            }
            SVNFileUtil.closeFile(out);
        } catch (SVNException e) {
View Full Code Here

  public void diff(String target, Revision pegRevision,
      Revision startRevision, Revision endRevision, String relativeToDir,
      String outFileName, int depth, String[] changelists,
      boolean ignoreAncestry, boolean noDiffDeleted, boolean force)
      throws ClientException {
        SVNDiffClient differ = getSVNDiffClient();
        differ.getDiffGenerator().setDiffDeleted(!noDiffDeleted);
        differ.getDiffGenerator().setForcedBinaryDiff(force);
        differ.setOptions(getOptions());
        SVNRevision peg = JavaHLObjectFactory.getSVNRevision(pegRevision);
        SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision);
        SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision);
        try {
            differ.getDiffGenerator().setBasePath(getDiffBasePath(relativeToDir));
            OutputStream out = SVNFileUtil.openFileForWriting(new File(outFileName));
            if (isURL(target)) {
                SVNURL url = SVNURL.parseURIEncoded(target);
                differ.doDiff(url, peg, rev1, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out);
            } else {
                differ.doDiff(new File(target).getAbsoluteFile(), peg, rev1, rev2,
                        JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, out,
                        JavaHLObjectFactory.getChangeListsCollection(changelists));
            }
            SVNFileUtil.closeFile(out);
        } catch (SVNException e) {
View Full Code Here

        }
        return file;
    }

    public void diffSummarize(String target1, Revision revision1, String target2, Revision revision2, int depth, String[] changelists, boolean ignoreAncestry, final DiffSummaryReceiver receiver) throws ClientException {
        SVNDiffClient differ = getSVNDiffClient();
        SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(revision1);
        SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(revision2);
        ISVNDiffStatusHandler handler = new ISVNDiffStatusHandler() {
            public void handleDiffStatus(SVNDiffStatus diffStatus) throws SVNException {
                if (receiver != null) {
                    if (diffStatus != null && (diffStatus.isPropertiesModified() ||
                            (diffStatus.getModificationType() != SVNStatusType.STATUS_NORMAL &&
                             diffStatus.getModificationType() != SVNStatusType.STATUS_NONE))) {
                        receiver.onSummary(JavaHLObjectFactory.createDiffSummary(diffStatus));
                    }
                }
            }
        };
        try {
            if (!isURL(target1) && !isURL(target2)) {
                differ.doDiffStatus(new File(target1).getAbsoluteFile(), rev1,
                        new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth),
                        !ignoreAncestry, handler);
            } else if (isURL(target1) && isURL(target2)) {
                SVNURL url1 = SVNURL.parseURIEncoded(target1);
                SVNURL url2 = SVNURL.parseURIEncoded(target2);
                differ.doDiffStatus(url1, rev1, url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, handler);
            } else if (!isURL(target1) && isURL(target2)) {
                SVNURL url2 = SVNURL.parseURIEncoded(target2);
                differ.doDiffStatus(new File(target1).getAbsoluteFile(), rev1,
                        url2, rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, handler);
            } else if (isURL(target1) && !isURL(target2)) {
                SVNURL url1 = SVNURL.parseURIEncoded(target1);
                differ.doDiffStatus(url1, rev1, new File(target2).getAbsoluteFile(), rev2, JavaHLObjectFactory.getSVNDepth(depth), !ignoreAncestry, handler);
            }
        } catch (SVNException e) {
            throwException(e);
        } finally {
            resetLog();
View Full Code Here

        }
    }

    public void diffSummarize(String target, Revision pegRevision, Revision startRevision, Revision endRevision,
                              int depth, String[] changelists, boolean ignoreAncestry, final DiffSummaryReceiver receiver) throws ClientException {
        SVNDiffClient differ = getSVNDiffClient();
        SVNRevision rev1 = JavaHLObjectFactory.getSVNRevision(startRevision);
        SVNRevision rev2 = JavaHLObjectFactory.getSVNRevision(endRevision);
        SVNRevision pegRev = JavaHLObjectFactory.getSVNRevision(pegRevision);

        ISVNDiffStatusHandler handler = new ISVNDiffStatusHandler() {
            public void handleDiffStatus(SVNDiffStatus diffStatus) throws SVNException {
                if (diffStatus != null && receiver != null) {
                    if (diffStatus.isPropertiesModified() ||
                            (diffStatus.getModificationType() != SVNStatusType.STATUS_NORMAL &&
                             diffStatus.getModificationType() != SVNStatusType.STATUS_NONE)) {
                        receiver.onSummary(JavaHLObjectFactory.createDiffSummary(diffStatus));
                    }
                }
            }
        };
        try {
            if (!isURL(target)) {
                differ.doDiffStatus(new File(target).getAbsoluteFile(),
                        rev1, rev2, pegRev,
                        JavaHLObjectFactory.getSVNDepth(depth),
                        !ignoreAncestry, handler);
            } else {
                SVNURL url = SVNURL.parseURIEncoded(target);
                differ.doDiffStatus(url, rev1, rev2, pegRev,
                        JavaHLObjectFactory.getSVNDepth(depth),
                        !ignoreAncestry, handler);
            }
        } catch (SVNException e) {
            throwException(e);
View Full Code Here

    }

    public void run(final PrintStream out, PrintStream err) throws SVNException {
        myOut = out;
        boolean error = false;
        SVNDiffClient differ = getClientManager().getDiffClient();
        if (getCommandLine().hasArgument(SVNArgument.EXTENSIONS)) {
            SVNDiffOptions diffOptions = new SVNDiffOptions(getCommandLine().hasArgument(SVNArgument.IGNORE_ALL_WS),
                    getCommandLine().hasArgument(SVNArgument.IGNORE_WS_CHANGE),
                    getCommandLine().hasArgument(SVNArgument.IGNORE_EOL_STYLE));
            ISVNDiffGenerator generator = differ.getDiffGenerator();
            if (generator instanceof DefaultSVNDiffGenerator) {
                ((DefaultSVNDiffGenerator) generator).setDiffOptions(diffOptions);
            }
        }
        File userDir = new File(".").getAbsoluteFile().getParentFile();
        differ.getDiffGenerator().setBasePath(userDir);

        boolean useAncestry = getCommandLine().hasArgument(SVNArgument.USE_ANCESTRY);
        boolean recursive = !getCommandLine().hasArgument(SVNArgument.NON_RECURSIVE);
        boolean summarize = getCommandLine().hasArgument(SVNArgument.SUMMARIZE);
       
        differ.getDiffGenerator().setDiffDeleted(!getCommandLine().hasArgument(SVNArgument.NO_DIFF_DELETED));
        differ.getDiffGenerator().setForcedBinaryDiff(getCommandLine().hasArgument(SVNArgument.FORCE));

        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);
                        } else {
                            differ.doDiff(url1, r1, url1, r2, recursive, useAncestry, out);
                        }
                    }
                }
            }
        }
View Full Code Here

     * </p>
     * @return {@link java.util.ArrayList} of {@link org.tmatesoft.svn.core.wc.SVNDiffStatus}
     */
    public ArrayList list() {
        try {
            SVNDiffClient diffClient = new SVNDiffClient(authManager, SVNWCUtil.createDefaultOptions(true));

            ArrayList changes = new ArrayList();

            // adds to changes
            ImplISVNDiffStatusHandler handler = new ImplISVNDiffStatusHandler(changes);

            diffClient.doDiffStatus(this.branchURL, this.startingRevision,
                    this.branchURL, this.endingRevision, true, false, handler);

            return changes;
        } catch (SVNException e) {
            throw new RuntimeException(e);
View Full Code Here

    public void merge(String path1, Revision revision1, String path2, Revision revision2, String localPath, boolean force, boolean recurse) throws ClientException {
        merge(path1, revision1, path2, revision2, localPath, force, recurse, false, false);
    }

    public void merge(String path1, Revision revision1, String path2, Revision revision2, String localPath, boolean force, boolean recurse, boolean ignoreAncestry, boolean dryRun) throws ClientException {
        SVNDiffClient differ = getSVNDiffClient();
        try {
            if(isURL(path1) && isURL(path2)){
                SVNURL url1 = SVNURL.parseURIEncoded(path1);
                SVNURL url2 = SVNURL.parseURIEncoded(path2);
                differ.doMerge(url1, JavaHLObjectFactory.getSVNRevision(revision1), url2,
                        JavaHLObjectFactory.getSVNRevision(revision2), new File(localPath).getAbsoluteFile(),
                        recurse, !ignoreAncestry, force, dryRun);
            } else if (isURL(path1)) {
                SVNURL url1 = SVNURL.parseURIEncoded(path1);
                File file2 = new File(path2).getAbsoluteFile();
                differ.doMerge(url1, JavaHLObjectFactory.getSVNRevision(revision1), file2,
                        JavaHLObjectFactory.getSVNRevision(revision2), new File(localPath).getAbsoluteFile(),
                        recurse, !ignoreAncestry, force, dryRun);
            } else if (isURL(path2)) {
                SVNURL url2 = SVNURL.parseURIEncoded(path2);
                File file1 = new File(path1).getAbsoluteFile();
                differ.doMerge(file1, JavaHLObjectFactory.getSVNRevision(revision1), url2,
                        JavaHLObjectFactory.getSVNRevision(revision2), new File(localPath).getAbsoluteFile(),
                        recurse, !ignoreAncestry, force, dryRun);
            } else {
                File file1 = new File(path1).getAbsoluteFile();
                File file2 = new File(path2).getAbsoluteFile();
                differ.doMerge(file1, JavaHLObjectFactory.getSVNRevision(revision1),
                        file2, JavaHLObjectFactory.getSVNRevision(revision2),
                        new File(localPath).getAbsoluteFile(), recurse, !ignoreAncestry, force, dryRun);
            }
        } catch (SVNException e) {
            throwException(e);
View Full Code Here

TOP

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

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.