Browse Source

This patch enables a newly created Perforce label to be locked

Submitted by:	Les Hughes <leslie.hughes@rubus.com>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269027 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
c3633d1c5a
2 changed files with 57 additions and 2 deletions
  1. +6
    -0
      docs/manual/OptionalTasks/perforce.html
  2. +51
    -2
      src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java

+ 6
- 0
docs/manual/OptionalTasks/perforce.html View File

@@ -325,6 +325,11 @@ although P4Edit can open files to the default change, P4Submit cannot yet submi
<td valign="top">Label Description</td> <td valign="top">Label Description</td>
<td valign="top" align="center">No</td> <td valign="top" align="center">No</td>
</tr> </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> </table>
@@ -333,6 +338,7 @@ although P4Edit can open files to the default change, P4Submit cannot yet submi
&lt;p4label &lt;p4label
name=&quot;NightlyBuild:${DSTAMP}:${TSTAMP}&quot; name=&quot;NightlyBuild:${DSTAMP}:${TSTAMP}&quot;
desc=&quot;Auto Nightly Build&quot; desc=&quot;Auto Nightly Build&quot;
lock=&quot;locked&quot;
/&gt; /&gt;
</pre> </pre>
<hr> <hr>


+ 51
- 2
src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java View File

@@ -79,6 +79,7 @@ public class P4Label extends P4Base {


protected String name; protected String name;
protected String desc; protected String desc;
protected String lock;
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
@@ -87,7 +88,11 @@ public class P4Label extends P4Base {
public void setDesc(String desc) { public void setDesc(String desc) {
this.desc = desc; this.desc = desc;
} }
public void setLock(String lock) {
this.lock = lock;
}
public void execute() throws BuildException { public void execute() throws BuildException {
log("P4Label exec:",Project.MSG_INFO); log("P4Label exec:",Project.MSG_INFO);
@@ -101,7 +106,10 @@ public class P4Label extends P4Base {
desc = "AntLabel"; desc = "AntLabel";
} }

if(lock != null && !lock.equalsIgnoreCase("locked")) {
log("lock attribute invalid - ignoring",Project.MSG_WARN);
}
if(name == null || name.length() < 1) { if(name == null || name.length() < 1) {
SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd-hh:mm"); SimpleDateFormat formatter = new SimpleDateFormat ("yyyy.MM.dd-hh:mm");
Date now = new Date(); Date now = new Date();
@@ -110,6 +118,7 @@ public class P4Label extends P4Base {
} }
//We have to create a unlocked label first
String newLabel = String newLabel =
"Label: "+name+"\n"+ "Label: "+name+"\n"+
"Description: "+desc+"\n"+ "Description: "+desc+"\n"+
@@ -134,6 +143,46 @@ public class P4Label extends P4Base {
log("Created Label "+name+" ("+desc+")", Project.MSG_INFO); 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);
}
} }




Loading…
Cancel
Save