From ant-dev-return-11592-apmail-jakarta-ant-dev-archive=jakarta.apache.org@jakarta.apache.org Fri Mar 16 16:11:57 2001 Return-Path: Delivered-To: apmail-jakarta-ant-dev-archive@jakarta.apache.org Received: (qmail 65123 invoked by uid 500); 16 Mar 2001 16:11:51 -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 Delivered-To: moderator for ant-dev@jakarta.apache.org Received: (qmail 26100 invoked from network); 16 Mar 2001 15:39:36 -0000 Message-ID: <14C2925D3C68D411811C009027DE50890A69C5@exchange.verbind.com> From: "Cheek, Bob" To: ant-dev@jakarta.apache.org Cc: leslie.hughes@rubus.com Subject: [PATCH] Added Description to P4Change command Date: Fri, 16 Mar 2001 10:38:16 -0500 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: multipart/mixed; boundary="----_=_NextPart_000_01C0AE2F.1E6470AE" 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_01C0AE2F.1E6470AE Content-Type: text/plain; charset="iso-8859-1" I made an enhancement to P4Change.java to allow for a description to be entered for the changelist being created. This is my first time submitting to ANT organization so I may not have followed the proper procedures. Attached is the new source file, new documentation html and diff listings of both. I work on windows platform so the diff is a windows FC compare command. The fix, however, should be platform independent. Please forward this change to a committer to apply the patch. Thank you, Bob Cheek RCheek@Verbind.com 781.482.2354 Voice 781.482.2399 Fax http://www.verbind.com <> <> <> <> ------_=_NextPart_000_01C0AE2F.1E6470AE Content-Type: application/octet-stream; name="P4Change.java" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="P4Change.java" /*=0A= * The Apache Software License, Version 1.1=0A= *=0A= * Copyright (c) 2000 The Apache Software Foundation. All rights=0A= * reserved.=0A= *=0A= * Redistribution and use in source and binary forms, with or = without=0A= * modification, are permitted provided that the following = conditions=0A= * are met:=0A= *=0A= * 1. Redistributions of source code must retain the above copyright=0A= * notice, this list of conditions and the following disclaimer.=0A= *=0A= * 2. Redistributions in binary form must reproduce the above = copyright=0A= * notice, this list of conditions and the following disclaimer = in=0A= * the documentation and/or other materials provided with the=0A= * distribution.=0A= *=0A= * 3. The end-user documentation included with the redistribution, = if=0A= * any, must include the following acknowlegement:=0A= * "This product includes software developed by the=0A= * Apache Software Foundation (http://www.apache.org/)."=0A= * Alternately, this acknowlegement may appear in the software = itself,=0A= * if and wherever such third-party acknowlegements normally = appear.=0A= *=0A= * 4. The names "The Jakarta Project", "Ant", and "Apache Software=0A= * Foundation" must not be used to endorse or promote products = derived=0A= * from this software without prior written permission. For = written=0A= * permission, please contact apache@apache.org.=0A= *=0A= * 5. Products derived from this software may not be called "Apache"=0A= * nor may "Apache" appear in their names without prior written=0A= * permission of the Apache Group.=0A= *=0A= * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED=0A= * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES=0A= * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE=0A= * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR=0A= * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,=0A= * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT=0A= * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF=0A= * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED = AND=0A= * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT = LIABILITY,=0A= * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY = OUT=0A= * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY = OF=0A= * SUCH DAMAGE.=0A= * = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A= *=0A= * This software consists of voluntary contributions made by many=0A= * individuals on behalf of the Apache Software Foundation. For = more=0A= * information on the Apache Software Foundation, please see=0A= * .=0A= *=0A= * Portions of this software are based upon public domain software=0A= * originally written at the National Center for Supercomputing = Applications,=0A= * University of Illinois, Urbana-Champaign.=0A= */=0A= =0A= package org.apache.tools.ant.taskdefs.optional.perforce;=0A= =0A= import java.io.*;=0A= =0A= import org.apache.tools.ant.*;=0A= =0A= /** P4Change - grab a new changelist from Perforce.=0A= *=0A= * P4Change creates a new changelist in perforce. P4Change sets the = property=0A= * ${p4.change} with the new changelist number. This should then be = passed into=0A= * p4edit and p4submit.=0A= *=0A= * @see P4Edit=0A= * @see P4Submit=0A= * @author Les Hughes=0A= *=0A= */=0A= public class P4Change extends P4Base {=0A= =0A= protected String emptyChangeList =3D null;=0A= protected String description =3D "AutoSubmit By Ant";=0A= =0A= public void execute() throws BuildException {=0A= =0A= if(emptyChangeList =3D=3D null) emptyChangeList =3D = getEmptyChangeList();=0A= final Project myProj =3D project;=0A= =0A= P4Handler handler =3D new P4HandlerAdapter() {=0A= public void process(String line) {=0A= if (util.match("/Change/", line)) {=0A= =0A= //Remove any non-numerical chars - should leave the = change number=0A= line =3D util.substitute("s/[^0-9]//g", line);=0A= =0A= int changenumber =3D Integer.parseInt(line);=0A= log("Change Number is "+changenumber, = Project.MSG_INFO);=0A= myProj.setProperty("p4.change", = ""+changenumber);=0A= =0A= } else if(util.match("/error/", line)) {=0A= throw new BuildException("Perforce Error, check = client settings and/or server");=0A= }=0A= =0A= }};=0A= =0A= handler.setOutput(emptyChangeList);=0A= =0A= execP4Command("change -i", handler);=0A= }=0A= =0A= =0A= public String getEmptyChangeList() throws BuildException {=0A= final StringBuffer stringbuf =3D new StringBuffer();=0A= =0A= execP4Command("change -o", new P4HandlerAdapter() {=0A= public void process(String line) {=0A= if(!util.match("/^#/",line)){=0A= if(util.match("/error/", line)) {=0A= =0A= log("Client Error", Project.MSG_VERBOSE);=0A= throw new BuildException("Perforce Error, check = client settings and/or server");=0A= =0A= } else if(util.match("//",line)) {=0A= =0A= line =3D util.substitute("s//" + description + "/", line);=0A= =0A= } else if(util.match("/\\/\\//", line)) {=0A= //Match "//" for begining of depot filespec=0A= return;=0A= }=0A= =0A= stringbuf.append(line);=0A= stringbuf.append("\n");=0A= =0A= }=0A= }});=0A= =0A= return stringbuf.toString();=0A= }=0A= =0A= /* Set Description Variable. */=0A= public void setDescription(String desc){=0A= this.description =3D desc;=0A= }=0A= =0A= } //EoF=0A= ------_=_NextPart_000_01C0AE2F.1E6470AE Content-Type: application/octet-stream; name="P4Change.dif" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="P4Change.dif" Comparing files P4Change.Org and P4CHANGE.JAVA ***** P4Change.Org protected String emptyChangeList =3D null; ***** P4CHANGE.JAVA protected String emptyChangeList =3D null; protected String description =3D "AutoSubmit By Ant"; ***** ***** P4Change.Org if (util.match("/Change/", line)) { =20 //Remove any non-numerical chars - should leave the = change number line =3D util.substitute("s/[^0-9]//g", = line); =20 int changenumber =3D = 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"); } =20 }}; ***** P4CHANGE.JAVA if (util.match("/Change/", line)) { //Remove any non-numerical chars - should leave the = change number line =3D util.substitute("s/[^0-9]//g", line); int changenumber =3D 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"); } }}; ***** ***** P4Change.Org final StringBuffer stringbuf =3D new StringBuffer(); =20 execP4Command("change -o", new P4HandlerAdapter() { ***** P4CHANGE.JAVA final StringBuffer stringbuf =3D new StringBuffer(); execP4Command("change -o", new P4HandlerAdapter() { ***** ***** P4Change.Org public void process(String line) { if(!util.match("/^#/",line)){ if(util.match("/error/", line)) { =20 log("Client Error", = Project.MSG_VERBOSE); throw new BuildException("Perforce = Error, check client settings and/or server"); =20 } else if(util.match("//",line)) { line =3D util.substitute("s//AutoSubmit By Ant/", line); =20 } else if(util.match("/\\/\\//", line)) = { //Match "//" for begining of depot = filespec return; } =20 stringbuf.append(line); stringbuf.append("\n"); =20 } }}); =20 return stringbuf.toString(); } ***** P4CHANGE.JAVA 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 =3D 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(); } ***** ***** P4Change.Org ***** P4CHANGE.JAVA /* Set Description Variable. */ public void setDescription(String desc){ this.description =3D desc; } ***** ------_=_NextPart_000_01C0AE2F.1E6470AE Content-Type: text/html; name="perforce.html" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="perforce.html" Perforce Tasks for ANT

