maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r389253 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar: ./ src/main/java/org/apache/maven/scm/provider/bazaar/ src/main/java/org/apache/maven/scm/provider/bazaar/command/ src/main/java/org/apache/maven/scm/provider/baza...
Date Mon, 27 Mar 2006 20:19:58 GMT
Author: evenisse
Date: Mon Mar 27 12:19:55 2006
New Revision: 389253

URL: http://svn.apache.org/viewcvs?rev=389253&view=rev
Log:
o [SCM-175] Fix parsing of changelog entries for merged branches
o [SCM-174] Fix changelog report(take2)
o Better diagnostics and only when something fails (reduced logging when hitting the lucky
state :)
Submitted by Torbjørn EIkli Smørgrav

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/Readme.txt
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/Readme.txt
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/Readme.txt?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/Readme.txt (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/Readme.txt Mon Mar 27 12:19:55
2006
@@ -1,20 +1,27 @@
 How to build bazaar scm provider?
 
-You must have bazaar installed on your machine. Bazaar is available there (http://bazaar.canonical.com/)
-It require Python and some others modules (http://bazaar.canonical.com/Installation).
+You must have bazaar installed on your machine. Bazaar is available at (http://bazaar-vcs.org/)
+It requires Python and some other modules (http://bazaar-vcs.org/Installation).
 
-For windows users, you'll need, after installation to create a bzr.bat file added in your
path with the folowing content:
+For bazaar version 0.8+ consult (http://bazaar-vcs.org/Installation).
+
+For bazaar pre 0.8 on windows:
+
+For windows users, you'll need, after installation to create a bzr.bat file
+added in your path with the following content:
 
 ----------
 python <path_to_bzr_home>\bzr %*
 ----------
 
-Unfortunately, you can't use the Cygwin bzr at this time. While it will start with a batch
file called:
+Unfortunately, you can't use the Cygwin bzr at this time.
+While it will start with a batch file called:
 
 ----------
 c:\cygwin\bin\python2.4.exe /usr/bin/bzr %*
 ----------
 
-Any of the arguments that are files cannot be translated to cygwin paths. What is required
is support in Commandline
-to recognise a cygwin environment, and for anything that was created with createArgument().setFile(...),
it should be
+Any of the arguments that are files cannot be translated to cygwin paths.
+What is required is support in Commandline to recognise a cygwin environment,
+and for anything that was created with createArgument().setFile(...), it should be
 translated with cygpath -w. Commands would be executed with "sh".

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java?rev=389253&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
Mon Mar 27 12:19:55 2006
@@ -0,0 +1,242 @@
+package org.apache.maven.scm.provider.bazaar;
+
+/*
+ * Copyright 2001-2006 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.ScmException;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.DefaultLog;
+import org.apache.maven.scm.provider.bazaar.command.BazaarCommand;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.codehaus.plexus.util.cli.Commandline;
+
+/**
+ * Check bazaar installation.
+ *
+ * @author <a href="mailto:torbjorn@smorgrav.org">Torbjørn Eikli Smørgrav</a>
+ */
+public class BazaarConfig
+{
+    //Minimum version for the Bazaar SCM
+    private static final float BAZAAR_REQ = 0.7f;
+    private static final float PYTHON_REQ = 2.4f;
+
+    //Bazaar spesific
+    private static final String BAZAAR_VERSION_TAG = "bzr (bazaar-ng) ";
+    private static final String BAZAAR_INSTALL_URL = "'http://bazaar-vcs.org/Installation'";
+
+    //Python spesific
+    private static final String PYTHON_EXEC = "python";
+    private static final String PYTHON_VERSION = "-V";
+    private static final String PYTHON_VERSION_TAG = "Python ";
+
+    //Python modules
+    private static final String PARAMIKO = "\"import paramiko\"";
+    private static final String CCRYPT = "\"import Crypto\"";
+    private static final String CELEMENTREE = "\"import cElementTree\"";
+
+    //Configuration to check with default values (not installed)
+    private VersionConsumer bazaarVersion = new VersionConsumer(null);
+    private VersionConsumer pythonVersion = new VersionConsumer(null);
+    private boolean cElementTree = false;
+    private boolean paramiko = false;
+    private boolean cCrypt = false;
+
+    BazaarConfig( File workingDir )
+    {
+        try
+        {
+            pythonVersion = getPythonVersion( workingDir );
+            paramiko = checkPyModules( workingDir, PARAMIKO ); //does not throw
+            cCrypt = checkPyModules( workingDir, CCRYPT ); //does not throw
+            cElementTree = checkPyModules( workingDir, CELEMENTREE ); //does not throw
+            bazaarVersion = getBazaarVersion( workingDir );
+        }
+        catch ( ScmException e )
+        {
+            //Ignore - Either python and/or bazaar is not installed.
+            //This is already recorded thus we do not generate more info.
+        }
+
+    }
+
+    private boolean checkPyModules( File workingDir, String cmd )
+    {
+        PythonConsumer consumer = new PythonConsumer();
+        int exitCode;
+        try
+        {
+            Commandline cmdLine = buildPythonCmd( workingDir, new String[] { "-c", cmd }
);
+            exitCode = BazaarUtils.executeCmd( consumer, cmdLine );
+        }
+        catch ( ScmException e )
+        {
+            //Ignore - error here is likly to manifest itself when checking python anyway.
+            exitCode = -1;
+        }
+
+        return exitCode == 0 && consumer.getConsumedAndClear().equals( "" );
+    }
+
+
+    /**
+     * @return True if one can run basic bazaar commands
+     */
+    private boolean isInstalled()
+    {
+        return pythonVersion.isVersionOk(PYTHON_REQ)
+        && bazaarVersion.isVersionOk(BAZAAR_REQ);
+    }
+
+    /**
+     * @return True if all modules for bazaar are installed.
+     */
+    private boolean isComplete()
+    {
+        return isInstalled() && cElementTree && paramiko && cCrypt;
+    }
+
+    public static VersionConsumer getBazaarVersion( File workingDir )
+        throws ScmException
+    {
+        String[] versionCmd = new String[] { BazaarCommand.VERSION };
+        VersionConsumer consumer = new VersionConsumer( BAZAAR_VERSION_TAG );
+        Commandline cmd = BazaarUtils.buildCmd( workingDir, versionCmd );
+
+        // Execute command
+        BazaarUtils.executeCmd( consumer, cmd );
+
+        // Return result
+        return consumer;
+    }
+
+    public static VersionConsumer getPythonVersion( File workingDir )
+        throws ScmException
+    {
+        String[] versionCmd = new String[] { PYTHON_VERSION };
+        VersionConsumer consumer = new VersionConsumer( PYTHON_VERSION_TAG );
+        Commandline cmd = buildPythonCmd( workingDir, versionCmd );
+
+        // Execute command
+        BazaarUtils.executeCmd( consumer, cmd );
+
+        // Return result
+        return consumer;
+    }
+
+    private static Commandline buildPythonCmd( File workingDir, String[] cmdAndArgs )
+        throws ScmException
+    {
+        Commandline cmd = new Commandline();
+        cmd.setExecutable( PYTHON_EXEC );
+        cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
+        cmd.addArguments( cmdAndArgs );
+
+        if ( !workingDir.exists() )
+        {
+            boolean success = workingDir.mkdirs();
+            if ( !success )
+            {
+                String msg = "Working directory did not exist"
+                    + " and it couldn't be created: " + workingDir;
+                throw new ScmException( msg );
+            }
+        }
+        return cmd;
+    }
+
+    /**
+     * Get version of the bazaar executable <p/> Resolve revision to the last
+     * integer found in the command output.
+     */
+    private static class VersionConsumer
+        extends BazaarConsumer
+    {
+        private final String version_tag;
+        private String versionStr = "NA";
+        private float version = -1;
+
+        VersionConsumer(String version_tag)
+        {
+            super( new DefaultLog() );
+            this.version_tag = version_tag;
+        }
+
+        public void doConsume( ScmFileStatus status, String line )
+        {
+            if ( line.startsWith( version_tag ) )
+            {
+                versionStr = line.substring( version_tag.length() );
+            }
+        }
+
+        String getVersion()
+        {
+            return versionStr;
+        }
+
+        boolean isVersionOk(float min)
+        {
+            return true; //min <= version;
+        }
+    }
+
+    private static class PythonConsumer
+        extends BazaarConsumer
+    {
+
+        private String consumed = "";
+
+        PythonConsumer()
+        {
+            super( new DefaultLog() );
+        }
+
+        public void doConsume( ScmFileStatus status, String line )
+        {
+            consumed = line;
+        }
+
+        String getConsumedAndClear()
+        {
+            String tmp = consumed;
+            consumed = "";
+            return tmp;
+        }
+    }
+
+    private String getInstalledStr() {
+        if (isComplete()) {
+            return "valid and complete.";
+        }
+        return (isInstalled() ? "incomplete. " : "invalid. ") + "Consult " + BAZAAR_INSTALL_URL;
+    }
+
+    public String toString( File workingDir )
+    {
+        boolean bzrOk = bazaarVersion.isVersionOk(BAZAAR_REQ);
+        boolean pyOk = bazaarVersion.isVersionOk(PYTHON_REQ);
+        return "\n  Your Bazaar installation seems to be " + getInstalledStr()
+        + "\n    Python version: " + pythonVersion.getVersion() + (pyOk ? " (OK)" : " (TOO
OLD!)")
+        + "\n    Bazaar version: " + bazaarVersion.getVersion() + (bzrOk ? " (OK)" : " (TOO
OLD!)")
+        + "\n    Paramiko installed: " + paramiko + " (For remote access eg. sftp) "
+        + "\n    cCrypt installed: " + cCrypt + " (For remote access eg. sftp) "
+        + "\n    cElementTree installed: " + cElementTree + " (Not mandatory) "
+        + "\n";
+    }
+}

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

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

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java
Mon Mar 27 12:19:55 2006
@@ -30,6 +30,7 @@
 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.BazaarCommand;
 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;
@@ -91,13 +92,14 @@
     {
         List errorMessages = new ArrayList();
 
-        String[] checkCmd = new String[]{"check", scmSpecificUrl};
+        String[] checkCmd = new String[]{BazaarCommand.CHECK, scmSpecificUrl};
         ScmResult result;
         try
         {
             File tmpDir = new File( System.getProperty( "java.io.tmpdir" ) );
             result = BazaarUtils.execute( tmpDir, checkCmd );
             errorMessages.add( result.getCommandOutput() );
+            errorMessages.add( result.getProviderMessage() );
         }
         catch ( ScmException e )
         {

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarUtils.java
Mon Mar 27 12:19:55 2006
@@ -41,7 +41,6 @@
  */
 public class BazaarUtils
 {
-
     /**
      * Map between command and its valid exit codes
      */
@@ -60,36 +59,71 @@
         //Diff is different
         List diffExitCodes = new ArrayList();
         diffExitCodes.add( new Integer( 0 ) ); //No difference
-        diffExitCodes.add( new Integer( 1 ) ); //Difference exists
+        diffExitCodes.add( new Integer( 1 ) ); //Conflicts in merge-like or changes in diff-like
+        diffExitCodes.add( new Integer( 2 ) ); //Unrepresentable diff changes
         exitCodeMap.put( BazaarCommand.DIFF_CMD, diffExitCodes );
     }
 
-    public static ScmResult execute( BazaarConsumer consumer, ScmLogger logger, File workingDir,
String[] cmdAndArgs )
+    public static ScmResult execute( BazaarConsumer consumer, ScmLogger logger,
+                                     File workingDir, String[] cmdAndArgs )
         throws ScmException
     {
-    	//Build commandline
-        Commandline cmd = buildCmd(workingDir, cmdAndArgs);
+        try
+        {
+            //Build commandline
+            Commandline cmd = buildCmd( workingDir, cmdAndArgs );
+            logger.info( "EXECUTING: " + cmd );
+
+            //Execute command
+            int exitCode = executeCmd( consumer, cmd );
+
+            //Return result
+            List exitCodes = defaultExitCodes;
+            if (exitCodeMap.containsKey( cmdAndArgs[0] )) {
+                exitCodes = (List) exitCodeMap.get( cmdAndArgs[0] );
+            }
+            boolean success = exitCodes.contains( new Integer( exitCode ) );
+
+            //On failure (and not due to exceptions) - run diagnostics
+            String providerMsg = "Execution of bazaar command succeded";
+            if ( !success )
+            {
+                BazaarConfig config = new BazaarConfig(workingDir);
+                providerMsg = "\nEXECUTION FAILED"
+                    + "\n  Execution of cmd : " + cmdAndArgs[0]
+                    + " failed with exit code: " + exitCode + "."
+                    + "\n  Working directory was: "
+                    + "\n    " + workingDir.getAbsolutePath()
+                    + config.toString(workingDir)
+                    + "\n";
+                logger.error( providerMsg );
+            }
 
-        //Write out info and debug info
-        logger.info( "EXECUTING: " + cmd );
-        //TODO log this as debug information when I understand howto do that
-        logger.info( "Bazaar version: " + getBazaarVersion(workingDir));
-        logger.info( "Working directory: " + workingDir.getAbsolutePath() );
 
-        //Execute command
-        final int exitCode = executeCmd(consumer, cmd);
+            return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success
);
+        }
+        catch ( ScmException se )
+        {
+            String msg = "EXECUTION FAILED"
+                + "\n  Execution failed before invoking the Bazaar command. Last exception:"
+                + "\n    " + se.getMessage();
 
-        //Return result
-        List exitCodes =
-            exitCodeMap.containsKey( cmdAndArgs[0] ) ? (List) exitCodeMap.get( cmdAndArgs[0]
) : defaultExitCodes;
-        boolean success = exitCodes.contains( new Integer( exitCode ) );
+            //Add nested cause if any
+            if ( se.getCause() != null )
+            {
+                msg += "\n  Nested exception:" + "\n    " + se.getCause().getMessage();
+            }
 
-        String providerMsg = "Execution of bazaar command: " + ( success ? "succeded" : "failed"
);
-        return new ScmResult( cmd.toString(), providerMsg, consumer.getStdErr(), success
);
+            //log and return
+            logger.error( msg );
+            throw se;
+        }
     }
 
-	private static Commandline buildCmd(File workingDir, String[] cmdAndArgs) throws ScmException
{
-		Commandline cmd = new Commandline();
+    static Commandline buildCmd( File workingDir, String[] cmdAndArgs )
+        throws ScmException
+    {
+        Commandline cmd = new Commandline();
         cmd.setExecutable( BazaarCommand.EXEC );
         cmd.setWorkingDirectory( workingDir.getAbsolutePath() );
         cmd.addArguments( cmdAndArgs );
@@ -99,15 +133,18 @@
             boolean success = workingDir.mkdirs();
             if ( !success )
             {
-                String msg = "Working directory did not exist and it couldn't be created:
" + workingDir;
+                String msg = "Working directory did not exist"
+                    + " and it couldn't be created: " + workingDir;
                 throw new ScmException( msg );
             }
         }
-		return cmd;
-	}
+        return cmd;
+    }
 
-	private static int executeCmd(BazaarConsumer consumer, Commandline cmd) throws ScmException
{
-		final int exitCode;
+    static int executeCmd( BazaarConsumer consumer, Commandline cmd )
+        throws ScmException
+    {
+        final int exitCode;
         try
         {
             exitCode = CommandLineUtils.executeCommandLine( cmd, consumer, consumer );
@@ -116,8 +153,8 @@
         {
             throw new ScmException( "Command could not be executed: " + cmd, ex );
         }
-		return exitCode;
-	}
+        return exitCode;
+    }
 
     public static ScmResult execute( File workingDir, String[] cmdAndArgs )
         throws ScmException
@@ -148,7 +185,7 @@
         throws ScmException
     {
 
-        String[] revCmd = new String[]{BazaarCommand.REVNO_CMD};
+        String[] revCmd = new String[] { BazaarCommand.REVNO_CMD };
         BazaarRevNoConsumer consumer = new BazaarRevNoConsumer( logger );
         BazaarUtils.execute( consumer, logger, workingDir, revCmd );
 
@@ -186,49 +223,6 @@
         int getCurrentRevisionNumber()
         {
             return revNo;
-        }
-    }
-
-    public static String getBazaarVersion(File workingDir)
-			throws ScmException {
-
-		String[] versionCmd = new String[] { "version" };
-		BazaarVersionConsumer consumer = new BazaarVersionConsumer();
-		Commandline cmd = buildCmd(workingDir, versionCmd);
-
-		// Execute command
-		executeCmd(consumer, cmd);
-
-		// Return result
-		return consumer.getVersion();
-	}
-
-    /**
-	 * Get version of the bazaar executable <p/> Resolve revision to the last
-	 * integer found in the command output.
-	 */
-    private static class BazaarVersionConsumer
-        extends BazaarConsumer
-    {
-
-    	private static final String VERSION_TAG = "bzr (bazaar-ng) ";
-        private String version = "Unknown";
-
-        BazaarVersionConsumer()
-        {
-            super( new DefaultLog() );
-        }
-
-        public void doConsume( ScmFileStatus status, String line )
-        {
-            if (line.startsWith(VERSION_TAG)) {
-            	version = line.substring(VERSION_TAG.length());
-            }
-        }
-
-        String getVersion()
-        {
-            return version;
         }
     }
 }

Modified: maven/scm/trunk/maven-scm-providers/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/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarCommand.java
Mon Mar 27 12:19:55 2006
@@ -101,4 +101,8 @@
     public static final String REVISION_OPTION = "--revision";
 
     public static final String VERBOSE_OPTION = "--verbose";
+
+    public static final String VERSION = "version";
+
+    public static final String CHECK = "check";
 }

Modified: maven/scm/trunk/maven-scm-providers/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/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogCommand.java
Mon Mar 27 12:19:55 2006
@@ -46,7 +46,7 @@
     {
         String[] cmd = new String[]{LOG_CMD, VERBOSE_OPTION};
         BazaarChangeLogConsumer consumer =
-            new BazaarChangeLogConsumer( getLogger(), datePattern, fileSet.getBasedir() );
+            new BazaarChangeLogConsumer( getLogger(), datePattern );
         ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(),
cmd );
 
         List logEntries = consumer.getModifications();
@@ -54,8 +54,6 @@
         startDate = startDate == null ? new Date( 0 ) : startDate; //From 1. Jan 1970
         endDate = endDate == null ? new Date() : endDate; //Upto now
 
-        getLogger().info(startDate.toString());
-        getLogger().info(endDate.toString());
         for ( Iterator it = logEntries.iterator(); it.hasNext(); )
         {
             ChangeSet change = (ChangeSet) it.next();
@@ -68,7 +66,6 @@
             }
         }
 
-        getLogger().info("Got " + inRangeAndValid.size() + " of " + logEntries.size()  +
" log entries");
         ChangeLogSet changeLogSet = new ChangeLogSet( inRangeAndValid, startDate, endDate
);
         return new ChangeLogScmResult(changeLogSet, result );
     }

Modified: maven/scm/trunk/maven-scm-providers/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/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumer.java
Mon Mar 27 12:19:55 2006
@@ -22,7 +22,6 @@
 import org.apache.maven.scm.log.ScmLogger;
 import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
 
-import java.io.File;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -48,12 +47,16 @@
 
     private static final String BRANCH_NICK_TOKEN = "branch nick: ";
 
-    private final File workingDir;
+    private static final String MERGED_TOKEN = "merged: ";
 
     private List logEntries = new ArrayList();
 
     private ChangeSet currentChange;
 
+    private ChangeSet lastChange;
+
+    private boolean isMergeEntry;
+
     private String currentRevision;
 
     private StringBuffer currentComment;
@@ -61,17 +64,15 @@
     private String userDatePattern;
 
     /**
-     * null means not parsing message nor files, UNKNOWN means parsing message
+     * Null means not parsing message nor files, UNKNOWN means parsing message
      */
     private ScmFileStatus currentStatus = null;
 
-    public BazaarChangeLogConsumer( ScmLogger logger, String userDatePattern, File workingDir
)
+    public BazaarChangeLogConsumer( ScmLogger logger, String userDatePattern )
     {
         super( logger );
 
         this.userDatePattern = userDatePattern;
-
-        this.workingDir = workingDir;
     }
 
     public List getModifications()
@@ -86,12 +87,37 @@
         // Parse line
         if ( line.startsWith( START_LOG_TAG ) )
         {
+            //If last entry was part a merged entry
+            if (isMergeEntry && lastChange != null) {
+                String comment = lastChange.getComment();
+                comment += "\n[MAVEN]: Merged from " + currentChange.getAuthor();
+                comment += "\n[MAVEN]:    " + currentChange.getDateFormatted();
+                comment += "\n[MAVEN]:    " + currentChange.getComment();
+                lastChange.setComment(comment);
+            }
+
+            //Init a new changeset
             currentChange = new ChangeSet();
             currentChange.setFiles(new ArrayList());
             logEntries.add( currentChange );
+
+            //Reset memeber vars
             currentComment = new StringBuffer();
             currentStatus = null;
             currentRevision = "";
+            isMergeEntry = false;
+        }
+        else if ( line.startsWith( MERGED_TOKEN ) )
+        {
+            //This is part of lastChange and is not a separate log entry
+            isMergeEntry = true;
+            logEntries.remove(currentChange);
+            if (logEntries.size() > 0) {
+                lastChange = (ChangeSet)logEntries.get(logEntries.size() - 1);
+            } else {
+                getLogger().warn("First entry was unexpectedly a merged entry");
+                lastChange = null;
+            }
         }
         else if ( line.startsWith( REVNO_TAG ) )
         {
@@ -129,12 +155,8 @@
         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 );
-            }
+            ChangeFile changeFile = new ChangeFile( tmpLine, currentRevision );
+            currentChange.addFile( changeFile );
         }
         else if ( line.startsWith( BRANCH_NICK_TOKEN ) )
         {

Modified: maven/scm/trunk/maven-scm-providers/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/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/diff/BazaarDiffConsumer.java
Mon Mar 27 12:19:55 2006
@@ -40,7 +40,6 @@
 
     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 = "---";
@@ -115,9 +114,36 @@
         }
     }
 
