maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r349435 [2/3] - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/ main/java/org/apache/maven/scm/provider/perforce/command/ main/java/org/apache/maven/scm/provider/per...
Date Mon, 28 Nov 2005 17:02:13 GMT
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,106 @@
+package org.apache.maven.scm.provider.perforce.command.remove;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.remove.AbstractRemoveCommand;
+import org.apache.maven.scm.command.remove.RemoveScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceRemoveCommand
+    extends AbstractRemoveCommand
+    implements PerforceCommand
+{
+
+    protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet files, String message )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
+        PerforceRemoveConsumer consumer = new PerforceRemoveConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        return new RemoveScmResult( cl.toString(), consumer.getRemovals() );
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                ScmFileSet files )
+    {
+        Commandline command = PerforceScmProvider.createP4Command(repo, workingDirectory);
+
+        command.createArgument().setValue( "delete" );
+
+        try
+        {
+            String candir = workingDirectory.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // I want to use relative paths to delete files to make testing
+                // simpler.
+                // Otherwise the absolute path will be different on everyone's
+                // machine
+                // and testing will be a little more painful.
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                command.createArgument().setValue( file.getName() );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,93 @@
+package org.apache.maven.scm.provider.perforce.command.remove;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceRemoveConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+    private static final String FILE_BEGIN_TOKEN = "//";
+
+    private static final String PATTERN = "^([^#]+)#\\d+ - (.*)";
+
+    private List removals = new ArrayList();
+
+    private RE revisionRegexp;
+
+    private boolean error = false;
+
+    public PerforceRemoveConsumer()
+    {
+        try
+        {
+            revisionRegexp = new RE( PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    public List getRemovals()
+    {
+        return removals;
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( line.startsWith( "... " ) )
+        {
+            return;
+        }
+
+        if ( !line.startsWith( FILE_BEGIN_TOKEN ) )
+        {
+            error( line );
+        }
+
+        if ( !revisionRegexp.match( line ) )
+        {
+            error( line );
+        }
+
+        removals.add( revisionRegexp.getParen( 1 ) );
+    }
+
+    private void error( String line )
+    {
+        error = true;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return !error;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/remove/PerforceRemoveConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,128 @@
+package org.apache.maven.scm.provider.perforce.command.status;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.status.AbstractStatusCommand;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.command.PerforceVerbMapper;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.regexp.RE;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceStatusCommand
+    extends AbstractStatusCommand
+    implements PerforceCommand
+{
+
+    protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet files )
+        throws ScmException
+    {
+        PerforceScmProviderRepository prepo = (PerforceScmProviderRepository) repo;
+        PerforceStatusConsumer consumer = new PerforceStatusConsumer();
+        Commandline command = readOpened( prepo, files, consumer );
+
+        if ( consumer.isSuccess() )
+        {
+            List scmfiles = createResults( prepo.getPath(), consumer );
+            return new StatusScmResult( command.toString(), scmfiles );
+        }
+        else
+        {
+            return new StatusScmResult( command.toString(), "Unable to get status", consumer
+                .getOutput(), consumer.isSuccess() );
+        }
+    }
+
+    public static List createResults( String repoPath, PerforceStatusConsumer consumer )
+    {
+        List results = new ArrayList();
+        List files = consumer.getDepotfiles();
+        String root = repoPath;
+        RE re = new RE( "([^#]+)#\\d+ - ([^ ]+) .*" );
+        for ( Iterator it = files.iterator(); it.hasNext(); )
+        {
+            String filepath = (String) it.next();
+            if ( !re.match( filepath ) )
+            {
+                System.err.println( "Skipping " + filepath );
+                continue;
+            }
+            String path = re.getParen( 1 );
+            String verb = re.getParen( 2 );
+
+            ScmFile scmfile = new ScmFile( path.substring( root.length() + 1 ).trim(), PerforceVerbMapper
+                .toStatus( verb ) );
+            results.add( scmfile );
+        }
+        return results;
+    }
+
+    private Commandline readOpened( PerforceScmProviderRepository prepo, ScmFileSet files, PerforceStatusConsumer consumer )
+    {
+        Commandline cl = createOpenedCommandLine( prepo, files.getBasedir() );
+        try
+        {
+            getLogger().info("Executing " + cl.toString());
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                getLogger().info("Reading " + line);
+                consumer.consumeLine( line );
+            }
+            br.close();
+        }
+        catch ( CommandLineException e )
+        {
+            getLogger().error(e);
+        }
+        catch ( IOException e )
+        {
+            getLogger().error(e);
+        }
+        return cl;
+    }
+
+    public static Commandline createOpenedCommandLine( PerforceScmProviderRepository repo, File workingDirectory )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+        command.createArgument().setValue( "opened" );
+        command.createArgument().setValue( repo.getPath() + "/..." );
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,81 @@
+package org.apache.maven.scm.provider.perforce.command.status;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceStatusConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+    static final int STATE_FILES = 1;
+
+    static final int STATE_ERROR = 2;
+
+    private int currentState = STATE_FILES;
+
+    private List depotfiles = new ArrayList();
+
+    public void consumeLine( String line )
+    {
+        if (line.indexOf("not opened") != -1) {
+            // User has no files open at all, just return 
+            return;
+        }
+        switch ( currentState )
+        {
+            /*
+//depot/sandbox/mperham/scm-test/Foo.java#1 - add default change (text)
+//depot/sandbox/mperham/scm-test/bar/Bar.xml#1 - add default change (text)
+             */
+            case STATE_FILES:
+                if ( line.startsWith( "//" ) )
+                {
+                    depotfiles.add( line.trim() );
+                }
+                break;
+            default:
+                error( line );
+                break;
+        }
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState != STATE_ERROR;
+    }
+
+    public List getDepotfiles()
+    {
+        return depotfiles;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/status/PerforceStatusConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,180 @@
+package org.apache.maven.scm.provider.perforce.command.tag;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.tag.AbstractTagCommand;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceTagCommand
+    extends AbstractTagCommand
+    implements PerforceCommand
+{
+
+    protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet files, String tag )
+        throws ScmException
+    {
+        PerforceTagConsumer consumer = new PerforceTagConsumer();
+        if ( consumer.isSuccess() )
+        {
+            createLabel( repo, files, tag, consumer );
+        }
+        if ( consumer.isSuccess() )
+        {
+            syncLabel( repo, files, tag, consumer );
+        }
+
+        if ( consumer.isSuccess() )
+        {
+            // TODO Unclear what to pass as the first arg
+            return new TagScmResult( "p4 label -i", consumer.getTagged() );
+        }
+        else
+        {
+            // TODO Unclear what to pass as the first arg
+            return new TagScmResult( "p4 label -i", "Tag failed", consumer.getOutput(), false );
+        }
+    }
+
+    private void syncLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer )
+    {
+        Commandline cl = createLabelCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files, tag );
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+    private void createLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer )
+    {
+        Commandline cl = createLabelCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files, tag );
+        try
+        {
+            Process proc = cl.execute();
+            DataOutputStream dos = new DataOutputStream( proc.getOutputStream() );
+            dos.writeUTF( createLabelSpecification( (PerforceScmProviderRepository) repo, files, tag ) );
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+    }
+
+    public static Commandline createLabelCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                     ScmFileSet files, String tag )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "label" );
+        command.createArgument().setValue( "-i" );
+        return command;
+    }
+
+    public static Commandline createLabelsyncCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                         ScmFileSet files, String tag )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "labelsync" );
+        command.createArgument().setValue( "-l" );
+        command.createArgument().setValue( tag );
+
+        try
+        {
+            String candir = workingDirectory.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // I want to use relative paths to add files to make testing
+                // simpler.
+                // Otherwise the absolute path will be different on everyone's
+                // machine
+                // and testing will be a little more painful.
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                command.createArgument().setValue( file.getName() );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return command;
+    }
+
+    private static final String NEWLINE = "\r\n";
+
+    /*
+     * Label: foo-label 
+     * View: //depot/path/to/repos/...
+     */
+    public static String createLabelSpecification( PerforceScmProviderRepository repo, ScmFileSet files, String tag )
+    {
+        StringBuffer buf = new StringBuffer();
+        buf.append( "Label: " ).append( tag ).append( NEWLINE );
+        buf.append( "View: " ).append( repo.getPath() ).append( "/..." ).append( NEWLINE );
+        return buf.toString();
+    }
+
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,127 @@
+package org.apache.maven.scm.provider.perforce.command.tag;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceTagConsumer extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+
+    private static final String LABEL_PATTERN = "^Label ([^ ]+) saved.$";
+
+    private static final String SYNC_PATTERN = "^([^#]+)#\\d+ - (.*)";
+
+    public static final int STATE_CREATE = 1;
+
+    public static final int STATE_SYNC = 2;
+
+    public static final int STATE_ERROR = 3;
+
+    private int currentState = STATE_CREATE;
+
+    private List tagged = new ArrayList();
+
+    private RE syncRegexp;
+
+    public PerforceTagConsumer()
+    {
+        try
+        {
+            syncRegexp = new RE( SYNC_PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    /**
+     * Return a list of Strings formatted like:
+     * 
+     * <pre>
+     * //depot/modules/cordoba/runtime-ear/pom.xml
+     * //depot/modules/cordoba/runtime-ear/.runtime
+     * 
+     * 
+     * </pre>
+     */
+    public List getTagged()
+    {
+        return tagged;
+    }
+
+    /*
+     * We consume the output from 'p4 label -i' and 'p4 labelsync -l <tag>
+     * <files...>'
+     */
+    /*
+     * Label maven-scm-test saved.
+     */
+    /*
+     * //depot/modules/cordoba/runtime-ear/pom.xml#4 - added
+     * //depot/modules/cordoba/runtime-ear/.runtime#1 - added
+     */
+    public void consumeLine( String line )
+    {
+        switch ( currentState )
+        {
+            case STATE_CREATE:
+                if ( !new RE( LABEL_PATTERN ).match( line ) )
+                {
+                    error( line );
+                    break;
+                }
+                currentState = STATE_SYNC;
+                break;
+            case STATE_SYNC:
+                if ( !syncRegexp.match( line ) )
+                {
+                    error( line );
+                    break;
+                }
+                tagged.add( syncRegexp.getParen( 1 ) );
+                break;
+            default:
+                error( line );
+                break;
+        }
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_SYNC;
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,113 @@
+package org.apache.maven.scm.provider.perforce.command.unedit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.unedit.AbstractUnEditCommand;
+import org.apache.maven.scm.command.unedit.UnEditScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceUnEditCommand
+    extends AbstractUnEditCommand
+    implements PerforceCommand
+{
+
+    protected ScmResult executeUnEditCommand( ScmProviderRepository repo, ScmFileSet files )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files );
+        PerforceUnEditConsumer consumer = new PerforceUnEditConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        if ( consumer.isSuccess() )
+        {
+            return new UnEditScmResult( cl.toString(), consumer.getEdits() );
+        }
+        else
+        {
+            return new UnEditScmResult( cl.toString(), "Unable to revert", consumer.getOutput(), consumer.isSuccess() );
+        }
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory,
+                                                ScmFileSet files )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "revert" );
+
+        try
+        {
+            String candir = workingDirectory.getCanonicalPath();
+            File[] fs = files.getFiles();
+            for ( int i = 0; i < fs.length; i++ )
+            {
+                File file = fs[i];
+                // I want to use relative paths to add files to make testing
+                // simpler.
+                // Otherwise the absolute path will be different on everyone's
+                // machine
+                // and testing will be a little more painful.
+                String canfile = file.getCanonicalPath();
+                if ( canfile.startsWith( candir ) )
+                {
+                    canfile = canfile.substring( candir.length() + 1 );
+                }
+                command.createArgument().setValue( file.getName() );
+            }
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+        return command;
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,89 @@
+package org.apache.maven.scm.provider.perforce.command.unedit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceUnEditConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+
+    private static final String PATTERN = "^([^#]+)#\\d+ - (.*)";
+
+    private static final String FILE_BEGIN_TOKEN = "//";
+
+    private static final int STATE_NORMAL = 1;
+
+    private static final int STATE_ERROR = 2;
+
+    private int currentState = STATE_NORMAL;
+
+    private List edits = new ArrayList();
+
+    private RE revisionRegexp;
+
+    public PerforceUnEditConsumer()
+    {
+        try
+        {
+            revisionRegexp = new RE( PATTERN );
+        }
+        catch ( RESyntaxException ignored )
+        {
+            ignored.printStackTrace();
+        }
+    }
+
+    public List getEdits()
+    {
+        return edits;
+    }
+
+    public void consumeLine( String line )
+    {
+        if ( currentState != STATE_ERROR && revisionRegexp.match( line ) )
+        {
+            edits.add( revisionRegexp.getParen( 1 ) );
+            return;
+        }
+
+        error( line );
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_NORMAL;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/unedit/PerforceUnEditConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,98 @@
+package org.apache.maven.scm.provider.perforce.command.update;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.changelog.ChangeLogCommand;
+import org.apache.maven.scm.command.update.AbstractUpdateCommand;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.command.changelog.PerforceChangeLogCommand;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogCommand.java 264804 2005-08-30 16:09:04Z
+ *          evenisse $
+ */
+public class PerforceUpdateCommand
+    extends AbstractUpdateCommand
+    implements PerforceCommand
+{
+
+    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet files, String tag )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), tag );
+        PerforceUpdateConsumer consumer = new PerforceUpdateConsumer();
+        try
+        {
+            Process proc = cl.execute();
+            BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream() ) );
+            String line = null;
+            while ( ( line = br.readLine() ) != null )
+            {
+                consumer.consumeLine( line );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            e.printStackTrace();
+        }
+        catch ( IOException e )
+        {
+            e.printStackTrace();
+        }
+
+        if ( consumer.isSuccess() )
+        {
+            return new UpdateScmResult( cl.toString(), consumer.getUpdates() );
+        }
+        else
+        {
+            return new UpdateScmResult( cl.toString(), "Unable to sync", consumer.getOutput(), consumer.isSuccess() );
+        }
+    }
+
+    public static Commandline createCommandLine( PerforceScmProviderRepository repo, File workingDirectory, String tag )
+    {
+        Commandline command = PerforceScmProvider.createP4Command( repo, workingDirectory );
+
+        command.createArgument().setValue( "sync" );
+        // I'm unclear whether we should be
+        // sync'ing each file individually to the label or just sync the
+        // entire contents of the workingDir. I'm going to assume the
+        // latter until the exact semantics are clearer.
+        command.createArgument().setValue( "..." + ( tag != null ? "@" + tag : "" ) );
+        return command;
+    }
+
+    protected ChangeLogCommand getChangeLogCommand()
+    {
+        return new PerforceChangeLogCommand();
+    }
+}
\ No newline at end of file

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,76 @@
+package org.apache.maven.scm.provider.perforce.command.update;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.provider.perforce.command.AbstractPerforceConsumer;
+import org.apache.regexp.RE;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author Mike Perham
+ * @version $Id: PerforceChangeLogConsumer.java 331276 2005-11-07 15:04:54Z
+ *          evenisse $
+ */
+public class PerforceUpdateConsumer
+    extends AbstractPerforceConsumer
+    implements StreamConsumer
+{
+    private static final String UPDATE_PATTERN = "^([^#]+)#\\d+ - (.*)";
+
+    public static final int STATE_NORMAL = 1;
+
+    public static final int STATE_ERROR = 2;
+
+    private int currentState = STATE_NORMAL;
+
+    private List updates = new ArrayList();
+
+    private RE regexp = new RE( UPDATE_PATTERN );
+
+    public void consumeLine( String line )
+    {
+        if ( currentState != STATE_ERROR && regexp.match( line ) )
+        {
+            // TODO Need to flesh out the 
+            updates.add( new ScmFile( regexp.getParen( 1 ), ScmFileStatus.UNKNOWN ) );
+            return;
+        }
+
+        error( line );
+    }
+
+    private void error( String line )
+    {
+        currentState = STATE_ERROR;
+        output.println( line );
+    }
+
+    public boolean isSuccess()
+    {
+        return currentState == STATE_NORMAL;
+    }
+
+    public List getUpdates()
+    {
+        return updates;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/update/PerforceUpdateConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.perforce.command.add;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PerforceAddCommandTest
+    extends ScmTestCase
+{
+    public void testGetCommandLine()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce://depot/projects/pathname", "p4 add foo.xml bar.xml" );
+    }
+
+    public void testGetCommandLineWithHost()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:a:username@//depot/projects/pathname",
+                         "p4 -H a -u username add foo.xml bar.xml" );
+    }
+
+    public void testGetCommandLineWithHostAndPort()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:myhost:1234:username@//depot/projects/pathname",
+                         "p4 -H myhost:1234 -u username add foo.xml bar.xml" );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String scmUrl, String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/perforce-add-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File("."), new File[] { new File("foo.xml"), new File("bar.xml") } );
+        Commandline cl = PerforceAddCommand.createCommandLine( svnRepository, workingDirectory, files );
+
+        assertEquals( commandLine, cl.toString() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,56 @@
+package org.apache.maven.scm.provider.perforce.command.add;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import org.apache.maven.scm.ScmTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PerforceAddConsumerTest
+    extends ScmTestCase
+{
+    public void testParse()
+        throws Exception
+    {
+        File testFile = getTestFile( "src/test/resources/perforce/addlog.txt" );
+
+        PerforceAddConsumer consumer = new PerforceAddConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
+        String s = in.readLine();
+        while ( s != null )
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        List adds = consumer.getAdditions();
+        assertEquals( "Wrong number of entries returned", 2, adds.size() );
+        String entry = (String) adds.get( 0 );
+        assertTrue( entry.startsWith( "//" ) );
+        assertTrue( entry.endsWith( "foo.xml" ) );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/add/PerforceAddConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,83 @@
+package org.apache.maven.scm.provider.perforce.command.checkin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PerforceCheckInCommandTest
+    extends ScmTestCase
+{
+    public void testGetCommandLine()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce://depot/projects/pathname", "p4 submit -i" );
+    }
+
+    public void testGetCommandLineWithHost()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:a:username@//depot/projects/pathname",
+                         "p4 -H a -u username submit -i" );
+    }
+
+    public void testGetCommandLineWithHostAndPort()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:myhost:1234:username@//depot/projects/pathname",
+                         "p4 -H myhost:1234 -u username submit -i" );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String scmUrl, String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/perforce-checkin-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File("."), new File[] { new File("foo.xml"), new File("bar.xml") } );
+        Commandline cl = PerforceCheckInCommand.createCommandLine( svnRepository, workingDirectory, files );
+
+        assertEquals( commandLine, cl.toString() );
+        
+        String change = PerforceCheckInCommand.createChangeListSpecification( svnRepository, files, "Test checkin" );
+        assertContains( change, "//depot/projects/pathname/foo.xml" );
+        assertContains( change, "//depot/projects/pathname/bar.xml" );
+        assertContains( change, "Test checkin" );
+    }
+    
+    private void assertContains(String block, String element) {
+        if (block.indexOf(element) == -1) {
+            fail("Block '" + block + "' does not contain element '" + element + "'");
+        }
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,70 @@
+package org.apache.maven.scm.provider.perforce.command.checkin;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PerforceCheckInConsumerTest
+    extends ScmTestCase
+{
+    public void testGoodParse()
+        throws Exception
+    {
+        File testFile = getTestFile( "src/test/resources/perforce/checkin_good.txt" );
+
+        PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
+        String s = in.readLine();
+        while ( s != null )
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        assertTrue( consumer.getOutput(), consumer.isSuccess() );
+        assertEquals( "", consumer.getOutput() );
+    }
+
+    public void testBadParse() throws Exception {
+        File testFile = getTestFile("src/test/resources/perforce/checkin_bad.txt");
+
+        PerforceCheckInConsumer consumer = new PerforceCheckInConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader(fis) );
+        String s = in.readLine();
+        while ( s != null ) 
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        assertFalse( consumer.getOutput(), consumer.isSuccess() );
+        assertTrue( consumer.getOutput(), consumer.getOutput().length() > 0 );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkin/PerforceCheckInConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,72 @@
+package org.apache.maven.scm.provider.perforce.command.checkout;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PerforceCheckOutCommandTest
+    extends ScmTestCase
+{
+    public void testGetCommandLine()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce://depot/projects/pathname", "p4 sync ...@somelabel" );
+    }
+
+    public void testGetCommandLineWithHost()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:a:username@//depot/projects/pathname",
+                         "p4 -H a -u username sync ...@somelabel" );
+    }
+
+    public void testGetCommandLineWithHostAndPort()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce:myhost:1234:username@//depot/projects/pathname",
+                         "p4 -H myhost:1234 -u username sync ...@somelabel" );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String scmUrl, String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/perforce-checkout-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File("."), new File[] { new File("foo.xml"), new File("bar.xml") } );
+        Commandline cl = PerforceCheckOutCommand.createCommandLine( svnRepository, workingDirectory, "somelabel" );
+
+        assertEquals( commandLine, cl.toString() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,77 @@
+package org.apache.maven.scm.provider.perforce.command.checkout;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PerforceCheckOutConsumerTest
+    extends ScmTestCase
+{
+    public void testGoodParse() throws Exception
+    {
+        File testFile = getTestFile( "src/test/resources/perforce/checkout_good.txt" );
+
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
+        String s = in.readLine();
+        while ( s != null )
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        assertTrue( consumer.getOutput(), consumer.isSuccess() );
+        assertEquals( "", consumer.getOutput() );
+    }
+
+    public void testBadParse() throws Exception {
+        File testFile = getTestFile("src/test/resources/perforce/checkout_bad.txt");
+
+        PerforceCheckOutConsumer consumer = new PerforceCheckOutConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader(fis) );
+        String s = in.readLine();
+        while ( s != null ) 
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        assertFalse( consumer.getOutput(), consumer.isSuccess() );
+        assertTrue( consumer.getOutput(), consumer.getOutput().length() > 0 );
+        assertContains( consumer.getOutput(), "Invalid" );
+        assertContains( consumer.getOutput(), "somelabel" );
+    }
+
+    private void assertContains(String block, String element) {
+        if (block.indexOf(element) == -1) {
+            fail("Block '" + block + "' does not contain element '" + element + "'");
+        }
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/checkout/PerforceCheckOutConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,64 @@
+package org.apache.maven.scm.provider.perforce.command.diff;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PerforceDiffCommandTest
+    extends ScmTestCase
+{
+    public void testGetCommandLine()
+        throws Exception
+    {
+        testCommandLine( "somelabel", null, "p4 diff2 -u ...@somelabel ...@head" );
+    }
+
+    public void testGetCommandLineWithRevs()
+        throws Exception
+    {
+        testCommandLine( "somelabel", "someend", "p4 diff2 -u ...@somelabel ...@someend" );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String startRev, String endRev, String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/perforce-diff-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( "scm:perforce://depot/projects/pathname" );
+        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File("."), new File[] { new File("foo.xml"), new File("bar.xml") } );
+        Commandline cl = PerforceDiffCommand.createCommandLine( svnRepository, workingDirectory, startRev, endRev );
+
+        assertEquals( commandLine, cl.toString() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,54 @@
+package org.apache.maven.scm.provider.perforce.command.diff;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+
+import org.apache.maven.scm.ScmTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PerforceDiffConsumerTest
+    extends ScmTestCase
+{
+    public void testParse()
+        throws Exception
+    {
+        File testFile = getTestFile( "src/test/resources/perforce/difflog.txt" );
+
+        PerforceDiffConsumer consumer = new PerforceDiffConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
+        String s = in.readLine();
+        while ( s != null )
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        // Linebreak differences will fail if we try to assert
+        // the exact file length so we just use a rough approximation.
+        assertTrue( consumer.getOutput().length() > 12500 );
+        assertTrue( consumer.getOutput().length() < 13500 );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/diff/PerforceDiffConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,58 @@
+package org.apache.maven.scm.provider.perforce.command.edit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.File;
+
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id$
+ */
+public class PerforceEditCommandTest
+    extends ScmTestCase
+{
+    public void testGetCommandLine()
+        throws Exception
+    {
+        testCommandLine( "scm:perforce://depot/projects/pathname", "p4 edit foo.xml bar.xml" );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String scmUrl, String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/perforce-edit-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File("."), new File[] { new File("foo.xml"), new File("bar.xml") } );
+        Commandline cl = PerforceEditCommand.createCommandLine( svnRepository, workingDirectory, files );
+
+        assertEquals( commandLine, cl.toString() );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java?rev=349435&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java Mon Nov 28 09:01:05 2005
@@ -0,0 +1,56 @@
+package org.apache.maven.scm.provider.perforce.command.edit;
+
+/*
+ * Copyright 2001-2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import org.apache.maven.scm.ScmTestCase;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id$
+ */
+public class PerforceEditConsumerTest
+    extends ScmTestCase
+{
+    public void testParse()
+        throws Exception
+    {
+        File testFile = getTestFile( "src/test/resources/perforce/editlog.txt" );
+
+        PerforceEditConsumer consumer = new PerforceEditConsumer();
+
+        FileInputStream fis = new FileInputStream( testFile );
+        BufferedReader in = new BufferedReader( new InputStreamReader( fis ) );
+        String s = in.readLine();
+        while ( s != null )
+        {
+            consumer.consumeLine( s );
+            s = in.readLine();
+        }
+
+        List edits = consumer.getEdits();
+        assertEquals( "Wrong number of entries returned", 2, edits.size() );
+        String entry = (String) edits.get( 0 );
+        assertTrue( entry.startsWith( "//" ) );
+        assertTrue( entry.endsWith( ".classpath" ) );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditConsumerTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message