Perforce Tasks User Manual

by

Version 1.1 - 2001/01/09


Contents


Introduction

These tasks provide an interface to the Perforce SCM. The org.apache.tools.ant.taskdefs.optional.perforce = package consists of a simple framework to support p4 functionality as well as some Ant tasks encapsulating frequently = used (by me :-) p4 commands. However, the addition of new p4 commands is a pretty simple task (see = the source). Although it is possible to use these commands on the desktop, they were primarily intended to be used by automated build systems.

Note: These tasks require the oro 2.0 = regular expression package. Simply download this package and copy the = jakarta-oro-2.0.jar file into Ant's lib directory. You will also need the perforce client executable (p4 or p4.exe but not = p4win.exe) in your path.

The Tasks

P4Sync Synchronise a workspce to a depot
P4Change Request a new changelist from the perforce server
P4Edit Open files for edit (checkout)
P4Submit Submit a changelist to the perforce server (checkin)
P4Have List current files in client view, useful for = reporting
P4Label Create a label reflecting files in the current = workspace

General P4 Properties

Each p4 task requires a number of settings, either through = build-wide properties, individual attributes or environment variables. These are

Property Attribute Env Var Description Default
p4.port port P4PORT The p4d server and port to connect to perforce:1666
p4.client client P4CLIENT The p4 client spec to use The logged in username
p4.user user P4USER The p4 username The logged in username
-- view -- The client, branch or label view to operate = upon. See the p4 user guide for more info. //...

