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.SVNCommitInfo;
22: import org.tmatesoft.svn.core.SVNException;
23: import org.tmatesoft.svn.core.SVNURL;
24: import org.tmatesoft.svn.core.wc.SVNCommitClient;
25:
26: /**
27: * @version 1.1.1
28: * @author TMate Software Ltd.
29: */
30: public class SVNImportCommand 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, PrintStream err)
38: throws SVNException {
39: String path = ".";
40: if (getCommandLine().getPathCount() >= 1) {
41: path = getCommandLine().getPathAt(0);
42: }
43: String url = getCommandLine().getURL(0);
44: boolean recursive = !getCommandLine().hasArgument(
45: SVNArgument.NON_RECURSIVE);
46: boolean disableAutoProps = getCommandLine().hasArgument(
47: SVNArgument.NO_AUTO_PROPS);
48: boolean enableAutoProps = getCommandLine().hasArgument(
49: SVNArgument.AUTO_PROPS);
50: String message = (String) getCommandLine().getArgumentValue(
51: SVNArgument.MESSAGE);
52:
53: getClientManager().setEventHandler(
54: new SVNCommandEventProcessor(out, err, false));
55: SVNCommitClient commitClient = getClientManager()
56: .getCommitClient();
57:
58: if (disableAutoProps) {
59: commitClient.getOptions().setUseAutoProperties(false);
60: }
61: if (enableAutoProps) {
62: commitClient.getOptions().setUseAutoProperties(true);
63: }
64:
65: boolean useGlobalIgnores = !getCommandLine().hasArgument(
66: SVNArgument.NO_IGNORE);
67: SVNCommitInfo info = commitClient.doImport(new File(path),
68: SVNURL.parseURIEncoded(url), message, useGlobalIgnores,
69: recursive);
70: if (info != SVNCommitInfo.NULL) {
71: out.println();
72: out.println("Imported revision " + info.getNewRevision()
73: + ".");
74: }
75: }
76:
77: }
|