From d10d01a97afafd7ee61f1eddefe292b56240f408 Mon Sep 17 00:00:00 2001 From: Stefan Bodewig Date: Mon, 19 Mar 2001 13:18:31 +0000 Subject: [PATCH] add description attribute to Submitted by: Bob Cheek patch looks a lot bigger than it is - I removed a ton of tabs from this file. git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268865 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 2 + docs/manual/OptionalTasks/perforce.html | 9 ++- .../taskdefs/optional/perforce/P4Change.java | 81 ++++++++++--------- 3 files changed, 50 insertions(+), 42 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index c0107c801..b02c0fc54 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -21,6 +21,8 @@ Other changes: * will now add empty directories as well +* you can now specify a description for + Fixed bugs: ----------- diff --git a/docs/manual/OptionalTasks/perforce.html b/docs/manual/OptionalTasks/perforce.html index ba66244e3..a1ce83f97 100644 --- a/docs/manual/OptionalTasks/perforce.html +++ b/docs/manual/OptionalTasks/perforce.html @@ -190,14 +190,15 @@ This task sets the ${p4.change} property which can then be passed to P4Submit or Required - None - -- - -- + description + Description for ChangeList. If none specified, it will + default to "AutoSubmit By Ant" + No.

Examples

-
<p4change />
+
<p4change description="Change Build Number in Script">
 

diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java index f946b72f7..a5764820d 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java @@ -75,7 +75,8 @@ import org.apache.tools.ant.*; */ public class P4Change extends P4Base { - protected String emptyChangeList = null; + protected String emptyChangeList = null; + protected String description = "AutoSubmit By Ant"; public void execute() throws BuildException { @@ -83,21 +84,21 @@ public class P4Change extends P4Base { final Project myProj = project; P4Handler handler = new P4HandlerAdapter() { - public void process(String line) { - if (util.match("/Change/", line)) { + public void process(String line) { + if (util.match("/Change/", line)) { - //Remove any non-numerical chars - should leave the change number - line = util.substitute("s/[^0-9]//g", line); - - int changenumber = Integer.parseInt(line); - log("Change Number is "+changenumber, Project.MSG_INFO); - myProj.setProperty("p4.change", ""+changenumber); - - } else if(util.match("/error/", line)) { - throw new BuildException("Perforce Error, check client settings and/or server"); - } - - }}; + //Remove any non-numerical chars - should leave the change number + line = util.substitute("s/[^0-9]//g", line); + + int changenumber = Integer.parseInt(line); + log("Change Number is "+changenumber, Project.MSG_INFO); + myProj.setProperty("p4.change", ""+changenumber); + + } else if(util.match("/error/", line)) { + throw new BuildException("Perforce Error, check client settings and/or server"); + } + + }}; handler.setOutput(emptyChangeList); @@ -109,30 +110,34 @@ public class P4Change extends P4Base { final StringBuffer stringbuf = new StringBuffer(); execP4Command("change -o", new P4HandlerAdapter() { - public void process(String line) { - if(!util.match("/^#/",line)){ - if(util.match("/error/", line)) { - - log("Client Error", Project.MSG_VERBOSE); - throw new BuildException("Perforce Error, check client settings and/or server"); - - } else if(util.match("//",line)) { - - line = util.substitute("s//AutoSubmit By Ant/", line); - - } else if(util.match("/\\/\\//", line)) { - //Match "//" for begining of depot filespec - return; - } - - stringbuf.append(line); - stringbuf.append("\n"); - - } - }}); - - return stringbuf.toString(); + public void process(String line) { + if(!util.match("/^#/",line)){ + if(util.match("/error/", line)) { + + log("Client Error", Project.MSG_VERBOSE); + throw new BuildException("Perforce Error, check client settings and/or server"); + + } else if(util.match("//",line)) { + + line = util.substitute("s//" + description + "/", line); + + } else if(util.match("/\\/\\//", line)) { + //Match "//" for begining of depot filespec + return; + } + + stringbuf.append(line); + stringbuf.append("\n"); + + } + }}); + + return stringbuf.toString(); } + /* Set Description Variable. */ + public void setDescription(String desc){ + this.description = desc; + } } //EoF