+    /**
+     * This method takes into account two types of diff output. <br>
+     * - Bazaar 0.7 format: dir/dir/myfile  <br>
+     * - Bazaar 0.8 format: a/dir/dir/myfile <br>
+     *
+     * @param status Eg. modified or added
+     * @param line The original bazaar output to process (for logging)
+     * @param tmpLine The bazaar output to process
+     */
     private void addChangedFile( ScmFileStatus status, String line, String tmpLine )
     {
         tmpLine = tmpLine.substring( 1, tmpLine.length() - 1 );
+        boolean ok = addChangedFile( status, tmpLine );
+
+        if (!ok) {
+            int index = tmpLine.indexOf("/");
+            if (index > -1) {
+                tmpLine = tmpLine.substring(index + 1);
+                ok = addChangedFile( status, tmpLine );
+            }
+        }
+
+        if (!ok) {
+            logger.warn( "Could not figure out of line: " + line );
+        }
+    }
+
+    /** @return True if tmpLine was a valid file and thus added to the changeset */
+    private boolean addChangedFile( ScmFileStatus status, String tmpLine )
+    {
         File tmpFile = new File( workingDirectory, tmpLine );
         if ( tmpFile.isFile() )
         {
@@ -125,11 +151,10 @@
             currentDifference = new StringBuffer();
             differences.put( currentFile, currentDifference );
             changedFiles.add( new ScmFile( tmpLine, status ) );
+            return true;
         }
-        else
-        {
-            logger.warn( "Could not figure out of line: " + line );
-        }
+
+        return false;
     }
 
     public List getChangedFiles()

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java?rev=389253&r1=389252&r2=389253&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/BazaarTestUtils.java
Mon Mar 27 12:19:55 2006
@@ -103,16 +103,19 @@
         ScmResult result = BazaarUtils.execute( WORKING_DIR, add_cmd );
         if ( !result.isSuccess() )
         {
-            String message = "Provider message: " + result.getProviderMessage() + "\n" +
"Output: " + result.getCommandOutput();
+            String message = "Provider message: " + result.getProviderMessage()
+            + "\n" + "Output: " + result.getCommandOutput();
             throw new Exception( message );
         }
 
         // Commit the initial repository
