001: /*
002: * ====================================================================
003: * Copyright (c) 2004-2008 TMate Software Ltd. All rights reserved.
004: *
005: * This software is licensed as described in the file COPYING, which
006: * you should have received as part of this distribution. The terms
007: * are also available at http://svnkit.com/license.html
008: * If newer versions of this license are posted there, you may use a
009: * newer version instead, at your option.
010: * ====================================================================
011: */
012:
013: package org.tmatesoft.svn.cli.command;
014:
015: import java.io.File;
016: import java.io.InputStream;
017: import java.io.PrintStream;
018:
019: import org.tmatesoft.svn.cli.SVNArgument;
020: import org.tmatesoft.svn.cli.SVNCommand;
021: import org.tmatesoft.svn.core.SVNException;
022: import org.tmatesoft.svn.core.SVNURL;
023: import org.tmatesoft.svn.core.internal.util.SVNFormatUtil;
024: import org.tmatesoft.svn.core.wc.ISVNPropertyHandler;
025: import org.tmatesoft.svn.core.wc.SVNPropertyData;
026: import org.tmatesoft.svn.core.wc.SVNRevision;
027: import org.tmatesoft.svn.core.wc.SVNWCClient;
028:
029: /**
030: * @version 1.1.1
031: * @author TMate Software Ltd.
032: */
033: public class SVNPropdelCommand extends SVNCommand {
034:
035: public void run(InputStream in, PrintStream out, PrintStream err)
036: throws SVNException {
037: run(out, err);
038: }
039:
040: public final void run(final PrintStream out, PrintStream err)
041: throws SVNException {
042: final String propertyName = getCommandLine().getPathAt(0);
043: final boolean recursive = getCommandLine().hasArgument(
044: SVNArgument.RECURSIVE);
045: boolean revProp = getCommandLine().hasArgument(
046: SVNArgument.REV_PROP);
047: boolean force = getCommandLine().hasArgument(SVNArgument.FORCE);
048: int pathIndex = 1;
049:
050: SVNWCClient wcClient = getClientManager().getWCClient();
051: if (revProp) {
052: SVNRevision revision = SVNRevision.UNDEFINED;
053: if (getCommandLine().hasArgument(SVNArgument.REVISION)) {
054: revision = SVNRevision.parse((String) getCommandLine()
055: .getArgumentValue(SVNArgument.REVISION));
056: }
057: if (getCommandLine().hasURLs()) {
058: wcClient.doSetRevisionProperty(SVNURL
059: .parseURIEncoded(getCommandLine().getURL(0)),
060: revision, propertyName, null, force,
061: new ISVNPropertyHandler() {
062: public void handleProperty(File path,
063: SVNPropertyData property)
064: throws SVNException {
065: }
066:
067: public void handleProperty(long revision,
068: SVNPropertyData property)
069: throws SVNException {
070: out
071: .println("Property '"
072: + propertyName
073: + "' deleted on repository revision "
074: + revision);
075: }
076:
077: public void handleProperty(SVNURL url,
078: SVNPropertyData property)
079: throws SVNException {
080: }
081: });
082:
083: } else {
084: File tgt = new File(".");
085: if (getCommandLine().getPathCount() > 1) {
086: tgt = new File(getCommandLine().getPathAt(1));
087: }
088: wcClient.doSetRevisionProperty(tgt, revision,
089: propertyName, null, force,
090: new ISVNPropertyHandler() {
091: public void handleProperty(File path,
092: SVNPropertyData property)
093: throws SVNException {
094: }
095:
096: public void handleProperty(long revision,
097: SVNPropertyData property)
098: throws SVNException {
099: out
100: .println("Property '"
101: + propertyName
102: + "' deleted on repository revision "
103: + revision);
104: }
105:
106: public void handleProperty(SVNURL url,
107: SVNPropertyData property)
108: throws SVNException {
109: }
110: });
111: }
112: } else {
113: for (int i = pathIndex; i < getCommandLine().getPathCount(); i++) {
114: String absolutePath = getCommandLine().getPathAt(i);
115: if (!recursive) {
116: wcClient.doSetProperty(new File(absolutePath),
117: propertyName, null, force, recursive,
118: new ISVNPropertyHandler() {
119: public void handleProperty(File path,
120: SVNPropertyData property)
121: throws SVNException {
122: out.println("Property '"
123: + propertyName
124: + "' deleted on '"
125: + SVNFormatUtil
126: .formatPath(path)
127: + "'");
128: }
129:
130: public void handleProperty(SVNURL url,
131: SVNPropertyData property)
132: throws SVNException {
133: }
134:
135: public void handleProperty(
136: long revision,
137: SVNPropertyData property)
138: throws SVNException {
139: }
140:
141: });
142: } else {
143: final boolean wasSet[] = new boolean[] { false };
144: wcClient.doSetProperty(new File(absolutePath),
145: propertyName, null, force, recursive,
146: new ISVNPropertyHandler() {
147: public void handleProperty(File path,
148: SVNPropertyData property)
149: throws SVNException {
150: wasSet[0] = true;
151: }
152:
153: public void handleProperty(SVNURL url,
154: SVNPropertyData property)
155: throws SVNException {
156: }
157:
158: public void handleProperty(
159: long revision,
160: SVNPropertyData property)
161: throws SVNException {
162: }
163: });
164: if (wasSet[0]) {
165: out.println("Property '" + propertyName
166: + "' deleted (recursively) on '"
167: + absolutePath + "'");
168: }
169: }
170:
171: }
172: }
173: }
174: }
|