ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sbaill...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce P4Base.java P4Change.java P4Counter.java P4Delete.java P4Edit.java P4Handler.java P4HandlerAdapter.java P4Have.java P4Label.java P4Reopen.java P4Revert.java P4Submit.java P4Sync.java SimpleP4OutputHandler.java
Date Wed, 09 Jan 2002 00:03:23 GMT
sbailliez    02/01/08 16:03:23

  Modified:    src/main/org/apache/tools/ant/taskdefs/optional/perforce
                        P4Base.java P4Change.java P4Counter.java
                        P4Delete.java P4Edit.java P4Handler.java
                        P4HandlerAdapter.java P4Have.java P4Label.java
                        P4Reopen.java P4Revert.java P4Submit.java
                        P4Sync.java SimpleP4OutputHandler.java
  Log:
  Code layout only.
  
  Revision  Changes    Path
  1.8       +61 -46    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java
  
  Index: P4Base.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Base.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- P4Base.java	8 Jan 2002 22:24:16 -0000	1.7
  +++ P4Base.java	9 Jan 2002 00:03:22 -0000	1.8
  @@ -59,11 +59,12 @@
   package org.apache.tools.ant.taskdefs.optional.perforce;
   
   import java.io.IOException;
  +
  +import org.apache.oro.text.perl.Perl5Util;
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.taskdefs.Execute;
   import org.apache.tools.ant.types.Commandline;
  -import org.apache.oro.text.perl.Perl5Util;
   
   
   /** Base class for Perforce (P4) ANT tasks. See individual task for example usage.
  @@ -86,58 +87,72 @@
   
       //P4 runtime directives
       /** Perforce Server Port (eg KM01:1666) */
  -    protected String P4Port     = "";
  +    protected String P4Port = "";
       /** Perforce Client (eg myclientspec) */
  -    protected String P4Client   = "";
  +    protected String P4Client = "";
       /** Perforce User (eg fbloggs) */
  -    protected String P4User     = "";
  +    protected String P4User = "";
       /** Perforce view for commands (eg //projects/foobar/main/source/... )*/
  -    protected String P4View     = "";
  +    protected String P4View = "";
   
       //P4 g-opts and cmd opts (rtfm)
       /** Perforce 'global' opts.
  -      * Forms half of low level API */
  -    protected String P4Opts     = "";
  +     * Forms half of low level API */
  +    protected String P4Opts = "";
       /** Perforce command opts.
  -      * Forms half of low level API */
  -    protected String P4CmdOpts  = "";
  +     * Forms half of low level API */
  +    protected String P4CmdOpts = "";
   
       //Setters called by Ant
  -    public void setPort(String P4Port)        { this.P4Port       =   "-p"+P4Port;    }
  -    public void setClient(String P4Client)    { this.P4Client     =   "-c"+P4Client;  }
  -    public void setUser(String P4User)        { this.P4User       =   "-u"+P4User;    }
  -    public void setView(String P4View)        { this.P4View       =   P4View;         }
  -    public void setCmdopts(String P4CmdOpts)  { this.P4CmdOpts    =   P4CmdOpts;      }
  +    public void setPort(String P4Port) {
  +        this.P4Port = "-p" + P4Port;
  +    }
  +
  +    public void setClient(String P4Client) {
  +        this.P4Client = "-c" + P4Client;
  +    }
  +
  +    public void setUser(String P4User) {
  +        this.P4User = "-u" + P4User;
  +    }
  +
  +    public void setView(String P4View) {
  +        this.P4View = P4View;
  +    }
  +
  +    public void setCmdopts(String P4CmdOpts) {
  +        this.P4CmdOpts = P4CmdOpts;
  +    }
   
       public void init() {
   
           util = new Perl5Util();
   
           //Get default P4 settings from environment - Mark would have done something cool
with
  -            //introspection here.....:-)
  -            String tmpprop;
  -        if((tmpprop = project.getProperty("p4.port")) != null) {
  -          setPort(tmpprop);
  +        //introspection here.....:-)
  +        String tmpprop;
  +        if ((tmpprop = project.getProperty("p4.port")) != null) {
  +            setPort(tmpprop);
  +        }
  +        if ((tmpprop = project.getProperty("p4.client")) != null) {
  +            setClient(tmpprop);
           }
  -        if((tmpprop = project.getProperty("p4.client")) != null) {
  -          setClient(tmpprop);
  +        if ((tmpprop = project.getProperty("p4.user")) != null) {
  +            setUser(tmpprop);
           }
  -        if((tmpprop = project.getProperty("p4.user")) != null) {
  -          setUser(tmpprop);
  -        }        
       }
   
       protected void execP4Command(String command) throws BuildException {
           execP4Command(command, null);
       }
  -    
  +
       /** Execute P4 command assembled by subclasses.
  -        @param command The command to run
  -        @param p4input Input to be fed to command on stdin
  -        @param handler A P4Handler to process any input and output
  -    */
  +     @param command The command to run
  +     @param p4input Input to be fed to command on stdin
  +     @param handler A P4Handler to process any input and output
  +     */
       protected void execP4Command(String command, P4Handler handler) throws BuildException
{
  -        try{
  +        try {
   
               Commandline commandline = new Commandline();
               commandline.setExecutable("p4");
  @@ -155,38 +170,38 @@
               commandline.createArgument().setLine(command);
   
   
  -            String[] cmdline = commandline.getCommandline() ;
  +            String[] cmdline = commandline.getCommandline();
               String cmdl = "";
  -            for (int i=0 ; i < cmdline.length ; i++) {
  +            for (int i = 0; i < cmdline.length; i++) {
                   cmdl += cmdline[i] + " ";
               }
  -    
  -            log("Execing "+cmdl, Project.MSG_VERBOSE);
   
  -            if(handler == null ) {
  -              handler = new SimpleP4OutputHandler(this);
  +            log("Execing " + cmdl, Project.MSG_VERBOSE);
  +
  +            if (handler == null) {
  +                handler = new SimpleP4OutputHandler(this);
               }
   
               Execute exe = new Execute(handler, null);
   
               exe.setAntRun(project);
  -            
  +
               exe.setCommandline(commandline.getCommandline());
   
  -            try{
  -             exe.execute();
  -            }catch(IOException e) {
  +            try {
  +                exe.execute();
  +            } catch (IOException e) {
                   throw new BuildException(e);
               } finally {
  -                try{
  +                try {
                       handler.stop();
  -                }catch(Exception e) {}
  +                } catch (Exception e) {
  +                }
               }
   
  -            
  -                
  -            }catch(Exception e) {
  -                throw new BuildException("Problem exec'ing P4 command: "+e.getMessage());
  -            }
  +
  +        } catch (Exception e) {
  +            throw new BuildException("Problem exec'ing P4 command: " + e.getMessage());
  +        }
       }
   }
  
  
  
  1.8       +46 -44    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java
  
  Index: P4Change.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Change.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- P4Change.java	8 Jan 2002 22:40:31 -0000	1.7
  +++ P4Change.java	9 Jan 2002 00:03:22 -0000	1.8
  @@ -79,27 +79,28 @@
   
       public void execute() throws BuildException {
   
  -        if(emptyChangeList == null) {
  -          emptyChangeList = getEmptyChangeList();
  +        if (emptyChangeList == null) {
  +            emptyChangeList = getEmptyChangeList();
           }
           final Project myProj = project;
   
           P4Handler handler = new P4HandlerAdapter() {
  -                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);
  +            public void process(String line) {
  +                if (util.match("/Change/", line)) {
   
  -                    } 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,32 +110,33 @@
   
       public String getEmptyChangeList() throws BuildException {
           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("/<enter description here>/",line))
{
  -
  -                            // we need to escape the description in case there are /
  -                            description = backslash(description);
  -                            line = util.substitute("s/<enter description here>/"
+ description + "/", line);
  -                                        
  -                        } else if(util.match("/\\/\\//", line)) {
  -                            //Match "//" for begining of depot filespec
  -                            return;
  -                        }
  -                                    
  -                        stringbuf.append(line);
  -                        stringbuf.append("\n");
  -                                
  +            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("/<enter description here>/", line)) {
  +
  +                        // we need to escape the description in case there are /
  +                        description = backslash(description);
  +                        line = util.substitute("s/<enter description here>/" + description
+ "/", line);
  +
  +                    } else if (util.match("/\\/\\//", line)) {
  +                        //Match "//" for begining of depot filespec
  +                        return;
                       }
  -                }});
  -                
  +
  +                    stringbuf.append(line);
  +                    stringbuf.append("\n");
  +
  +                }
  +            }
  +        });
  +
           return stringbuf.toString();
       }
   
  @@ -146,12 +148,12 @@
        * @return the backslashed string
        * @see < a href="http://jakarta.apache.org/oro/api/org/apache/oro/text/perl/Perl5Util.html#substitute(java.lang.String,%20java.lang.String)">Oro</a>
        */
  -    public static final String backslash(String value){
  +    public static final String backslash(String value) {
           final StringBuffer buf = new StringBuffer(value.length());
           final int len = value.length();
  -        for (int i = 0; i < len; i++){
  +        for (int i = 0; i < len; i++) {
               char c = value.charAt(i);
  -            if (c == '/'){
  +            if (c == '/') {
                   buf.append('\\');
               }
               buf.append(c);
  @@ -160,7 +162,7 @@
       }
   
       /* Set Description Variable. */
  -    public void setDescription(String desc){
  +    public void setDescription(String desc) {
           this.description = desc;
       }
   
  
  
  
  1.4       +9 -9      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Counter.java
  
  Index: P4Counter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Counter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- P4Counter.java	28 Oct 2001 21:30:22 -0000	1.3
  +++ P4Counter.java	9 Jan 2002 00:03:22 -0000	1.4
  @@ -66,13 +66,13 @@
    * to the output stream for the project (by setting the "name"
    * attribute only), to set a property based on the value of
    * a counter (by setting the "property" attribute) or to set the counter
  - * on the perforce server (by setting the "value" attribute). 
  + * on the perforce server (by setting the "value" attribute).
    *
    * Example Usage:<br>
    * &lt;p4counter name="${p4.counter}" property=${p4.change}"/&gt;
    * @author <a href="mailto:kirk@radik.com">Kirk Wylie</a>
    */
  - 
  +
   public class P4Counter extends P4Base {
       public String counter = null;
       public String property = null;
  @@ -96,35 +96,35 @@
   
       public void execute() throws BuildException {
   
  -        if((counter == null) || counter.length() == 0) {
  +        if ((counter == null) || counter.length() == 0) {
               throw new BuildException("No counter specified to retrieve");
           }
   
  -        if(shouldSetValue && shouldSetProperty) {
  +        if (shouldSetValue && shouldSetProperty) {
               throw new BuildException("Cannot both set the value of the property and retrieve
the value of the property.");
           }
   
           String command = "counter " + P4CmdOpts + " " + counter;
  -        if(!shouldSetProperty) {
  +        if (!shouldSetProperty) {
               // NOTE kirk@radik.com 04-April-2001 -- If you put in the -s, you
               // have to start running through regular expressions here. Much easier
               // to just not include the scripting information than to try to add it
               // and strip it later.
               command = "-s " + command;
           }
  -        if(shouldSetValue) {
  +        if (shouldSetValue) {
               command += " " + value;
           }
   
  -        if(shouldSetProperty) {
  +        if (shouldSetProperty) {
               final Project myProj = project;
   
               P4Handler handler = new P4HandlerAdapter() {
                   public void process(String line) {
  -                    log("P4Counter retrieved line \""+ line + "\"", Project.MSG_VERBOSE);
  +                    log("P4Counter retrieved line \"" + line + "\"", Project.MSG_VERBOSE);
                       try {
                           value = Integer.parseInt(line);
  -                        myProj.setProperty(property, ""+value);
  +                        myProj.setProperty(property, "" + value);
                       } catch (NumberFormatException nfe) {
                           throw new BuildException("Perforce error. Could not retrieve counter
value.");
                       }
  
  
  
  1.4       +5 -5      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java
  
  Index: P4Delete.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Delete.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- P4Delete.java	8 Jan 2002 22:31:09 -0000	1.3
  +++ P4Delete.java	9 Jan 2002 00:03:22 -0000	1.4
  @@ -76,12 +76,12 @@
       }
   
       public void execute() throws BuildException {
  -        if(change != null ) {
  -          P4CmdOpts = "-c "+change;
  +        if (change != null) {
  +            P4CmdOpts = "-c " + change;
           }
  -        if(P4View == null) {
  -          throw new BuildException("No view specified to delete");
  +        if (P4View == null) {
  +            throw new BuildException("No view specified to delete");
           }
  -        execP4Command("-s delete "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
  +        execP4Command("-s delete " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.6       +6 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java
  
  Index: P4Edit.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Edit.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- P4Edit.java	8 Jan 2002 22:50:43 -0000	1.5
  +++ P4Edit.java	9 Jan 2002 00:03:22 -0000	1.6
  @@ -69,7 +69,7 @@
    * ToDo: Should call reopen if file is already open in one of our changelists perhaps?
    */
   
  - public class P4Edit extends P4Base {
  +public class P4Edit extends P4Base {
   
       public String change = null;
   
  @@ -78,12 +78,12 @@
       }
   
       public void execute() throws BuildException {
  -        if(change != null ) {
  -          P4CmdOpts = "-c "+change;
  +        if (change != null) {
  +            P4CmdOpts = "-c " + change;
           }
  -        if(P4View == null) {
  -          throw new BuildException("No view specified to edit");
  +        if (P4View == null) {
  +            throw new BuildException("No view specified to edit");
           }
  -        execP4Command("-s edit "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
  +        execP4Command("-s edit " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.2       +1 -0      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java
  
  Index: P4Handler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Handler.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- P4Handler.java	12 Jan 2001 15:28:34 -0000	1.1
  +++ P4Handler.java	9 Jan 2002 00:03:22 -0000	1.2
  @@ -65,5 +65,6 @@
   public interface P4Handler extends ExecuteStreamHandler {
   
       public void process(String line) throws BuildException;
  +
       public void setOutput(String line) throws BuildException;
   }
  
  
  
  1.4       +18 -16    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java
  
  Index: P4HandlerAdapter.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4HandlerAdapter.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- P4HandlerAdapter.java	27 Nov 2001 18:04:53 -0000	1.3
  +++ P4HandlerAdapter.java	9 Jan 2002 00:03:22 -0000	1.4
  @@ -54,12 +54,13 @@
   
   package org.apache.tools.ant.taskdefs.optional.perforce;
   
  +import java.io.BufferedReader;
   import java.io.IOException;
  -import java.io.OutputStream;
   import java.io.InputStream;
  -import java.io.BufferedReader;
   import java.io.InputStreamReader;
  +import java.io.OutputStream;
   import java.io.SequenceInputStream;
  +
   import org.apache.tools.ant.BuildException;
   
   public abstract class P4HandlerAdapter implements P4Handler {
  @@ -77,29 +78,29 @@
   
       public void start() throws BuildException {
   
  -    try{
  -        //First write any output to P4
  -        if(p4input != null && p4input.length() >0 && os != null) {
  -                    os.write(p4input.getBytes());
  -                    os.flush();
  -                    os.close();
  +        try {
  +            //First write any output to P4
  +            if (p4input != null && p4input.length() > 0 && os != null)
{
  +                os.write(p4input.getBytes());
  +                os.flush();
  +                os.close();
               }
   
  -        //Now read any input and process
  +            //Now read any input and process
   
  -        BufferedReader input = new BufferedReader(
  -                                     new InputStreamReader(
  -                                       new SequenceInputStream(is,es)));
  +            BufferedReader input = new BufferedReader(
  +                    new InputStreamReader(
  +                            new SequenceInputStream(is, es)));
   
               String line;
  -            while((line = input.readLine()) != null) {
  -               process(line);
  +            while ((line = input.readLine()) != null) {
  +                process(line);
               }
   
               input.close();
   
   
  -        }catch(Exception e) {
  +        } catch (Exception e) {
               throw new BuildException(e);
           }
       }
  @@ -120,5 +121,6 @@
           this.is = is;
       }
   
  -    public void stop(){}
  +    public void stop() {
  +    }
   }
  
  
  
  1.4       +2 -2      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java
  
  Index: P4Have.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Have.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- P4Have.java	28 Oct 2001 21:30:22 -0000	1.3
  +++ P4Have.java	9 Jan 2002 00:03:22 -0000	1.4
  @@ -62,7 +62,7 @@
   
   
   /** P4Have - lists files currently on client.
  - * 
  + *
    * P4Have simply dumps the current file version info into
    * the Ant log (or stdout).
    * @author <A HREF="mailto:leslie.hughes@rubus.com">Les Hughes</A>
  @@ -70,6 +70,6 @@
   public class P4Have extends P4Base {
   
       public void execute() throws BuildException {
  -        execP4Command("have "+P4CmdOpts+" "+P4View, new SimpleP4OutputHandler(this));
  +        execP4Command("have " + P4CmdOpts + " " + P4View, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.7       +30 -31    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.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- P4Label.java	27 Nov 2001 18:04:53 -0000	1.6
  +++ P4Label.java	9 Jan 2002 00:03:22 -0000	1.7
  @@ -58,12 +58,12 @@
   
   package org.apache.tools.ant.taskdefs.optional.perforce;
   
  +import java.text.SimpleDateFormat;
  +import java.util.Date;
  +
   import org.apache.tools.ant.BuildException;
   import org.apache.tools.ant.Project;
   
  -import java.util.Date;
  -import java.text.SimpleDateFormat;
  -
   
   /** P4Label - create a Perforce Label.
    *
  @@ -93,41 +93,41 @@
           this.desc = desc;
       }
   
  -     public void setLock(String lock)  {
  +    public void setLock(String lock) {
           this.lock = lock;
  -     }
  +    }
   
       public void execute() throws BuildException {
  -        log("P4Label exec:",Project.MSG_INFO);
  +        log("P4Label exec:", Project.MSG_INFO);
   
  -        if(P4View == null || P4View.length() < 1) {
  +        if (P4View == null || P4View.length() < 1) {
               log("View not set, assuming //depot/...", Project.MSG_WARN);
               P4View = "//depot/...";
           }
   
  -        if(desc == null || desc.length() < 1) {
  +        if (desc == null || desc.length() < 1) {
               log("Label Description not set, assuming 'AntLabel'", Project.MSG_WARN);
               desc = "AntLabel";
           }
   
  -        if(lock != null && !lock.equalsIgnoreCase("locked")) {
  -            log("lock attribute invalid - ignoring",Project.MSG_WARN);
  +        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");
  +        if (name == null || name.length() < 1) {
  +            SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd-hh:mm");
               Date now = new Date();
  -            name = "AntLabel-"+formatter.format(now);
  -            log("name not set, assuming '"+name+"'", Project.MSG_WARN);
  +            name = "AntLabel-" + formatter.format(now);
  +            log("name not set, assuming '" + name + "'", Project.MSG_WARN);
           }
   
   
           //We have to create a unlocked label first
           String newLabel =
  -            "Label: "+name+"\n"+
  -            "Description: "+desc+"\n"+
  -            "Options: unlocked\n"+
  -            "View: "+P4View+"\n";
  +                "Label: " + name + "\n" +
  +                "Description: " + desc + "\n" +
  +                "Options: unlocked\n" +
  +                "View: " + P4View + "\n";
   
           P4Handler handler = new P4HandlerAdapter() {
               public void process(String line) {
  @@ -139,19 +139,19 @@
   
           execP4Command("label -i", handler);
   
  -        execP4Command("labelsync -l "+name, new P4HandlerAdapter() {
  +        execP4Command("labelsync -l " + name, new P4HandlerAdapter() {
               public void process(String line) {
                   log(line, Project.MSG_VERBOSE);
               }
           });
   
   
  -        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"))  {
  +        if (lock != null && lock.equalsIgnoreCase("locked")) {
   
  -            log("Modifying lock status to 'locked'",Project.MSG_INFO);
  +            log("Modifying lock status to 'locked'", Project.MSG_INFO);
   
               final StringBuffer labelSpec = new StringBuffer();
   
  @@ -159,24 +159,23 @@
               //Replace Options
               //Submit back to Perforce
   
  -            handler = new P4HandlerAdapter()  {
  -                public void process(String line)  {
  +            handler = new P4HandlerAdapter() {
  +                public void process(String line) {
                       log(line, Project.MSG_VERBOSE);
   
  -                    if(util.match("/^Options:/",line)) {
  -                        line = "Options: "+lock;
  +                    if (util.match("/^Options:/", line)) {
  +                        line = "Options: " + lock;
                       }
   
  -                    labelSpec.append(line+"\n");
  +                    labelSpec.append(line + "\n");
                   }
               };
   
   
  +            execP4Command("label -o " + name, handler);
  +            log(labelSpec.toString(), Project.MSG_DEBUG);
   
  -            execP4Command("label -o "+name, handler);
  -            log(labelSpec.toString(),Project.MSG_DEBUG);
  -
  -            log("Now locking label...",Project.MSG_VERBOSE);
  +            log("Now locking label...", Project.MSG_VERBOSE);
               handler = new P4HandlerAdapter() {
                   public void process(String line) {
                       log(line, Project.MSG_VERBOSE);
  
  
  
  1.5       +4 -3      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java
  
  Index: P4Reopen.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Reopen.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- P4Reopen.java	8 Jan 2002 23:59:33 -0000	1.4
  +++ P4Reopen.java	9 Jan 2002 00:03:22 -0000	1.5
  @@ -64,12 +64,13 @@
    *
    * @author <A HREF="mailto:leslie.hughes@rubus.com">Les Hughes</A>
    */
  +
   public class P4Reopen extends P4Base {
   
       private String toChange = "";
   
       public void setToChange(String toChange) throws BuildException {
  -        if(toChange == null && !toChange.equals("")) {
  +        if (toChange == null && !toChange.equals("")) {
               throw new BuildException("P4Reopen: tochange cannot be null or empty");
           }
   
  @@ -77,9 +78,9 @@
       }
   
       public void execute() throws BuildException {
  -        if(P4View == null) {
  +        if (P4View == null) {
               throw new BuildException("No view specified to reopen");
           }
  -        execP4Command("-s reopen -c "+toChange+" "+P4View, new SimpleP4OutputHandler(this));
  +        execP4Command("-s reopen -c " + toChange + " " + P4View, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.4       +7 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java
  
  Index: P4Revert.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Revert.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- P4Revert.java	8 Jan 2002 22:50:21 -0000	1.3
  +++ P4Revert.java	9 Jan 2002 00:03:22 -0000	1.4
  @@ -64,13 +64,14 @@
    *
    * @author <A HREF="mailto:leslie.hughes@rubus.com">Les Hughes</A>
    */
  +
   public class P4Revert extends P4Base {
   
       private String revertChange = null;
       private boolean onlyUnchanged = false;
   
       public void setChange(String revertChange) throws BuildException {
  -        if(revertChange == null && !revertChange.equals("")) {
  +        if (revertChange == null && !revertChange.equals("")) {
               throw new BuildException("P4Revert: change cannot be null or empty");
           }
   
  @@ -78,7 +79,7 @@
   
       }
   
  -    public void setRevertOnlyUnchanged(boolean onlyUnchanged)  {
  +    public void setRevertOnlyUnchanged(boolean onlyUnchanged) {
           this.onlyUnchanged = onlyUnchanged;
       }
   
  @@ -92,14 +93,14 @@
            * The whole process also accepts a p4 filespec
            */
           String p4cmd = "-s revert";
  -        if(onlyUnchanged) {
  -          p4cmd+=" -a";
  +        if (onlyUnchanged) {
  +            p4cmd += " -a";
           }
   
           if (revertChange != null) {
  -          p4cmd += " -c "+revertChange;
  +            p4cmd += " -c " + revertChange;
           }
   
  -        execP4Command(p4cmd+" "+P4View, new SimpleP4OutputHandler(this));
  +        execP4Command(p4cmd + " " + P4View, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.5       +7 -6      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java
  
  Index: P4Submit.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Submit.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- P4Submit.java	27 Nov 2001 18:04:53 -0000	1.4
  +++ P4Submit.java	9 Jan 2002 00:03:22 -0000	1.5
  @@ -81,14 +81,15 @@
       public void setChange(String change) {
           this.change = change;
       }
  +
       public void execute() throws BuildException {
  -        if(change != null) {
  -            execP4Command("submit -c "+change,
  -                new P4HandlerAdapter() {
  -                    public void process(String line) {
  -                        log(line, Project.MSG_VERBOSE);
  +        if (change != null) {
  +            execP4Command("submit -c " + change,
  +                    new P4HandlerAdapter() {
  +                        public void process(String line) {
  +                            log(line, Project.MSG_VERBOSE);
  +                        }
                       }
  -                }
               );
   
           } else {
  
  
  
  1.5       +17 -17    jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java
  
  Index: P4Sync.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/P4Sync.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- P4Sync.java	8 Jan 2002 22:49:56 -0000	1.4
  +++ P4Sync.java	9 Jan 2002 00:03:22 -0000	1.5
  @@ -62,7 +62,7 @@
   import org.apache.tools.ant.Project;
   
   /** P4Sync  - synchronise client space to a perforce depot view.
  - *  The API allows additional functionality of the "p4 sync" command 
  + *  The API allows additional functionality of the "p4 sync" command
    * (such as "p4 sync -f //...#have" or other exotic invocations).</P>
    *
    * <b>Example Usage:</b>
  @@ -83,9 +83,9 @@
       String label;
       private String syncCmd = "";
   
  -    public void setLabel(String label) throws BuildException { 
  -        if(label == null && !label.equals("")) {
  -                throw new BuildException("P4Sync: Labels cannot be Null or Empty");
  +    public void setLabel(String label) throws BuildException {
  +        if (label == null && !label.equals("")) {
  +            throw new BuildException("P4Sync: Labels cannot be Null or Empty");
           }
   
           this.label = label;
  @@ -94,27 +94,27 @@
   
   
       public void setForce(String force) throws BuildException {
  -        if(force == null && !label.equals("")) {
  -                throw new BuildException("P4Sync: If you want to force, set force to non-null
string!");
  +        if (force == null && !label.equals("")) {
  +            throw new BuildException("P4Sync: If you want to force, set force to non-null
string!");
           }
  -            P4CmdOpts = "-f";
  -        }
  -        
  +        P4CmdOpts = "-f";
  +    }
  +
       public void execute() throws BuildException {
   
   
           if (P4View != null) {
  -                syncCmd = P4View;
  +            syncCmd = P4View;
  +        }
  +
  +
  +        if (label != null && !label.equals("")) {
  +            syncCmd = syncCmd + "@" + label;
           }
   
  -        
  -        if(label != null && !label.equals("")) {
  -                syncCmd = syncCmd + "@" + label;
  -        } 
   
  -        
  -        log("Execing sync "+P4CmdOpts+" "+syncCmd, Project.MSG_VERBOSE);
  +        log("Execing sync " + P4CmdOpts + " " + syncCmd, Project.MSG_VERBOSE);
   
  -        execP4Command("-s sync "+P4CmdOpts+" "+syncCmd, new SimpleP4OutputHandler(this));
  +        execP4Command("-s sync " + P4CmdOpts + " " + syncCmd, new SimpleP4OutputHandler(this));
       }
   }
  
  
  
  1.6       +5 -4      jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/SimpleP4OutputHandler.java
  
  Index: SimpleP4OutputHandler.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/perforce/SimpleP4OutputHandler.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- SimpleP4OutputHandler.java	8 Jan 2002 19:59:45 -0000	1.5
  +++ SimpleP4OutputHandler.java	9 Jan 2002 00:03:22 -0000	1.6
  @@ -64,13 +64,14 @@
   public class SimpleP4OutputHandler extends P4HandlerAdapter {
   
       P4Base parent;
  +
       public SimpleP4OutputHandler(P4Base parent) {
           this.parent = parent;
       }
   
       public void process(String line) throws BuildException {
  -        if(parent.util.match("/^exit/",line)) {
  -          return;
  +        if (parent.util.match("/^exit/", line)) {
  +            return;
           }
   
           //Throw exception on errors (except up-to-date)
  @@ -83,12 +84,12 @@
           //which is already open for edit.....
           //Just look for error: - catches most things....
   
  -        if(parent.util.match("/error:/", line) && !parent.util.match("/up-to-date/",
line)) {
  +        if (parent.util.match("/error:/", line) && !parent.util.match("/up-to-date/",
line)) {
               throw new BuildException(line);
   
           }
   
  -        parent.log(parent.util.substitute("s/^.*: //",line), Project.MSG_INFO);
  +        parent.log(parent.util.substitute("s/^.*: //", line), Project.MSG_INFO);
   
       }
   }
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message