Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 98644 invoked by uid 500); 14 May 2001 08:46:30 -0000 Mailing-List: contact ant-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk Reply-To: ant-dev@jakarta.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list ant-dev@jakarta.apache.org Received: (qmail 98625 invoked from network); 14 May 2001 08:46:27 -0000 Message-ID: <502326F46B08D41191C400508B6D70C10235BF73@nvision01.rubus.com> From: Les Hughes To: "Ant-Dev@Jakarta. Apache. Org (E-mail)" Cc: "'eric.badiere@bea.com'" Subject: [PATCH] Added lockable labels to P4Label.java Date: Mon, 14 May 2001 09:43:14 +0100 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C0DC51.EA196B50" X-Spam-Rating: h31.sny.collab.net 1.6.2 0/1000/N This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. ------_=_NextPart_000_01C0DC51.EA196B50 Content-Type: text/plain; charset="iso-8859-1" Hi, This patch enables a newly created Perforce label to be locked. Bye, Les ------_=_NextPart_000_01C0DC51.EA196B50 Content-Type: application/octet-stream; name="P4Label.diff" Content-Disposition: attachment; filename="P4Label.diff" Index: P4Label.java =================================================================== RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Label.java,v retrieving revision 1.2 diff -u -r1.2 P4Label.java --- P4Label.java 2001/01/12 15:28:35 1.2 +++ P4Label.java 2001/05/14 08:39:29 @@ -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); + } + } ------_=_NextPart_000_01C0DC51.EA196B50 Content-Type: application/octet-stream; name="perforce.html.diff" Content-Disposition: attachment; filename="perforce.html.diff" Index: perforce.html =================================================================== RCS file: /home/cvspublic/jakarta-ant/docs/manual/OptionalTasks/perforce.html,v retrieving revision 1.6 diff -u -r1.6 perforce.html --- perforce.html 2001/05/03 07:10:16 1.6 +++ perforce.html 2001/05/14 08:41:55 @@ -325,6 +325,11 @@ Label Description No + + lock + Lock the label once created. + No + @@ -333,6 +338,7 @@ <p4label name="NightlyBuild:${DSTAMP}:${TSTAMP}" desc="Auto Nightly Build" + lock="locked" />
------_=_NextPart_000_01C0DC51.EA196B50--