01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.tools.ant.taskdefs.optional.perforce;
19:
20: import org.apache.tools.ant.BuildException;
21:
22: /** Checkout files for deletion.
23: *
24: * Example Usage:<br>
25: * <p4delete change="${p4.change}" view="//depot/project/foo.txt" /><br>
26: *
27: * Simple re-write of P4Edit changing 'edit' to 'delete'.<br>
28: *
29: * @todo What to do if file is already open in one of our changelists perhaps
30: * (See also {@link P4Edit P4Edit})?<br>
31: *
32: * @ant.task category="scm"
33: */
34: public class P4Delete extends P4Base {
35:
36: // CheckStyle:VisibilityModifier OFF - bc
37: /**
38: * number of the change list to work on
39: */
40: public String change = null;
41:
42: // CheckStyle:VisibilityModifier ON
43:
44: /**
45: * An existing changelist number for the deletion; optional
46: * but strongly recommended.
47: * @param change the number of a change list
48: */
49: public void setChange(String change) {
50: this .change = change;
51: }
52:
53: /**
54: * executes the p4 delete task
55: * @throws BuildException if there is no view specified
56: */
57: public void execute() throws BuildException {
58: if (change != null) {
59: P4CmdOpts = "-c " + change;
60: }
61: if (P4View == null) {
62: throw new BuildException("No view specified to delete");
63: }
64: execP4Command("-s delete " + P4CmdOpts + " " + P4View,
65: new SimpleP4OutputHandler(this));
66: }
67: }
|