Your local installation of perforce may require other settings (e.g. = P4PASSWD, P4CONFIG). At the moment, these can only be set outside of = Ant, as environment variables.

Examples

Setting in the environment:-

(Unix csh)

setenv P4PORT myperforcebox:1666

(Unix sh et al)

P4USER=3Dmyp4userid; export P4USER

Using build properties:-

<property name=3D"p4.client" =
value=3D"nightlybuild"/>

Using task attributes:-

<p4Whatever
    port=3D"myserver:1666"
    client=3D"smoketest"
    user=3D"smoketestdude"
    .
    .
    .
/>

For more information regarding the underlying 'p4' commands you are = referred to the Perforce Command Reference available from the Perforce website.

Taskdefs

Standard taskdefs (for you to copy'n'paste)

    <taskdef name=3D"p4sync" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Sync=
" />
    <taskdef name=3D"p4change" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Chan=
ge" />
    <taskdef name=3D"p4edit" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Edit=
" />
    <taskdef name=3D"p4submit" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Subm=
it" />
    <taskdef name=3D"p4have" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Have=
" />
    <taskdef name=3D"p4label" =
classname=3D"org.apache.tools.ant.taskdefs.optional.perforce.P4Labe=
l" />

Task Descriptions

P4Sync

Description:

Synchronize the current workspace with the depot.

Parameters

Attribute Description Required
force force a refresh of files no
label sync client to label no

Examples

<p4sync label=3D"nightlybuild-0.0123" =
force=3D"yes" />
<p4sync view=3D"//depot/projects/projectfoo/main/src/..." =
/>

P4Change

Description:

Request a new changelist from the perforce server. This task sets the ${p4.change} property which can then be passed to = P4Submit or P4Edit.

Parameters

Attribute Description Required
description Description for ChangeList. If none specified, = it will default to "AutoSubmit By Ant" No.

Examples

<p4change description=3D"Change Build Number in Script">

P4Edit

Description:

Open file(s) for edit. P4Change should be used to obtain a new = changelist for P4Edit as, although P4Edit can open files to the default change, P4Submit cannot = yet submit it.

