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.SVNPathUtil;
23: import org.tmatesoft.svn.core.wc.SVNStatus;
24: import org.tmatesoft.svn.core.wc.SVNStatusType;
25: import org.tmatesoft.svn.core.wc.SVNWCClient;
26:
27: /**
28: * @version 1.1.1
29: * @author TMate Software Ltd.
30: */
31: public class SVNRevertCommand extends SVNCommand {
32:
33: public void run(InputStream in, PrintStream out, PrintStream err)
34: throws SVNException {
35: run(out, err);
36: }
37:
38: public final void run(final PrintStream out, final PrintStream err)
39: throws SVNException {
40: final boolean recursive = getCommandLine().hasArgument(
41: SVNArgument.RECURSIVE);
42:
43: getClientManager().setEventHandler(
44: new SVNCommandEventProcessor(out, err, false));
45: SVNWCClient wcClient = getClientManager().getWCClient();
46: for (int i = 0; i < getCommandLine().getPathCount(); i++) {
47: final String absolutePath = getCommandLine().getPathAt(i);
48: // hack to make schedule 9 test pass
49: if ("".equals(absolutePath) || ".".equals(absolutePath)) {
50: File path = new File(SVNPathUtil
51: .validateFilePath(absolutePath))
52: .getAbsoluteFile();
53: if (path.isDirectory()) {
54: SVNStatus status = getClientManager()
55: .getStatusClient().doStatus(path, false);
56: if (status.getContentsStatus() == SVNStatusType.STATUS_ADDED) {
57: // we're inside an added directory, skip it.
58: System.err.println("Skipped: " + absolutePath);
59: continue;
60: }
61: }
62: }
63: wcClient.doRevert(new File(absolutePath), recursive);
64: }
65: }
66: }
|