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.internal.util.SVNFormatUtil;
23: import org.tmatesoft.svn.core.wc.SVNRevision;
24: import org.tmatesoft.svn.core.wc.SVNUpdateClient;
25: import org.tmatesoft.svn.core.wc.SVNWCUtil;
26:
27: /**
28: * @version 1.1.1
29: * @author TMate Software Ltd.
30: */
31: public class SVNUpdateCommand extends SVNCommand {
32:
33: public void run(InputStream in, PrintStream out, PrintStream err)
34: throws SVNException {
35: run(out, err);
36: }
37:
38: public void run(final PrintStream out, final PrintStream err)
39: throws SVNException {
40: boolean error = false;
41: for (int i = 0; i < getCommandLine().getPathCount(); i++) {
42: final String path;
43: path = getCommandLine().getPathAt(i);
44:
45: SVNRevision revision = parseRevision(getCommandLine());
46: getClientManager().setEventHandler(
47: new SVNCommandEventProcessor(out, err, false));
48: SVNUpdateClient updater = getClientManager()
49: .getUpdateClient();
50:
51: File file = new File(path).getAbsoluteFile();
52: if (!file.exists()) {
53: File parent = file.getParentFile();
54: if (!parent.exists()
55: || !SVNWCUtil.isVersionedDirectory(parent)) {
56: if (!getCommandLine()
57: .hasArgument(SVNArgument.QUIET)) {
58: println(out, "Skipped '"
59: + SVNFormatUtil.formatPath(file)
60: .replace('/',
61: File.separatorChar)
62: + "'");
63: }
64: continue;
65: }
66: }
67: try {
68: updater.doUpdate(file.getAbsoluteFile(), revision,
69: !getCommandLine().hasArgument(
70: SVNArgument.NON_RECURSIVE));
71: } catch (Throwable th) {
72: updater.getDebugLog().info(th);
73: println(err, th.getMessage());
74: println(err);
75: error = true;
76: }
77: }
78: if (error) {
79: System.exit(1);
80: }
81: }
82: }
|