conor 01/05/17 03:30:53
Modified: docs/manual/OptionalTasks perforce.html
src/main/org/apache/tools/ant/taskdefs/optional/perforce
P4Label.java
Log:
This patch enables a newly created Perforce label to be locked
Submitted by: Les Hughes <[EMAIL PROTECTED]>
Revision Changes Path
1.7 +6 -0 jakarta-ant/docs/manual/OptionalTasks/perforce.html
Index: perforce.html
===================================================================
RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/perforce.html,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- perforce.html 2001/05/03 07:10:16 1.6
+++ perforce.html 2001/05/17 10:30:42 1.7
@@ -325,6 +325,11 @@
<td valign="top">Label Description</td>
<td valign="top" align="center">No</td>
</tr>
+ <tr>
+ <td valign="top">lock</td>
+ <td valign="top">Lock the label once created.</td>
+ <td valign="top" align="center">No</td>
+ </tr>
</table>
@@ -333,6 +338,7 @@
<p4label
name="NightlyBuild:${DSTAMP}:${TSTAMP}"
desc="Auto Nightly Build"
+ lock="locked"
/>
</pre>
<hr>
1.3 +51 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java
Index: P4Label.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- P4Label.java 2001/01/12 15:28:35 1.2
+++ P4Label.java 2001/05/17 10:30:49 1.3
@@ -79,6 +79,7 @@
protected String name;
protected String desc;
+ protected String lock;
public void setName(String name) {
this.name = name;
@@ -87,7 +88,11 @@
public void setDesc(String desc) {
this.desc = desc;
}
-
+
+ public void setLock(String lock) {
+ this.lock = lock;
+ }
+
public void execute() throws BuildException {
log("P4Label exec:",Project.MSG_INFO);
@@ -101,7 +106,10 @@
desc = "AntLabel";
}
-
+ if(lock != null && !lock.equalsIgnoreCase("locked")) {
+ log("lock attribute invalid - ignoring",Project.MSG_WARN);
+ }
+
if(name == null || name.length() < 1) {
SimpleDateFormat formatter = new SimpleDateFormat
("yyyy.MM.dd-hh:mm");
Date now = new Date();
@@ -110,6 +118,7 @@
}
+ //We have to create a unlocked label first
String newLabel =
"Label: "+name+"\n"+
"Description: "+desc+"\n"+
@@ -134,6 +143,46 @@
log("Created Label "+name+" ("+desc+")", Project.MSG_INFO);
+
+ //Now lock if required
+ if (lock != null && lock.equalsIgnoreCase("locked")) {
+
+ log("Modifying lock status to 'locked'",Project.MSG_INFO);
+
+ final StringBuffer labelSpec = new StringBuffer();
+
+ //Read back the label spec from perforce,
+ //Replace Options
+ //Submit back to Perforce
+
+ handler = new P4HandlerAdapter() {
+ public void process(String line) {
+ log(line, Project.MSG_VERBOSE);
+
+ if(util.match("/^Options:/",line)) {
+ line = "Options: "+lock;
+ }
+
+ labelSpec.append(line+"\n");
+ }
+ };
+
+
+
+ execP4Command("label -o "+name, handler);
+ log(labelSpec.toString(),Project.MSG_DEBUG);
+
+ log("Now locking label...",Project.MSG_VERBOSE);
+ handler = new P4HandlerAdapter() {
+ public void process(String line) {
+ log(line, Project.MSG_VERBOSE);
+ }
+ };
+
+ handler.setOutput(labelSpec.toString());
+ execP4Command("label -i", handler);
+ }
+
}