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: /*
19: * Portions of this software are based upon public domain software
20: * originally written at the National Center for Supercomputing Applications,
21: * University of Illinois, Urbana-Champaign.
22: */
23:
24: package org.apache.tools.ant.taskdefs.optional.perforce;
25:
26: import org.apache.tools.ant.BuildException;
27:
28: /**
29: * Open file(s) for edit.
30: * P4Change should be used to obtain a new changelist for P4Edit as,
31: * although P4Edit can open files to the default change,
32: * P4Submit cannot yet submit to it.
33: * Example Usage:<br>
34: * <p4edit change="${p4.change}" view="//depot/project/foo.txt" />
35: *
36: * @todo Should call reopen if file is already open in one of our changelists perhaps?
37: *
38: * @ant.task category="scm"
39: */
40:
41: public class P4Edit extends P4Base {
42:
43: // CheckStyle:VisibilityModifier OFF - bc
44: /**
45: * number of the change list to work on
46: */
47: public String change = null;
48:
49: // CheckStyle:VisibilityModifier ON
50:
51: /**
52: * An existing changelist number to assign files to; optional
53: * but strongly recommended.
54: * @param change the change list number
55: */
56: public void setChange(String change) {
57: this .change = change;
58: }
59:
60: /**
61: * Run the p4 edit command
62: * @throws BuildException if there is no view specified
63: */
64: public void execute() throws BuildException {
65: if (change != null) {
66: P4CmdOpts = "-c " + change;
67: }
68: if (P4View == null) {
69: throw new BuildException("No view specified to edit");
70: }
71: execP4Command("-s edit " + P4CmdOpts + " " + P4View,
72: new SimpleP4OutputHandler(this));
73: }
74: }
|