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.internal.util.SVNPathUtil;
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 SVNLookCatCommand 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: if (getCommandLine().getPathCount() < 2) {
40: SVNCommand.println(err,
41: "jsvnlook: Missing repository path argument");
42: System.exit(1);
43: }
44: File reposRoot = new File(getCommandLine().getPathAt(0));
45: String path = SVNPathUtil.canonicalizeAbsPath(getCommandLine()
46: .getPathAt(1));
47:
48: SVNRevision revision = SVNRevision.HEAD;
49: SVNLookClient lookClient = getClientManager().getLookClient();
50: if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
51: String transactionName = (String) getCommandLine()
52: .getArgumentValue(SVNArgument.TRANSACTION);
53: lookClient.doCat(reposRoot, path, transactionName, out);
54: return;
55: } else if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
56: revision = SVNRevision.parse((String) getCommandLine()
57: .getArgumentValue(SVNArgument.REVISION));
58: }
59: lookClient.doCat(reposRoot, path, revision, out);
60: }
61:
62: public void run(InputStream in, PrintStream out, PrintStream err)
63: throws SVNException {
64: run(out, err);
65: }
66: }
|