1 | /*
|
---|
2 | * Copyright 2000-2004 The Apache Software Foundation
|
---|
3 | *
|
---|
4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
5 | * you may not use this file except in compliance with the License.
|
---|
6 | * You may obtain a copy of the License at
|
---|
7 | *
|
---|
8 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
9 | *
|
---|
10 | * Unless required by applicable law or agreed to in writing, software
|
---|
11 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
13 | * See the License for the specific language governing permissions and
|
---|
14 | * limitations under the License.
|
---|
15 | *
|
---|
16 | */
|
---|
17 | /*
|
---|
18 | * Portions of this software are based upon public domain software
|
---|
19 | * originally written at the National Center for Supercomputing Applications,
|
---|
20 | * University of Illinois, Urbana-Champaign.
|
---|
21 | */
|
---|
22 |
|
---|
23 | package org.apache.tools.ant.taskdefs.optional.perforce;
|
---|
24 |
|
---|
25 | import org.apache.tools.ant.BuildException;
|
---|
26 |
|
---|
27 | /**
|
---|
28 | * Open file(s) for edit.
|
---|
29 | * P4Change should be used to obtain a new changelist for P4Edit as,
|
---|
30 | * although P4Edit can open files to the default change,
|
---|
31 | * P4Submit cannot yet submit to it.
|
---|
32 | * Example Usage:<br>
|
---|
33 | * <p4edit change="${p4.change}" view="//depot/project/foo.txt" />
|
---|
34 | *
|
---|
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 | /**
|
---|
44 | * number of the change list to work on
|
---|
45 | */
|
---|
46 | public String change = null;
|
---|
47 |
|
---|
48 | /**
|
---|
49 | * An existing changelist number to assign files to; optional
|
---|
50 | * but strongly recommended.
|
---|
51 | * @param change the change list number
|
---|
52 | */
|
---|
53 | public void setChange(String change) {
|
---|
54 | this.change = change;
|
---|
55 | }
|
---|
56 |
|
---|
57 | /**
|
---|
58 | * Run the p4 edit command
|
---|
59 | * @throws BuildException if there is no view specified
|
---|
60 | */
|
---|
61 | public void execute() throws BuildException {
|
---|
62 | if (change != null) {
|
---|
63 | P4CmdOpts = "-c " + change;
|
---|
64 | }
|
---|
65 | if (P4View == null) {
|
---|
66 | throw new BuildException("No view specified to edit");
|
---|
67 | }
|
---|
68 | execP4Command("-s edit " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
|
---|
69 | }
|
---|
70 | }
|
---|