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.ISVNHistoryHandler;
24: import org.tmatesoft.svn.core.wc.admin.SVNAdminPath;
25: import org.tmatesoft.svn.core.wc.admin.SVNLookClient;
26:
27: /**
28: * @version 1.1.1
29: * @author TMate Software Ltd.
30: * @since 1.1.1
31: */
32: public class SVNLookHistoryCommand extends SVNCommand implements
33: ISVNHistoryHandler {
34: private PrintStream myOut;
35: private boolean myIsIncludeIDs;
36:
37: public void run(PrintStream out, PrintStream err)
38: throws SVNException {
39: if (!getCommandLine().hasPaths()) {
40: SVNCommand.println(err,
41: "jsvnlook: Repository argument required");
42: System.exit(1);
43: }
44: if (getCommandLine().hasArgument(SVNArgument.TRANSACTION)) {
45: SVNCommand
46: .println(err,
47: "Subcommand 'history' doesn't accept option '-t [--transaction] arg'");
48: System.exit(1);
49: }
50:
51: myOut = out;
52: File reposRoot = new File(getCommandLine().getPathAt(0));
53: String path = null;
54: if (getCommandLine().getPathCount() > 1) {
55: path = SVNPathUtil.canonicalizeAbsPath(getCommandLine()
56: .getPathAt(1));
57: }
58: myIsIncludeIDs = getCommandLine().hasArgument(
59: SVNArgument.SHOW_IDS);
60:
61: SVNRevision revision = SVNRevision.HEAD;
62: SVNLookClient lookClient = getClientManager().getLookClient();
63: if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
64: revision = SVNRevision.parse((String) getCommandLine()
65: .getArgumentValue(SVNArgument.REVISION));
66: }
67: if (myIsIncludeIDs) {
68: SVNCommand.println(myOut, "REVISION PATH <ID>");
69: SVNCommand.println(myOut, "-------- ---------");
70: } else {
71: SVNCommand.println(myOut, "REVISION PATH");
72: SVNCommand.println(myOut, "-------- ----");
73: }
74: lookClient.doGetHistory(reposRoot, path, revision,
75: myIsIncludeIDs, this );
76: }
77:
78: public void run(InputStream in, PrintStream out, PrintStream err)
79: throws SVNException {
80: run(out, err);
81: }
82:
83: public void handlePath(SVNAdminPath path) throws SVNException {
84: if (path != null) {
85: if (myIsIncludeIDs) {
86: SVNCommand.println(myOut, path.getRevision() + " "
87: + path.getPath() + " <" + path.getNodeID()
88: + ">");
89: } else {
90: SVNCommand.println(myOut, path.getRevision() + " "
91: + path.getPath());
92: }
93: }
94: }
95:
96: }
|