maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r373513 [1/2] - in /maven/scm/trunk/sandbox: ./ maven-scm-provider-bazaar/ maven-scm-provider-bazaar/src/ maven-scm-provider-bazaar/src/main/ maven-scm-provider-bazaar/src/main/java/ maven-scm-provider-bazaar/src/main/java/org/ maven-scm-pr...
Date Mon, 30 Jan 2006 13:45:01 GMT
Author: evenisse
Date: Mon Jan 30 05:44:37 2006
New Revision: 373513

URL: http://svn.apache.org/viewcvs?rev=373513&view=rev
Log:
[SCM-143] Add Bazaar provider

Added:
    maven/scm/trunk/sandbox/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/resources/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/resources/META-INF/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/resources/META-INF/plexus/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/resources/META-INF/plexus/components.xml   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/checkin/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommandTest.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/checkout/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommandTest.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/status/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommandTest.java   (with props)
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/update/
    maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommandTest.java   (with props)

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml Mon Jan 30 05:44:37 2006
@@ -0,0 +1,23 @@
+<project>
+  <parent>
+    <artifactId>maven-scm-providers</artifactId>
+    <groupId>org.apache.maven.scm</groupId>
+    <version>1.0-beta-3-SNAPSHOT</version>
+  </parent>
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>maven-scm-provider-bazaar</artifactId>
+  <name>Maven SCM Bazaar Provider</name>
+  <version>1.0-beta-3-SNAPSHOT</version>
+  <dependencies>
+    <dependency>
+      <groupId>regexp</groupId>
+      <artifactId>regexp</artifactId>
+      <version>1.3</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-container-default</artifactId>
+      <version>1.0-alpha-7</version>
+    </dependency>
+  </dependencies>
+</project>

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,201 @@
+package org.apache.maven.scm.provider.bazaar;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.command.remove.RemoveScmResult;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.command.update.UpdateScmResult;
+import org.apache.maven.scm.provider.AbstractScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.command.add.BazaarAddCommand;
+import org.apache.maven.scm.provider.bazaar.command.changelog.BazaarChangeLogCommand;
+import org.apache.maven.scm.provider.bazaar.command.checkin.BazaarCheckInCommand;
+import org.apache.maven.scm.provider.bazaar.command.checkout.BazaarCheckOutCommand;
+import org.apache.maven.scm.provider.bazaar.command.diff.BazaarDiffCommand;
+import org.apache.maven.scm.provider.bazaar.command.remove.BazaarRemoveCommand;
+import org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand;
+import org.apache.maven.scm.provider.bazaar.command.update.BazaarUpdateCommand;
+import org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.scm.repository.UnknownRepositoryStructure;
+
+/**
+ * Bazaar NG http://bazaar.canonical.com/ is a decentralized revision control system. <br>
+ *
+ * The main difference from a centralized revision system is <br>
+ * that it makes no distinction between the working tree and the repository.<br>
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public class BazaarScmProvider
+    extends AbstractScmProvider
+{
+
+    public ScmProviderRepository makeProviderScmRepository( String scmSpecificUrl, char delimiter )
+        throws ScmRepositoryException
+    {
+        return new BazaarScmProviderRepository( scmSpecificUrl );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#makeProviderScmRepository(java.io.File)
+     */
+    public ScmProviderRepository makeProviderScmRepository( File path )
+        throws ScmRepositoryException, UnknownRepositoryStructure
+    {
+        if ( path == null || !path.isDirectory() )
+        {
+            throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." );
+        }
+
+        File bzrDir = new File( path, ".bzr" );
+
+        if ( !bzrDir.exists() )
+        {
+            throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a bazaar directory." );
+        }
+
+        return makeProviderScmRepository( "file:///" + path.getAbsolutePath(), ':' );
+    }
+
+    public List validateScmUrl( String scmSpecificUrl, char delimiter )
+    {
+        List errorMessages = new ArrayList();
+
+        String[] checkCmd = new String[] { "check", scmSpecificUrl };
+        ScmResult result;
+        try
+        {
+            File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) );
+            result = BazaarUtils.execute( tmpDir, checkCmd );
+            errorMessages.add( result.getCommandOutput() );
+        }
+        catch ( ScmException e )
+        {
+            errorMessages.add( e.getMessage() );
+        }
+
+        return errorMessages;
+    }
+
+    public String getScmType()
+    {
+        return "bazaar";
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#add(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public AddScmResult add( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarAddCommand command = new BazaarAddCommand();
+
+        command.setLogger( getLogger() );
+
+        return (AddScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#changelog(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public ChangeLogScmResult changelog( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarChangeLogCommand command = new BazaarChangeLogCommand();
+
+        command.setLogger( getLogger() );
+
+        return (ChangeLogScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#checkin(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public CheckInScmResult checkin( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarCheckInCommand command = new BazaarCheckInCommand();
+
+        command.setLogger( getLogger() );
+
+        return (CheckInScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#checkout(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public CheckOutScmResult checkout( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarCheckOutCommand command = new BazaarCheckOutCommand();
+
+        command.setLogger( getLogger() );
+
+        return (CheckOutScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#diff(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public DiffScmResult diff( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarDiffCommand command = new BazaarDiffCommand();
+
+        command.setLogger( getLogger() );
+
+        return (DiffScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#remove(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public RemoveScmResult remove( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarRemoveCommand command = new BazaarRemoveCommand();
+
+        command.setLogger( getLogger() );
+
+        return (RemoveScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#status(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public StatusScmResult status( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarStatusCommand command = new BazaarStatusCommand();
+
+        command.setLogger( getLogger() );
+
+        return (StatusScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+
+    /**
+     * @see org.apache.maven.scm.provider.AbstractScmProvider#update(org.apache.maven.scm.repository.ScmRepository, org.apache.maven.scm.ScmFileSet, org.apache.maven.scm.CommandParameters)
+     */
+    public UpdateScmResult update( ScmRepository repository, ScmFileSet fileSet, CommandParameters parameters )
+        throws ScmException
+    {
+        BazaarUpdateCommand command = new BazaarUpdateCommand();
+
+        command.setLogger( getLogger() );
+
+        return (UpdateScmResult) command.execute( repository.getProviderRepository(), fileSet, parameters );
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,155 @@
+package org.apache.maven.scm.provider.bazaar;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
+
+/**
+ * Common code for executing bazaar commands.
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public class BazaarUtils
+{
+
+    /** Map between command  and its valid exitcodes */
+    private static final Map exitCodeMap = new HashMap();
+
+    /** Defualt exit codes for entries not in exitCodeMap */
+    private static final List defaultExitCodes = new ArrayList();
+
+    /** Setup exit codes*/
+    static
+    {
+        defaultExitCodes.add( new Integer( 0 ) );
+
+        //Diff is different
+        List diffExitCodes = new ArrayList();
+        diffExitCodes.add( new Integer( 0 ) ); //No difference
+        diffExitCodes.add( new Integer( 1 ) ); //Difference exisits
+        exitCodeMap.put( BazaarCommand.DIFF_CMD, diffExitCodes );
+    }
+
+    public static ScmResult execute( StreamConsumer consumer, ScmLogger logger, File workingDir, String[] cmdAndArgs )
+        throws ScmException
+    {
+        Commandline cmd = new Commandline();
+        cmd.setExecutable( BazaarCommand.EXEC );
+        cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
+        cmd.addArguments( cmdAndArgs );
+
+        if ( !workingDir.exists() )
+        {
+            boolean success = workingDir.mkdirs();
+            if ( !success )
+            {
+                throw new ScmException( "Working directory did not exist and it couldn't be created: " + workingDir );
+            }
+        }
+
+        logger.info( "Executing: " + cmd );
+        logger.info( "Working directory: " + workingDir.getAbsolutePath() );
+
+        final int exitCode;
+        StringStreamConsumer stderr = new StringStreamConsumer();
+        try
+        {
+            exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, stderr );
+        }
+        catch ( CommandLineException ex )
+        {
+            throw new ScmException( "Command could not be executed: " + cmd, ex );
+        }
+
+        List exitCodes = exitCodeMap.containsKey( cmdAndArgs[0] ) ? (List) exitCodeMap.get( cmdAndArgs[0] )
+                                                                 : defaultExitCodes;
+        boolean success = exitCodes.contains( new Integer( exitCode ) );
+
+        return new ScmResult( cmd.toString(), "Execution of bazaar command failed", stderr.getOutput(), success );
+    }
+
+    public static ScmResult execute( File workingDir, String[] cmdAndArgs )
+        throws ScmException
+    {
+        return execute( new StringStreamConsumer(), new DefaultLog(), workingDir, cmdAndArgs );
+    }
+
+    public static String[] expandCommandLine( String[] cmdAndArgs, ScmFileSet additionalFiles )
+    {
+        File[] files = additionalFiles.getFiles();
+        String[] cmd = new String[files.length + cmdAndArgs.length];
+
+        // Copy command into array
+        System.arraycopy( cmdAndArgs, 0, cmd, 0, cmdAndArgs.length );
+
+        // Add files as additional parameter into the array
+        for ( int i = 0; i < files.length; i++ )
+        {
+            String file = files[i].getPath().replace( '\\', File.separatorChar );
+            cmd[i + cmdAndArgs.length] = file;
+        }
+
+        return cmd;
+    }
+
+    public static int getCurrentRevisionNumber( ScmLogger logger, File workingDir )
+        throws ScmException
+    {
+
+        String[] revCmd = new String[] { BazaarCommand.REVNO_CMD };
+        BazaarRevNoConsumer consumer = new BazaarRevNoConsumer( logger );
+        BazaarUtils.execute( consumer, logger, workingDir, revCmd );
+
+        return consumer.getCurrentRevisionNumber();
+    }
+
+    /**
+     * Get current (working) revision.
+     *
+     * Resolves revision to the last integer found in the command output.
+     */
+    private static class BazaarRevNoConsumer
+        extends BazaarConsumer
+    {
+
+        private int revNo;
+
+        BazaarRevNoConsumer( ScmLogger logger )
+        {
+            super( logger );
+        }
+
+        public void doConsume( ScmFileStatus status, String line )
+        {
+            try
+            {
+                revNo = Integer.valueOf( line ).intValue();
+            }
+            catch ( NumberFormatException e )
+            {
+                // ignore
+            }
+        }
+
+        int getCurrentRevisionNumber()
+        {
+            return revNo;
+        }
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,62 @@
+package org.apache.maven.scm.provider.bazaar.command;
+
+import org.apache.maven.scm.command.Command;
+
+/**
+ * Available/Used bazaar commands.
+ *
+ * These commands does not necessarily correspont to the SCM API.
+ * Eg. "check in" is translated to be "commit" and "push".
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public interface BazaarCommand
+    extends Command
+{
+    /** Executable for Bazaar */
+    public static final String EXEC = "bzr";
+
+    /** Use to create an empty branch or before importing an existing project */
+    public static final String INIT_CMD = "init";
+
+    /** Default recursive. Common option: --dry-run and --no-recursive */
+    public static final String ADD_CMD = "add";
+
+    /** Reports the following states: added, removed, modified, unchanged, unknown */
+    public static final String STATUS_CMD = "status";
+
+    /** Make a file unversioned */
+    public static final String REMOVE_CMD = "remove";
+
+    /** Create a new copy of a branch. Alias get or clone */
+    public static final String BRANCH_CMD = "branch";
+
+    /** Commit changes into a new revision */
+    public static final String COMMIT_CMD = "commit";
+
+    /** Pull any changes from another branch into the current one */
+    public static final String PULL_CMD = "pull";
+
+    /** Show log of this branch Common option: --revision */
+    public static final String LOG_CMD = "log";
+
+    /** Show differences in workingtree. Common option: --revision */
+    public static final String DIFF_CMD = "diff";
+
+    /** Push this branch into another branch */
+    public static final String PUSH_CMD = "push";
+
+    /** Show current revision number */
+    public static final String REVNO_CMD = "revno";
+
+    /** Show inventory of the current working copy or a revision */
+    public static final String INVENTORY_CMD = "inventory";
+
+    public static final String NO_RECURSE_OPTION = "--no-recurse";
+
+    public static final String MESSAGE_OPTION = "--message";
+
+    public static final String REVISION_OPTION = "--revision";
+
+    public static final String VERBOSE_OPTION = "--verbose";
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,115 @@
+package org.apache.maven.scm.provider.bazaar.command;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * Base consumer to do common parsing for all bazaar commands.
+ * <p>
+ * More spesific: log line on debug, get file status
+ * and detect warnings from bazaar
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public class BazaarConsumer
+    implements StreamConsumer
+{
+
+    /** A list of known keywords from bazaar */
+    private static final Map identifiers = new HashMap();
+
+    /** A list of known message prefixes from bazaar */
+    private static final Map messages = new HashMap();
+
+    static
+    {
+        identifiers.put( "added".intern(), ScmFileStatus.ADDED );
+        identifiers.put( "unknown".intern(), ScmFileStatus.UNKNOWN );
+        identifiers.put( "modified".intern(), ScmFileStatus.MODIFIED );
+        identifiers.put( "removed".intern(), ScmFileStatus.DELETED );
+        identifiers.put( "renamed".intern(), ScmFileStatus.MODIFIED );
+        messages.put( "bzr: WARNING:", "WARNING" );
+        messages.put( "bzr: ERROR:", "ERROR" );
+    }
+
+    /** Shared logger with all consumer implementations */
+    protected final ScmLogger logger;
+
+    public BazaarConsumer( ScmLogger logger )
+    {
+        this.logger = logger;
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+        //override this
+    }
+
+    public void consumeLine( String line )
+    {
+        logger.debug( line );
+        String trimmedLine = line.trim();
+
+        String statusStr = processInputForKnownIdentifiers( trimmedLine );
+
+        //If its not a status report - then maybe its a message?
+        if ( statusStr == null )
+        {
+            boolean isMessage = processInputForKnownMessages( trimmedLine );
+            //If it is then its already processed and we can ignore futher processing
+            if ( isMessage )
+            {
+                return;
+            }
+        }
+        else
+        {
+            //Strip away identifier
+            trimmedLine = trimmedLine.substring( statusStr.length() );
+            trimmedLine = trimmedLine.trim(); //one or more spaces
+        }
+
+        ScmFileStatus status = statusStr != null ? ( (ScmFileStatus) identifiers.get( statusStr.intern() ) ) : null;
+        doConsume( status, trimmedLine );
+    }
+
+    private static String processInputForKnownIdentifiers( String line )
+    {
+        for ( Iterator it = identifiers.keySet().iterator(); it.hasNext(); )
+        {
+            String id = (String) it.next();
+            if ( line.startsWith( id ) )
+            {
+                return id;
+            }
+        }
+        return null;
+    }
+
+    private boolean processInputForKnownMessages( String line )
+    {
+        for ( Iterator it = messages.keySet().iterator(); it.hasNext(); )
+        {
+            String prefix = (String) it.next();
+            if ( line.startsWith( prefix ) )
+            {
+                String message = line.substring( prefix.length() );
+                if ( messages.get( prefix ).equals( "WARNING" ) )
+                {
+                    logger.warn( message );
+                }
+                else
+                {
+                    logger.error( message );
+                }
+                return true;
+            }
+        }
+        return false;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,52 @@
+package org.apache.maven.scm.provider.bazaar.command.add;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.add.AbstractAddCommand;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+
+/**
+ * Add no recursive.
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public class BazaarAddCommand
+    extends AbstractAddCommand
+    implements BazaarCommand
+{
+    protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
+                                          boolean binary )
+        throws ScmException
+    {
+        String[] addCmd = new String[] { ADD_CMD, NO_RECURSE_OPTION };
+        addCmd = BazaarUtils.expandCommandLine( addCmd, fileSet );
+
+        File workingDir = fileSet.getBasedir();
+        BazaarAddConsumer consumer = new BazaarAddConsumer( getLogger(), workingDir );
+        ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, addCmd );
+
+        return wrapResult(consumer.getAddedFiles(), result);
+    }
+
+    private AddScmResult wrapResult( List files, ScmResult baseResult )
+    {
+        AddScmResult result;
+        if ( baseResult.isSuccess() )
+        {
+            result = new AddScmResult( baseResult.getCommandLine(), files );
+        }
+        else
+        {
+            result = new AddScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(), baseResult
+                .getCommandOutput(), baseResult.isSuccess() );
+        }
+        return result;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,49 @@
+package org.apache.maven.scm.provider.bazaar.command.add;
+
+import java.io.File;
+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.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarAddConsumer
+    extends BazaarConsumer
+{
+    private final File workingDir;
+
+    private final List addedFiles = new ArrayList();
+
+    public BazaarAddConsumer( ScmLogger logger, File workingDir )
+    {
+        super( logger );
+        this.workingDir = workingDir;
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+        if ( status != null && status == ScmFileStatus.ADDED )
+        {
+            //Only include real files (not directories)
+            File tmpFile = new File( workingDir, trimmedLine );
+            if ( !tmpFile.exists() )
+            {
+                logger.warn( "Not a file: " + tmpFile + ". Ignored" );
+            }
+            else
+            {
+                ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.ADDED );
+                logger.info( scmFile.toString() );
+                addedFiles.add( scmFile );
+            }
+        }
+    }
+
+    public List getAddedFiles()
+    {
+        return addedFiles;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/add/BazaarAddConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,67 @@
+package org.apache.maven.scm.provider.bazaar.command.changelog;
+
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarChangeLogCommand
+    extends AbstractChangeLogCommand
+    implements BazaarCommand
+{
+    protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet,
+                                                         Date startDate, Date endDate, int numDays, String branch )
+        throws ScmException
+    {
+        String[] cmd = new String[] { LOG_CMD, VERBOSE_OPTION };
+        BazaarChangeLogConsumer consumer = new BazaarChangeLogConsumer( getLogger(), fileSet.getBasedir() );
+        ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(), cmd );
+
+        List logEntries = consumer.getModifications();
+        List inRange = new ArrayList();
+        startDate = startDate == null ? new Date(0) : startDate; //From 1. Jan 1970
+        endDate = endDate == null ? new Date() : endDate; //Upto now
+        if (numDays > 0) { //numDays takes precedence to start date
+            Calendar rightNow = Calendar.getInstance();
+            rightNow.add(Calendar.DATE, -numDays);
+            startDate = rightNow.getTime();
+        }
+        for (Iterator it = logEntries.iterator(); it.hasNext(); ) {
+            ChangeSet change = (ChangeSet)it.next();
+            if (startDate != null) {
+                if (!change.getDate().before(startDate) && !change.getDate().after(endDate)) {
+                    inRange.add(change);
+                }
+            }
+        }
+
+        return wrapResult( inRange, result );
+    }
+
+    private ChangeLogScmResult wrapResult( List files, ScmResult result )
+    {
+        ChangeLogScmResult diffResult;
+        if ( result.isSuccess() )
+        {
+            diffResult = new ChangeLogScmResult( result.getCommandLine(), files );
+        }
+        else
+        {
+            diffResult = new ChangeLogScmResult( result.getCommandLine(), result.getProviderMessage(), result
+                .getCommandOutput(), result.isSuccess() );
+        }
+        return diffResult;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,130 @@
+package org.apache.maven.scm.provider.bazaar.command.changelog;
+
+import java.io.File;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.ChangeFile;
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarChangeLogConsumer
+    extends BazaarConsumer
+{
+
+    private static final SimpleDateFormat BAZAAR_TIME_FORMAT = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss Z" );
+
+    private static final String START_LOG_TAG = "-----";
+
+    private static final String REVNO_TAG = "revno: ";
+
+    private static final String AUTHOR_TAG = "committer: ";
+
+    private static final String TIME_STAMP_TOKEN = "timestamp: ";
+
+    private static final String MESSAGE_TOKEN = "message:";
+
+    private static final String BRANCH_NICK_TOKEN = "branch nick: ";
+
+    private final File workingDir;
+
+    private List logEntries = new ArrayList();
+
+    private ChangeSet currentChange;
+
+    private String currentRevision;
+
+    private StringBuffer currentComment;
+
+    /** null means not parsing message nor files, UNKNOWN means parsing message */
+    private ScmFileStatus currentStatus = null;
+
+    public BazaarChangeLogConsumer( ScmLogger logger, File workingDir )
+    {
+        super( logger );
+
+        this.workingDir = workingDir;
+    }
+
+    public List getModifications()
+    {
+        return logEntries;
+    }
+
+    public void doConsume( ScmFileStatus status, String line )
+    {
+        String tmpLine = new String( line );
+
+        // Parse line
+        if ( line.startsWith( START_LOG_TAG ) )
+        {
+            currentChange = new ChangeSet();
+            logEntries.add( currentChange );
+            currentComment = new StringBuffer();
+            currentStatus = null;
+            currentRevision = "";
+        }
+        else if ( line.startsWith( REVNO_TAG ) )
+        {
+            tmpLine = line.substring( REVNO_TAG.length() );
+            tmpLine = tmpLine.trim();
+            currentRevision = tmpLine;
+        }
+        else if ( line.startsWith( AUTHOR_TAG ) )
+        {
+            tmpLine = line.substring( AUTHOR_TAG.length() );
+            tmpLine = tmpLine.trim();
+            currentChange.setAuthor( tmpLine );
+        }
+        else if ( line.startsWith( TIME_STAMP_TOKEN ) )
+        {
+            tmpLine = line.substring( TIME_STAMP_TOKEN.length() + 3 );
+            tmpLine = tmpLine.trim();
+            try
+            {
+                Date date = BAZAAR_TIME_FORMAT.parse( tmpLine );
+                currentChange.setDate( date );
+            }
+            catch ( ParseException e )
+            {
+                logger.warn( "Could not figure out of date: " + tmpLine );
+            }
+        }
+        else if ( line.startsWith( MESSAGE_TOKEN ) )
+        {
+            currentStatus = ScmFileStatus.UNKNOWN;
+        }
+        else if ( status != null )
+        {
+            currentStatus = status;
+        }
+        else if ( currentStatus == ScmFileStatus.UNKNOWN )
+        {
+            currentComment.append( line ).append( "\n" );
+        }
+        else if ( currentStatus != null )
+        {
+            tmpLine = tmpLine.trim();
+            File tmpFile = new File( workingDir, tmpLine );
+            if ( tmpFile.isFile() )
+            {
+                ChangeFile changeFile = new ChangeFile( tmpLine, currentRevision );
+                currentChange.addFile( changeFile );
+            }
+        }
+        else if ( line.startsWith( BRANCH_NICK_TOKEN ) )
+        {
+            //ignore
+        }
+        else
+        {
+            logger.warn( "Could not figure out of: " + line );
+        }
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,99 @@
+package org.apache.maven.scm.provider.bazaar.command.checkin;
+
+import java.io.File;
+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.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.command.status.StatusScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.apache.maven.scm.provider.bazaar.command.status.BazaarStatusCommand;
+import org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarCheckInCommand
+    extends AbstractCheckInCommand
+{
+
+    protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
+                                                     String tag )
+        throws ScmException
+    {
+
+        if ( !StringUtils.isEmpty( tag ) )
+        {
+            throw new ScmException( "This provider can't handle tags." );
+        }
+
+        // Get files that will be committed (if not specified in fileSet)
+        List commitedFiles = new ArrayList();
+        File[] files = fileSet.getFiles();
+        if ( files.length == 0 )
+        { //Either commit all changes
+            BazaarStatusCommand statusCmd = new BazaarStatusCommand();
+            statusCmd.setLogger( getLogger() );
+            StatusScmResult status = statusCmd.executeStatusCommand( repo, fileSet );
+            List statusFiles = status.getChangedFiles();
+            for ( Iterator it = statusFiles.iterator(); it.hasNext(); )
+            {
+                ScmFile file = (ScmFile) it.next();
+                if ( file.getStatus() == ScmFileStatus.ADDED || file.getStatus() == ScmFileStatus.DELETED
+                    || file.getStatus() == ScmFileStatus.MODIFIED )
+                {
+                    commitedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.CHECKED_IN ) );
+                }
+            }
+
+        }
+        else
+        { //Or commit spesific files
+            for ( int i = 0; i < files.length; i++ )
+            {
+                commitedFiles.add( new ScmFile(files[i].getPath(), ScmFileStatus.CHECKED_IN) );
+            }
+        }
+
+        // Commit to local branch
+        String[] commitCmd = new String[] { BazaarCommand.COMMIT_CMD, BazaarCommand.MESSAGE_OPTION, message };
+        commitCmd = BazaarUtils.expandCommandLine( commitCmd, fileSet );
+        BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), fileSet.getBasedir(), commitCmd );
+
+        // Push to parent branch if any
+        BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
+        if ( !repository.getURI().equals( fileSet.getBasedir().getAbsolutePath() ) )
+        {
+            String[] push_cmd = new String[] { BazaarCommand.PUSH_CMD, repository.getURI() };
+            ScmResult result = BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), fileSet
+                .getBasedir(), push_cmd );
+            return wrapResult( commitedFiles, result );
+        }
+
+        return new CheckInScmResult( commitCmd[0], commitedFiles );
+    }
+
+    private CheckInScmResult wrapResult( List files, ScmResult baseResult )
+    {
+        CheckInScmResult result;
+        if ( baseResult.isSuccess() )
+        {
+            result = new CheckInScmResult( baseResult.getCommandLine(), files );
+        }
+        else
+        {
+            result = new CheckInScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(), baseResult
+                .getCommandOutput(), baseResult.isSuccess() );
+        }
+        return result;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkin/BazaarCheckInCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,76 @@
+package org.apache.maven.scm.provider.bazaar.command.checkout;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.List;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarCheckOutCommand
+    extends AbstractCheckOutCommand
+    implements BazaarCommand
+{
+
+    protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
+        throws ScmException
+    {
+
+        if ( !StringUtils.isEmpty( tag ) )
+        {
+            throw new ScmException( "This provider can't handle tags." );
+        }
+
+        BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
+        String url = repository.getURI();
+
+        File checkoutDir = fileSet.getBasedir();
+        try
+        {
+            getLogger().info( "Removing " + checkoutDir );
+            FileUtils.deleteDirectory( checkoutDir );
+        }
+        catch ( IOException e )
+        {
+            throw new ScmException( "Cannot remove " + checkoutDir );
+        }
+
+        // Do the actual checkout
+        String[] checkout_cmd = new String[] { BRANCH_CMD, url, checkoutDir.getAbsolutePath() };
+        BazaarConsumer checkout_consumer = new BazaarConsumer( getLogger() );
+        BazaarUtils.execute( checkout_consumer, getLogger(), checkoutDir.getParentFile(), checkout_cmd );
+
+        // Do inventory to find list of checkedout files
+        String[] inventory_cmd = new String[] { INVENTORY_CMD };
+        BazaarCheckOutConsumer consumer = new BazaarCheckOutConsumer( getLogger(), checkoutDir );
+        ScmResult result = BazaarUtils.execute( consumer, getLogger(), checkoutDir, inventory_cmd );
+
+        return wrapResult( consumer.getCheckedOutFiles(), result );
+    }
+
+    private CheckOutScmResult wrapResult( List files, ScmResult baseResult )
+    {
+        CheckOutScmResult result;
+        if ( baseResult.isSuccess() )
+        {
+            result = new CheckOutScmResult( baseResult.getCommandLine(), files );
+        }
+        else
+        {
+            result = new CheckOutScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(), baseResult
+                .getCommandOutput(), baseResult.isSuccess() );
+        }
+        return result;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,40 @@
+package org.apache.maven.scm.provider.bazaar.command.checkout;
+
+import java.io.File;
+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.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarCheckOutConsumer
+    extends BazaarConsumer
+{
+
+    private final File workingDirectory;
+
+    private final ArrayList checkedOut = new ArrayList();
+
+    public BazaarCheckOutConsumer( ScmLogger logger, File workingDirectory )
+    {
+        super( logger );
+        this.workingDirectory = workingDirectory;
+    }
+
+    public void doConsume( ScmFileStatus status, String line )
+    {
+        File file = new File( workingDirectory, line );
+        if ( file.isFile() )
+        {
+            checkedOut.add( new ScmFile( line, ScmFileStatus.CHECKED_OUT ) );
+        }
+    }
+
+    List getCheckedOutFiles()
+    {
+        return checkedOut;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,62 @@
+package org.apache.maven.scm.provider.bazaar.command.diff;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.command.diff.AbstractDiffCommand;
+import org.apache.maven.scm.command.diff.DiffScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.codehaus.plexus.util.StringUtils;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarDiffCommand
+    extends AbstractDiffCommand
+    implements BazaarCommand
+{
+
+    protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, String startRevision,
+                                               String endRevision )
+        throws ScmException
+    {
+
+        String[] diffCmd;
+        if ( !StringUtils.isEmpty( startRevision ) )
+        {
+            String revArg = startRevision;
+            if ( !StringUtils.isEmpty( endRevision ) )
+            {
+                revArg += ".." + endRevision;
+            }
+            diffCmd = new String[] { DIFF_CMD, REVISION_OPTION, revArg };
+        }
+        else
+        {
+            diffCmd = new String[] { DIFF_CMD };
+        }
+
+        diffCmd = BazaarUtils.expandCommandLine( diffCmd, fileSet );
+        BazaarDiffConsumer consumer = new BazaarDiffConsumer( getLogger(), fileSet.getBasedir() );
+
+        ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(), diffCmd );
+
+        return wrapResult( consumer, result );
+    }
+
+    private DiffScmResult wrapResult( BazaarDiffConsumer consumer, ScmResult result )
+    {
+        DiffScmResult diffResult;
+        if ( result.isSuccess() )
+        {
+            diffResult = new DiffScmResult( result.getCommandLine(), consumer.getChangedFiles(), consumer
+                .getDifferences(), consumer.getPatch() );
+        }
+        else
+        {
+            diffResult = new DiffScmResult( result.getCommandLine(), result.getProviderMessage(), result
+                .getCommandOutput(), result.isSuccess() );
+        }
+        return diffResult;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,131 @@
+package org.apache.maven.scm.provider.bazaar.command.diff;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarDiffConsumer
+    extends BazaarConsumer
+{
+
+    private final static String MODIFIED_FILE_TOKEN = "=== modified file ";
+
+    private final static String ADDED_FILE_TOKEN = "=== added file ";
+
+    private final static String DELETED_FILE_TOKEN = "=== deleted file ";
+
+    //TODO: What is this?
+    private final static String NO_NEWLINE_TOKEN = "\\ No newline at end of file";
+
+    private final static String FROM_FILE_TOKEN = "---";
+
+    private final static String TO_FILE_TOKEN = "+++";
+
+    private final static String ADDED_LINE_TOKEN = "+";
+
+    private final static String REMOVED_LINE_TOKEN = "-";
+
+    private final static String UNCHANGED_LINE_TOKEN = " ";
+
+    private final static String RANGE_TOKEN = "@@";
+
+    private ScmLogger logger;
+
+    private File workingDirectory;
+
+    private String currentFile;
+
+    private StringBuffer currentDifference;
+
+    private List changedFiles = new ArrayList();
+
+    private Map differences = new HashMap();
+
+    private StringBuffer patch = new StringBuffer();
+
+    public BazaarDiffConsumer( ScmLogger logger, File workingDirectory )
+    {
+        super( logger );
+        this.logger = logger;
+        this.workingDirectory = workingDirectory;
+    }
+
+    public void doConsume( ScmFileStatus status, String line )
+    {
+        String tmpLine = new String( line );
+        patch.append( line ).append( "\n" );
+
+        // Parse line
+        if ( line.startsWith( MODIFIED_FILE_TOKEN ) )
+        {
+            tmpLine = line.substring( MODIFIED_FILE_TOKEN.length() );
+            tmpLine = tmpLine.trim();
+            status = ScmFileStatus.MODIFIED;
+            addChangedFile( status, line, tmpLine );
+        }
+        else if ( line.startsWith( ADDED_FILE_TOKEN ) )
+        {
+            tmpLine = line.substring( ADDED_FILE_TOKEN.length() );
+            tmpLine = tmpLine.trim();
+            status = ScmFileStatus.ADDED;
+            addChangedFile( status, line, tmpLine );
+        }
+        else if ( line.startsWith( DELETED_FILE_TOKEN ) )
+        {
+            tmpLine = line.substring( DELETED_FILE_TOKEN.length() );
+            tmpLine = tmpLine.trim();
+            status = ScmFileStatus.DELETED;
+            addChangedFile( status, line, tmpLine );
+        }
+        else if ( line.startsWith( TO_FILE_TOKEN ) || line.startsWith( FROM_FILE_TOKEN ) )
+        {
+            // ignore (to avoid conflicts with add and remove tokens)
+        }
+        else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN )
+            || line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( RANGE_TOKEN )
+            || line.startsWith( NO_NEWLINE_TOKEN ) )
+        {
+            currentDifference.append( line ).append( "\n" );
+        }
+    }
+
+    private void addChangedFile( ScmFileStatus status, String line, String tmpLine )
+    {
+        tmpLine = tmpLine.substring( 1, tmpLine.length() - 1 );
+        File tmpFile = new File( workingDirectory, tmpLine );
+        if ( tmpFile.isFile() )
+        {
+            currentFile = tmpLine;
+            currentDifference = new StringBuffer();
+            differences.put( currentFile, currentDifference );
+            changedFiles.add( new ScmFile( tmpLine, status ) );
+        }
+        else
+        {
+            logger.warn( "Could not figure out of line: " + line );
+        }
+    }
+
+    public List getChangedFiles()
+    {
+        return changedFiles;
+    }
+
+    public Map getDifferences()
+    {
+        return differences;
+    }
+
+    public String getPatch()
+    {
+        return patch.toString();
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,36 @@
+package org.apache.maven.scm.provider.bazaar.command.remove;
+
+import java.io.File;
+
+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.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarRemoveCommand
+    extends AbstractRemoveCommand
+    implements BazaarCommand
+{
+    protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message )
+        throws ScmException
+    {
+
+        String[] command = new String[] { REMOVE_CMD };
+        BazaarUtils.expandCommandLine( command, fileSet );
+        BazaarRemoveConsumer consumer = new BazaarRemoveConsumer( getLogger() );
+        File workingDir = fileSet.getBasedir();
+
+        ScmResult result = BazaarUtils.execute( consumer, getLogger(), workingDir, command );
+        if ( result.isSuccess() )
+        {
+            return new RemoveScmResult( result.getCommandLine(), consumer.getRemovedFiles() );
+        }
+
+        return result;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,30 @@
+package org.apache.maven.scm.provider.bazaar.command.remove;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarRemoveConsumer
+    extends BazaarConsumer
+{
+    private final List removedFiles = new ArrayList();
+
+    public BazaarRemoveConsumer( ScmLogger logger )
+    {
+        super( logger );
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+        //TODO
+    }
+
+    public List getRemovedFiles()
+    {
+        return removedFiles;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/remove/BazaarRemoveConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,51 @@
+package org.apache.maven.scm.provider.bazaar.command.status;
+
+import java.io.File;
+import java.util.List;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmResult;
+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.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarStatusCommand
+    extends AbstractStatusCommand
+    implements BazaarCommand
+{
+
+    public BazaarStatusCommand() {
+        super();
+    }
+
+    public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet )
+        throws ScmException
+    {
+
+        File workingDir = fileSet.getBasedir();
+        BazaarStatusConsumer consumer = new BazaarStatusConsumer(getLogger(), workingDir);
+        String[] statusCmd = new String[] {STATUS_CMD};
+        ScmResult result = BazaarUtils.execute(consumer, getLogger(), workingDir, statusCmd);
+
+        return wrapResult(consumer.getStatus(), result);
+    }
+
+    private StatusScmResult wrapResult( List files, ScmResult baseResult )
+    {
+        StatusScmResult result;
+        if ( baseResult.isSuccess() )
+        {
+            result = new StatusScmResult( baseResult.getCommandLine(), files );
+        }
+        else
+        {
+            result = new StatusScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(), baseResult
+                .getCommandOutput(), baseResult.isSuccess() );
+        }
+        return result;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,64 @@
+package org.apache.maven.scm.provider.bazaar.command.status;
+
+import java.io.File;
+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.log.ScmLogger;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+class BazaarStatusConsumer
+    extends BazaarConsumer
+{
+    private final List repositoryStatus = new ArrayList();
+
+    private final File workingDir;
+
+    /** State currently consuming (one of the identifieres or null) */
+    private ScmFileStatus currentState = null;
+
+    BazaarStatusConsumer( ScmLogger logger, File workingDir )
+    {
+        super( logger );
+        this.workingDir = workingDir;
+    }
+
+    public void doConsume( ScmFileStatus status, String trimmedLine )
+    {
+        if ( status != null )
+        {
+            currentState = status;
+            return;
+        }
+
+        if ( currentState == null )
+        {
+            return;
+        }
+
+        //Only include real files (not directories)
+        File tmpFile = new File( workingDir, trimmedLine );
+        if ( !tmpFile.exists() )
+        {
+            logger.info( "Not a file: " + tmpFile + ". Ignoring" );
+        }
+        else if ( tmpFile.isDirectory() )
+        {
+            logger.info( "New directory added: " + tmpFile );
+        }
+        else
+        {
+            ScmFile scmFile = new ScmFile( trimmedLine, currentState );
+            logger.info( scmFile.toString() );
+            repositoryStatus.add( scmFile );
+        }
+    }
+
+    List getStatus()
+    {
+        return repositoryStatus;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/status/BazaarStatusConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,96 @@
+package org.apache.maven.scm.provider.bazaar.command.update;
+
+import java.io.File;
+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.ScmFileStatus;
+import org.apache.maven.scm.ScmResult;
+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.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.apache.maven.scm.provider.bazaar.command.changelog.BazaarChangeLogCommand;
+import org.apache.maven.scm.provider.bazaar.command.diff.BazaarDiffConsumer;
+import org.codehaus.plexus.util.StringUtils;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarUpdateCommand
+    extends AbstractUpdateCommand
+    implements BazaarCommand
+{
+
+    protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
+        throws ScmException
+    {
+
+        if ( !StringUtils.isEmpty( tag ) )
+        {
+            throw new ScmException( "This provider can't handle tags." );
+        }
+
+        File workingDir = fileSet.getBasedir();
+
+        // Update branch
+        String[] update_cmd = new String[] { BazaarCommand.PULL_CMD };
+        ScmResult updateResult = BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), workingDir,
+                                                      update_cmd );
+
+        if ( !updateResult.isSuccess() )
+        {
+            return wrapResult( new ArrayList(), updateResult );
+        }
+
+        // Find changes from last revision
+        int prev_revi = BazaarUtils.getCurrentRevisionNumber( getLogger(), workingDir ) - 1;
+        String[] diff_cmd = new String[] { DIFF_CMD, REVISION_OPTION, "" + prev_revi };
+        BazaarDiffConsumer diff_consumer = new BazaarDiffConsumer( getLogger(), workingDir );
+        ScmResult diffResult = BazaarUtils.execute( diff_consumer, getLogger(), workingDir, diff_cmd );
+
+        // Now translate between diff and update file status
+        List updatedFiles = new ArrayList();
+        for ( Iterator it = diff_consumer.getChangedFiles().iterator(); it.hasNext(); )
+        {
+            ScmFile file = (ScmFile) it.next();
+            if ( file.getStatus() == ScmFileStatus.MODIFIED )
+            {
+                updatedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.PATCHED ) );
+            }
+            else
+            {
+                updatedFiles.add( file );
+            }
+        }
+
+        return wrapResult( updatedFiles, diffResult );
+    }
+
+    private UpdateScmResult wrapResult( List files, ScmResult baseResult )
+    {
+        UpdateScmResult result;
+        if ( baseResult.isSuccess() )
+        {
+            result = new UpdateScmResult( baseResult.getCommandLine(), files );
+        }
+        else
+        {
+            result = new UpdateScmResult( baseResult.getCommandLine(), baseResult.getProviderMessage(), baseResult
+                .getCommandOutput(), baseResult.isSuccess() );
+        }
+        return result;
+    }
+
+    protected ChangeLogCommand getChangeLogCommand()
+    {
+        BazaarChangeLogCommand command = new BazaarChangeLogCommand();
+        command.setLogger( getLogger() );
+        return command;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/update/BazaarUpdateCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java?rev=373513&view=auto
==============================================================================
--- maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java (added)
+++ maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java Mon Jan 30 05:44:37 2006
@@ -0,0 +1,47 @@
+package org.apache.maven.scm.provider.bazaar.repository;
+
+import java.io.File;
+
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+
+/** @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a> */
+public class BazaarScmProviderRepository
+    extends ScmProviderRepository
+{
+    private final String uri;
+
+    public BazaarScmProviderRepository( String url )
+    {
+        this.uri = toURI( url );
+    }
+
+    public String getURI()
+    {
+        return uri;
+    }
+
+    private String toURI( String orgURL )
+    {
+        String newURI = orgURL;
+
+        //Only file urls needs special handling
+        if ( orgURL.startsWith( "file" ) )
+        {
+            newURI = orgURL.substring( "file://".length() );
+            String fileSeparator = System.getProperty( "file.separator" );
+            newURI = StringUtils.replace( newURI, "/", fileSeparator );
+            File tmpFile = new File( newURI );
+            String newURI2 = newURI.substring( fileSeparator.length() );
+            File tmpFile2 = new File( newURI2 );
+            if ( !tmpFile.exists() && !tmpFile2.exists() )
+            {
+                // TODO make fail fast
+            }
+
+            newURI = tmpFile2.exists() ? newURI2 : newURI;
+        }
+
+        return newURI;
+    }
+}

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/sandbox/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/repository/BazaarScmProviderRepository.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message