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 SVNLookAuthorCommand 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: 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: String author = lookClient.doGetAuthor(reposRoot,
47: transactionName);
48: SVNCommand.println(out, author != null ? author : "");
49: return;
50: } else if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
51: revision = SVNRevision.parse((String) getCommandLine()
52: .getArgumentValue(SVNArgument.REVISION));
53: }
54: String author = lookClient.doGetAuthor(reposRoot, revision);
55: SVNCommand.println(out, author != null ? author : "");
56: }
57:
58: public void run(InputStream in, PrintStream out, PrintStream err)
59: throws SVNException {
60: run(out, err);
61: }
62:
63: }
|