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:
13: package org.tmatesoft.svn.cli.command;
14:
15: import java.io.File;
16: import java.io.InputStream;
17: import java.io.PrintStream;
18:
19: import org.tmatesoft.svn.cli.SVNArgument;
20: import org.tmatesoft.svn.cli.SVNCommand;
21: import org.tmatesoft.svn.core.SVNException;
22: import org.tmatesoft.svn.core.SVNURL;
23: import org.tmatesoft.svn.core.wc.SVNRevision;
24: import org.tmatesoft.svn.core.wc.SVNUpdateClient;
25:
26: /**
27: * @version 1.1.1
28: * @author TMate Software Ltd.
29: */
30: public class SVNExportCommand extends SVNCommand {
31:
32: public void run(InputStream in, PrintStream out, PrintStream err)
33: throws SVNException {
34: run(out, err);
35: }
36:
37: public void run(final PrintStream out, final PrintStream err)
38: throws SVNException {
39: String path = getCommandLine().getPathAt(0);
40: String url = null;
41: if (getCommandLine().hasURLs()) {
42: url = getCommandLine().getURL(0);
43: }
44: String srcPath = null;
45: if (url == null) {
46: srcPath = getCommandLine().getPathAt(0);
47: path = getCommandLine().getPathAt(1);
48: }
49:
50: SVNRevision revision = parseRevision(getCommandLine());
51: getClientManager().setEventHandler(
52: new SVNCommandEventProcessor(out, err, false, true));
53: SVNUpdateClient updater = getClientManager().getUpdateClient();
54: String eol = (String) getCommandLine().getArgumentValue(
55: SVNArgument.EOL_STYLE);
56: if (url != null) {
57: if (revision != SVNRevision.HEAD
58: && revision.getDate() == null
59: && revision.getNumber() < 0) {
60: revision = SVNRevision.HEAD;
61: }
62: updater.doExport(SVNURL.parseURIEncoded(url),
63: new File(path).getAbsoluteFile(), revision,
64: revision, eol, getCommandLine().hasArgument(
65: SVNArgument.FORCE), !getCommandLine()
66: .hasArgument(SVNArgument.NON_RECURSIVE));
67: } else if (srcPath != null) {
68: if (revision == SVNRevision.UNDEFINED) {
69: revision = SVNRevision.WORKING;
70: }
71: updater.doExport(new File(srcPath).getAbsoluteFile(),
72: new File(path).getAbsoluteFile(),
73: SVNRevision.UNDEFINED, revision, eol,
74: getCommandLine().hasArgument(SVNArgument.FORCE),
75: !getCommandLine().hasArgument(
76: SVNArgument.NON_RECURSIVE));
77: }
78: }
79: }
|