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.SVNCancelException;
21: import org.tmatesoft.svn.core.SVNException;
22: import org.tmatesoft.svn.core.wc.SVNEvent;
23: import org.tmatesoft.svn.core.wc.SVNRevision;
24: import org.tmatesoft.svn.core.wc.admin.ISVNAdminEventHandler;
25: import org.tmatesoft.svn.core.wc.admin.SVNAdminClient;
26: import org.tmatesoft.svn.core.wc.admin.SVNAdminEvent;
27: import org.tmatesoft.svn.core.wc.admin.SVNAdminEventAction;
28:
29: /**
30: * @version 1.1.1
31: * @author TMate Software Ltd.
32: * @since 1.1.1
33: */
34: public class SVNAdminDumpCommand extends SVNCommand implements
35: ISVNAdminEventHandler {
36: private boolean myIsQuiet;
37: private PrintStream myOut;
38:
39: public void run(InputStream in, PrintStream out, PrintStream err)
40: throws SVNException {
41: run(out, err);
42: }
43:
44: public void run(PrintStream out, PrintStream err)
45: throws SVNException {
46: if (!getCommandLine().hasPaths()) {
47: SVNCommand.println(out,
48: "jsvnadmin: Repository argument required");
49: System.exit(1);
50: }
51: File reposRoot = new File(getCommandLine().getPathAt(0));
52:
53: SVNRevision[] revRange = getStartEndRevisions();
54: SVNRevision rStart = revRange[0];
55: SVNRevision rEnd = revRange[1];
56:
57: boolean isIncremental = getCommandLine().hasArgument(
58: SVNArgument.INCREMENTAL);
59: boolean useDeltas = getCommandLine().hasArgument(
60: SVNArgument.DELTAS);
61:
62: myIsQuiet = getCommandLine().hasArgument(SVNArgument.QUIET);
63: myOut = err;
64:
65: SVNAdminClient adminClient = getClientManager()
66: .getAdminClient();
67: adminClient.setEventHandler(this );
68: adminClient.doDump(reposRoot, out, rStart, rEnd, isIncremental,
69: useDeltas);
70: }
71:
72: public void handleAdminEvent(SVNAdminEvent event, double progress)
73: throws SVNException {
74: if (!myIsQuiet
75: && event != null
76: && event.getAction() == SVNAdminEventAction.REVISION_DUMPED) {
77: myOut.println(event.getMessage());
78: }
79: }
80:
81: public void handleEvent(SVNEvent event, double progress)
82: throws SVNException {
83: }
84:
85: public void checkCancelled() throws SVNCancelException {
86: }
87: }
|