01: /*
02: * ====================================================================
03: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
04: *
05: * This software is licensed as described in the file COPYING, which
06: * you should have received as part of this distribution. The terms
07: * are also available at http://svnkit.com/license.html.
08: * If newer versions of this license are posted there, you may use a
09: * newer version instead, at your option.
10: * ====================================================================
11: */
12: package org.tmatesoft.svn.cli.command;
13:
14: import java.io.File;
15: import java.io.InputStream;
16: import java.io.PrintStream;
17:
18: import org.tmatesoft.svn.cli.SVNArgument;
19: import org.tmatesoft.svn.cli.SVNCommand;
20: import org.tmatesoft.svn.core.SVNException;
21: import org.tmatesoft.svn.core.wc.SVNRevision;
22: import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
23:
24: /**
25: * @version 1.1.1
26: * @author TMate Software Ltd.
27: * @since 1.1.1
28: */
29: public class SVNLookDiffCommand extends SVNCommand {
30:
31: public void run(PrintStream out, PrintStream err)
32: throws SVNException {
33: if (!getCommandLine().hasPaths()) {
34: SVNCommand.println(err,
35: "jsvnlook: Repository argument required");
36: System.exit(1);
37: }
38: File reposRoot = new File(getCommandLine().getPathAt(0));
39:
40: boolean diffAdded = !getCommandLine().hasArgument(
41: SVNArgument.NO_DIFF_ADDED);
42: boolean diffDeleted = !getCommandLine().hasArgument(
43: SVNArgument.NO_DIFF_DELETED);
44: boolean diffCopyFrom = !getCommandLine().hasArgument(
45: SVNArgument.DIFF_COPY_FROM);
46:
47: SVNRevision revision = SVNRevision.HEAD;
48: SVNLookClient lookClient = getClientManager().getLookClient();
49: if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
50: String transactionName = (String) getCommandLine()
51: .getArgumentValue(SVNArgument.TRANSACTION);
52: lookClient.doGetDiff(reposRoot, transactionName,
53: diffDeleted, diffAdded, diffCopyFrom, out);
54: return;
55: } else if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
56: revision = SVNRevision.parse((String) getCommandLine()
57: .getArgumentValue(SVNArgument.REVISION));
58: }
59: lookClient.doGetDiff(reposRoot, revision, diffDeleted,
60: diffAdded, diffCopyFrom, out);
61: }
62:
63: public void run(InputStream in, PrintStream out, PrintStream err)
64: throws SVNException {
65: run(out, err);
66: }
67:
68: }
|