source: other-projects/trunk/gs3-release-maker/apache-ant-1.6.5/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Integrate.java@ 14627

Last change on this file since 14627 was 14627, checked in by oranfry, 17 years ago

initial import of the gs3-release-maker

File size: 9.2 KB
Line 
1/*
2 * Copyright 2003-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
23package org.apache.tools.ant.taskdefs.optional.perforce;
24
25import org.apache.tools.ant.BuildException;
26
27/**
28 * Integrate file(s).
29 * P4Change should be used to obtain a new changelist for P4Integrate,
30 * although P4Integrate can open files to the default change,
31 * P4Submit cannot yet submit to it.
32 * Example Usage:<br>
33 * &lt;p4integrate change="${p4.change}"
34 * fromfile="//depot/project/dev/foo.txt" tofile="//depot/project/main/foo.txt" /&gt;
35 *
36 *
37 * @ant.task category="scm"
38 */
39
40public class P4Integrate extends P4Base {
41
42 private String change = null;
43 private String fromfile = null;
44 private String tofile = null;
45 private String branch = null;
46 private boolean restoredeletedrevisions = false;
47 private boolean forceintegrate = false;
48 private boolean leavetargetrevision = false;
49 private boolean enablebaselessmerges = false;
50 private boolean simulationmode = false;
51 private boolean reversebranchmappings = false;
52 private boolean propagatesourcefiletype = false;
53 private boolean nocopynewtargetfiles = false;
54
55 /**
56 * get the changelist number
57 *
58 * @return the changelist number set for this task
59 */
60 public String getChange() {
61 return change;
62 }
63
64 /**
65 * set the changelist number for the operation
66 *
67 * @param change An existing changelist number to assign files to; optional
68 * but strongly recommended.
69 */
70 public void setChange(String change) {
71 this.change = change;
72 }
73
74 /**
75 * get the from file specification
76 *
77 * @return the from file specification
78 */
79 public String getFromfile() {
80 return fromfile;
81 }
82
83 /**
84 * sets the from file specification
85 *
86 * @param fromf the from file specification
87 */
88 public void setFromfile(String fromf) {
89 this.fromfile = fromf;
90 }
91
92 /**
93 * get the to file specification
94 *
95 * @return the to file specification
96 */
97 public String getTofile() {
98 return tofile;
99 }
100
101 /**
102 * sets the to file specification
103 *
104 * @param tof the to file specification
105 */
106 public void setTofile(String tof) {
107 this.tofile = tof;
108 }
109
110 /**
111 * get the branch
112 *
113 * @return the name of the branch
114 */
115 public String getBranch() {
116 return branch;
117 }
118
119 /**
120 * sets the branch
121 *
122 * @param br the name of the branch to use
123 */
124 public void setBranch(String br) {
125 this.branch = br;
126 }
127
128 /**
129 * gets the restoredeletedrevisions flag
130 *
131 * @return restore deleted revisions
132 */
133 public boolean isRestoreDeletedRevisions() {
134 return restoredeletedrevisions;
135 }
136
137 /**
138 * sets the restoredeletedrevisions flag
139 *
140 * @param setrest value chosen for restoredeletedrevisions
141 */
142 public void setRestoreDeletedRevisions(boolean setrest) {
143 this.restoredeletedrevisions = setrest;
144 }
145
146 /**
147 * gets the forceintegrate flag
148 *
149 * @return restore deleted revisions
150 */
151 public boolean isForceIntegrate() {
152 return forceintegrate;
153 }
154
155 /**
156 * sets the forceintegrate flag
157 *
158 * @param setrest value chosen for forceintegrate
159 */
160 public void setForceIntegrate(boolean setrest) {
161 this.forceintegrate = setrest;
162 }
163
164 /**
165 * gets the leavetargetrevision flag
166 *
167 * @return flag indicating if the target revision should be preserved
168 */
169 public boolean isLeaveTargetRevision() {
170 return leavetargetrevision;
171 }
172
173 /**
174 * sets the leavetargetrevision flag
175 *
176 * @param setrest value chosen for leavetargetrevision
177 */
178 public void setLeaveTargetRevision(boolean setrest) {
179 this.leavetargetrevision = setrest;
180 }
181
182 /**
183 * gets the enablebaselessmerges flag
184 *
185 * @return boolean indicating if baseless merges are desired
186 */
187 public boolean isEnableBaselessMerges() {
188 return enablebaselessmerges;
189 }
190
191 /**
192 * sets the enablebaselessmerges flag
193 *
194 * @param setrest value chosen for enablebaselessmerges
195 */
196 public void setEnableBaselessMerges(boolean setrest) {
197 this.enablebaselessmerges = setrest;
198 }
199
200 /**
201 * gets the simulationmode flag
202 *
203 * @return simulation mode flag
204 */
205 public boolean isSimulationMode() {
206 return simulationmode;
207 }
208
209 /**
210 * sets the simulationmode flag
211 *
212 * @param setrest value chosen for simulationmode
213 */
214 public void setSimulationMode(boolean setrest) {
215 this.simulationmode = setrest;
216 }
217 /**
218 * returns the flag indicating if reverse branch mappings are sought
219 *
220 * @return reversebranchmappings flag
221 */
222 public boolean isReversebranchmappings() {
223 return reversebranchmappings;
224 }
225
226 /**
227 * sets the reversebranchmappings flag
228 *
229 * @param reversebranchmappings flag indicating if reverse branch mappings are sought
230 */
231 public void setReversebranchmappings(boolean reversebranchmappings) {
232 this.reversebranchmappings = reversebranchmappings;
233 }
234 /**
235 * returns flag indicating if propagation of source file type is sought
236 *
237 * @return flag set to true if you want to propagate source file type for existing target files
238 */
239 public boolean isPropagatesourcefiletype() {
240 return propagatesourcefiletype;
241 }
242 /**
243 * sets flag indicating if one wants to propagate the source file type
244 *
245 * @param propagatesourcefiletype
246 * set it to true if you want to change the type of existing target files
247 * according to type of source file.
248 */
249 public void setPropagatesourcefiletype(boolean propagatesourcefiletype) {
250 this.propagatesourcefiletype = propagatesourcefiletype;
251 }
252 /**
253 * indicates intention to suppress the copying on the local hard disk of new target files.
254 *
255 * @return indicates intention to suppress the copying
256 * on the local hard disk of new target files.
257 */
258 public boolean isNocopynewtargetfiles() {
259 return nocopynewtargetfiles;
260 }
261
262 /**
263 * sets nocopynewtargetfiles flag
264 *
265 * @param nocopynewtargetfiles set it to true to gain speed in integration by not copying on
266 * the local Perforce client new target files
267 */
268 public void setNocopynewtargetfiles(boolean nocopynewtargetfiles) {
269 this.nocopynewtargetfiles = nocopynewtargetfiles;
270 }
271
272 /**
273 * execute the p4 integrate
274 * @throws BuildException if there are missing parameters
275 */
276 public void execute() throws BuildException {
277 if (change != null) {
278 P4CmdOpts = "-c " + change;
279 }
280 if (this.forceintegrate) {
281 P4CmdOpts = P4CmdOpts + " -f";
282 }
283 if (this.restoredeletedrevisions) {
284 P4CmdOpts = P4CmdOpts + " -d";
285 }
286 if (this.leavetargetrevision) {
287 P4CmdOpts = P4CmdOpts + " -h";
288 }
289 if (this.enablebaselessmerges) {
290 P4CmdOpts = P4CmdOpts + " -i";
291 }
292 if (this.simulationmode) {
293 P4CmdOpts = P4CmdOpts + " -n";
294 }
295 if (this.reversebranchmappings) {
296 P4CmdOpts = P4CmdOpts + " -r";
297 }
298 if (this.propagatesourcefiletype) {
299 P4CmdOpts = P4CmdOpts + " -t";
300 }
301 if (this.nocopynewtargetfiles) {
302 P4CmdOpts = P4CmdOpts + "-v";
303 }
304 String command;
305 if (branch == null && fromfile != null && tofile != null) {
306 command = P4CmdOpts + " " + fromfile + " " + tofile;
307 } else if (branch != null && fromfile == null && tofile != null) {
308 command = P4CmdOpts + " -b " + branch + " " + tofile;
309 } else if (branch != null && fromfile != null) {
310 command = P4CmdOpts + " -b " + branch + " -s " + fromfile + " " + tofile;
311 } else {
312 throw new BuildException("you need to specify fromfile and tofile, "
313 + "or branch and tofile, or branch and fromfile, or branch and fromfile and tofile ");
314 }
315 execP4Command("-s integrate " + command, new SimpleP4OutputHandler(this));
316 }
317}
Note: See TracBrowser for help on using the repository browser.