Parameters

Attribute Description Required
view The filespec to request to edit Yes
change An existing changelist number to assign files = to. No, but see above.

Examples

<p4edit
    =
view=3D"//depot/projects/projectfoo/main/src/Blah.java..."
    change=3D"${p4.change}" />

P4Submit

Description:

Submit a changelist, usually obtained from P4Change.

Parameters

Attribute Description Required
change The changelist number to submit Yes

Examples

<p4submit change=3D"${p4.change}" />

P4Have

Description:

List handy file info reflecting the current client contents.

Parameters

Attribute Description Required
None -- --

Examples

<p4have />

P4Label

Description:

Create a new label and set contents to reflect current client file = revisions.

Parameters

Attribute Description Required
name The name of the label Yes
view client view to use for label No
desc Label Description No

Examples

<p4label
    name=3D"NightlyBuild:${DSTAMP}:${TSTAMP}"
    desc=3D"Auto Nightly Build"
/>

Change History

Sept 2000 -- Internal Release within Rubus
Nov 2000 V1.0 Initial Release donated to ASF :-)
Jan 2001 V1.1 fixed cross platform (NT/Unix) bug
refactored = p4 output handling code
refactored exec'ing code
------_=_NextPart_000_01C0AE2F.1E6470AE Content-Type: application/octet-stream; name="Perforce.dif" Content-Disposition: attachment; filename="Perforce.dif" Comparing files perforce.orig and PERFORCE.HTML ***** perforce.orig

These tasks provide an interface to the Perforce SCM. The org.apache.tools.ant.taskdefs.optional.perforce package consists of a simple framework to support p4 functionality as well as some Ant tasks encapsulating frequently used (by me :-) p4 commands. However, the addition of new p4 commands is a pretty simple task (see the source). Although it is possible to use these commands on the desktop, they were primarily intended to be used by automated build systems.

***** PERFORCE.HTML

These tasks provide an interface to the Perforce SCM. The org.apache.tools.ant.taskdefs.optional.perforce package consists of a simple framework to support p4 functionality as well as some Ant tasks encapsulating frequently used (by me :-) p4 commands. However, the addition of new p4 commands is a pretty simple task (see the source). Although it is possible to use these commands on the desktop, they were primarily intended to be used by automated build systems.

***** ***** perforce.orig

General P4 Properties

Each p4 task requires a number of settings, either through build-wide properties, individual attributes or environment variables. These are ***** PERFORCE.HTML

General P4 Properties

Each p4 task requires a number of settings, either through build-wide properties, individual attributes or environment variables. These are ***** ***** perforce.orig <p4Whatever port="myserver:1666" client="smoketest" user="smoketestdude" . . . /> ***** PERFORCE.HTML <p4Whatever port="myserver:1666" client="smoketest" user="smoketestdude" . . . /> ***** ***** perforce.orig

Description:

Request a new changelist from the perforce server. This task sets the ${p4.change} property which can then be passed to P4Submit or P4Edit. ***** PERFORCE.HTML

Description:

Request a new changelist from the perforce server. This task sets the ${p4.change} property which can then be passed to P4Submit or P4Edit. ***** ***** perforce.orig None -- -- ***** PERFORCE.HTML description Description for ChangeList. If none specified, it will default to "AutoSubmit By Ant" No. ***** ***** perforce.orig

Examples

<p4change />
***** PERFORCE.HTML

Examples

<p4change description="Change Build Number in Script">
***** ***** perforce.orig <p4edit view="//depot/projects/projectfoo/main/src/Blah.java..." change="${p4.change}" /> ***** PERFORCE.HTML <p4edit view="//depot/projects/projectfoo/main/src/Blah.java..." change="${p4.change}" /> ***** ***** perforce.orig <p4label name="NightlyBuild:${DSTAMP}:${TSTAMP}" desc="Auto Nightly Build" /> ***** PERFORCE.HTML <p4label name="NightlyBuild:${DSTAMP}:${TSTAMP}" desc="Auto Nightly Build" /> ***** ------_=_NextPart_000_01C0AE2F.1E6470AE--