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.SVNLogEntry;
22: import org.tmatesoft.svn.core.wc.SVNRevision;
23: import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
24:
25: /**
26: * @version 1.1.1
27: * @author TMate Software Ltd.
28: * @since 1.1.1
29: */
30: public class SVNLookInfoCommand extends SVNCommand {
31:
32: public void run(PrintStream out, PrintStream err)
33: throws SVNException {
34: if (!getCommandLine().hasPaths()) {
35: SVNCommand.println(err,
36: "jsvnlook: Repository argument required");
37: System.exit(1);
38: }
39: File reposRoot = new File(getCommandLine().getPathAt(0));
40: SVNRevision revision = SVNRevision.HEAD;
41: SVNLookClient lookClient = getClientManager().getLookClient();
42:
43: if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
44: String transactionName = (String) getCommandLine()
45: .getArgumentValue(SVNArgument.TRANSACTION);
46: SVNLogEntry entry = lookClient.doGetInfo(reposRoot,
47: transactionName);
48: printInfo(entry, out);
49: return;
50: } else if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
51: revision = SVNRevision.parse((String) getCommandLine()
52: .getArgumentValue(SVNArgument.REVISION));
53: }
54:
55: SVNLogEntry entry = lookClient.doGetInfo(reposRoot, revision);
56: printInfo(entry, out);
57: }
58:
59: public void run(InputStream in, PrintStream out, PrintStream err)
60: throws SVNException {
61: run(out, err);
62: }
63:
64: private void printInfo(SVNLogEntry entry, PrintStream out) {
65: String author = entry.getAuthor() != null ? entry.getAuthor()
66: : "";
67: String date = entry.getDate() != null ? SVNLookDateCommand
68: .formatDate(entry.getDate()) : "";
69: String log = entry.getMessage() != null ? entry.getMessage()
70: : "";
71: SVNCommand.println(out, author);
72: SVNCommand.println(out, date);
73: if (log == null || log.length() == 0) {
74: SVNCommand.println(out, "0");
75: } else {
76: SVNCommand.println(out, String.valueOf(log.length()));
77: SVNCommand.println(out, log);
78: }
79: }
80: }
|