-        String[] commit_cmd = new String[]{BazaarCommand.COMMIT_CMD, BazaarCommand.MESSAGE_OPTION,
COMMIT_MESSAGE};
+        String[] commit_cmd = new String[]{BazaarCommand.COMMIT_CMD,
+            BazaarCommand.MESSAGE_OPTION, COMMIT_MESSAGE};
         result = BazaarUtils.execute( WORKING_DIR, commit_cmd );
         if ( !result.isSuccess() )
         {
-            String message = "Provider message: " + result.getProviderMessage() + "\n" +
"Output: " + result.getCommandOutput();
+            String message = "Provider message: " + result.getProviderMessage()
+            + "\n" + "Output: " + result.getCommandOutput();
             throw new Exception( message );
         }
     }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java?rev=389253&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java
Mon Mar 27 12:19:55 2006
@@ -0,0 +1,50 @@
+package org.apache.maven.scm.provider.bazaar.command.changelog;
+
+/*
+ * Copyright 2001-2006 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.IOException;
+import java.io.InputStreamReader;
+import java.util.List;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.log.DefaultLog;
+
+public class BazaarChangeLogConsumerTest
+    extends ScmTestCase
+{
+    public void testChanglogWithMergeEntries() throws IOException
+    {
+        File testFile = getTestFile( "src/test/resources/bazaar/changeLogWithMerge.txt" );
+
+        BazaarChangeLogConsumer consumer = new BazaarChangeLogConsumer( new DefaultLog(),
null);
+
+        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 mods = consumer.getModifications();
+        assertEquals(4, mods.size());
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/changelog/BazaarChangeLogConsumerTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt?rev=389253&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
Mon Mar 27 12:19:55 2006
@@ -0,0 +1,50 @@
+------------------------------------------------------------
+revno: 4
+committer: tsmoergrav@slb.com
+branch nick: bzr.test2
+timestamp: Fri 2006-03-24 21:51:36 +0100
+message:
+  Hello
+modified:
+  changeLogWithMerge.txt
+    ------------------------------------------------------------
+    merged: tsmoergrav@slb.com-20060324204530-b95bda1a51d98560
+    committer: tsmoergrav@slb.com
+    branch nick: BZR~1.TES
+    timestamp: Fri 2006-03-24 21:45:30 +0100
+    message:
+      Great!
+    ------------------------------------------------------------
+    merged: tsmoergrav@slb.com-20060324204323-8143a4e84f876d8e
+    committer: tsmoergrav@slb.com
+    branch nick: bzr.test
+    timestamp: Fri 2006-03-24 21:43:23 +0100
+    message:
+      Go Girl!
+------------------------------------------------------------
+revno: 3
+committer: tsmoergrav@slb.com
+branch nick: BZR~2.TES
+timestamp: Fri 2006-03-24 21:39:57 +0100
+message:
+  Third
+modified:
+  changeLogWithMerge.txt
+------------------------------------------------------------
+revno: 2
+committer: tsmoergrav@slb.com
+branch nick: BZR~2.TES
+timestamp: Fri 2006-03-24 21:39:31 +0100
+message:
+  Second
+modified:
+  changeLogWithMerge.txt
+------------------------------------------------------------
+revno: 1
+committer: tsmoergrav@slb.com
+branch nick: BZR~1.TES
+timestamp: Fri 2006-03-24 21:37:51 +0100
+message:
+  Init
+added:
+  changeLogWithMerge.txt

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/resources/bazaar/changeLogWithMerge.txt
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message