maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From strub...@apache.org
Subject svn commit: r806087 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src: main/java/org/apache/maven/scm/provider/bazaar/ main/java/org/apache/maven/scm/provider/bazaar/command/ main/java/org/apache/maven/scm/provider/bazaar/command/...
Date Thu, 20 Aug 2009 08:41:15 GMT
Author: struberg
Date: Thu Aug 20 08:41:15 2009
New Revision: 806087

URL: http://svn.apache.org/viewvc?rev=806087&view=rev
Log:
[SCM-492] tagging support added
Submitted by: Johan Walles 
o applied with slight code reformatting - txs

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
    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/command/BazaarConstants.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java

Modified: 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/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java?rev=806087&r1=806086&r2=806087&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarConfig.java
Thu Aug 20 08:41:15 2009
@@ -43,12 +43,12 @@
 
     private static final float PYTHON_REQ = 2.4f;
 
-    //Bazaar spesific
+    //Bazaar specific
     private static final String BAZAAR_VERSION_TAG = "bzr (bazaar-ng) ";
 
     private static final String BAZAAR_INSTALL_URL = "'http://bazaar-vcs.org/Installation'";
 
-    //Python spesific
+    //Python specific
     private static final String PYTHON_EXEC = "python";
 
     private static final String PYTHON_VERSION = "-V";

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/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/BazaarScmProvider.java?rev=806087&r1=806086&r2=806087&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
Thu Aug 20 08:41:15 2009
@@ -30,6 +30,7 @@
 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.tag.TagScmResult;
 import org.apache.maven.scm.command.update.UpdateScmResult;
 import org.apache.maven.scm.provider.AbstractScmProvider;
 import org.apache.maven.scm.provider.ScmProviderRepository;
@@ -41,6 +42,7 @@
 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.tag.BazaarTagCommand;
 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.ScmRepositoryException;
@@ -205,6 +207,17 @@
     }
 
     /** {@inheritDoc} */
+    public TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters
parameters )
+        throws ScmException
+    {
+        BazaarTagCommand command = new BazaarTagCommand();
+
+        command.setLogger( getLogger() );
+
+        return (TagScmResult) command.execute( repository, fileSet, parameters );
+    }
+
+    /** {@inheritDoc} */
     public UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet,
CommandParameters parameters )
         throws ScmException
     {

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConstants.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConstants.java?rev=806087&r1=806086&r2=806087&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConstants.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/BazaarConstants.java
Thu Aug 20 08:41:15 2009
@@ -92,6 +92,16 @@
     public static final String REVNO_CMD = "revno";
 
     /**
+     * Create a tag
+     */
+    public static final String TAG_CMD = "tag";
+
+    /**
+     * List directory contents, bazaar style.
+     */
+    public static final String LS_CMD = "ls";
+    
+    /**
      * Show inventory of the current working copy or a revision
      */
     public static final String INVENTORY_CMD = "inventory";
@@ -104,7 +114,12 @@
 
     public static final String VERBOSE_OPTION = "--verbose";
 
+    /**
+     * Option to enable recursing into subdirectories.
+     */
+    public static final String RECURSIVE_OPTION = "--recursive";
+    
     public static final String VERSION = "version";
 
     public static final String CHECK = "check";
-}
+}
\ No newline at end of file

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java?rev=806087&r1=806086&r2=806087&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/checkout/BazaarCheckOutCommand.java
Thu Aug 20 08:41:15 2009
@@ -23,7 +23,6 @@
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmResult;
 import org.apache.maven.scm.ScmVersion;
-import org.apache.maven.scm.command.Command;
 import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
 import org.apache.maven.scm.command.checkout.CheckOutScmResult;
 import org.apache.maven.scm.provider.ScmProviderRepository;
@@ -36,6 +35,7 @@
 
 import java.io.File;
 import java.io.IOException;
+import java.util.ArrayList;
 
 /**
  * @author <a href="mailto:torbjorn@smorgrav.org">Torbj�rn Eikli Sm�rgrav</a>
@@ -43,19 +43,12 @@
  */
 public class BazaarCheckOutCommand
     extends AbstractCheckOutCommand
-    implements Command
 {
     /** {@inheritDoc} */
     protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet
fileSet,
                                                         ScmVersion version, boolean recursive
)
         throws ScmException
     {
-
-        if ( version != null && StringUtils.isNotEmpty( version.getName() ) )
-        {
-            throw new ScmException( "This provider can't handle tags." );
-        }
-
         BazaarScmProviderRepository repository = (BazaarScmProviderRepository) repo;
         String url = repository.getURI();
 
@@ -74,9 +67,17 @@
         }
 
         // Do the actual checkout
-        String[] checkoutCmd = new String[]{BazaarConstants.BRANCH_CMD, url, checkoutDir.getAbsolutePath()};
+        ArrayList checkoutCmd = new ArrayList();
+        checkoutCmd.add( BazaarConstants.BRANCH_CMD );
+        checkoutCmd.add( url );
+        checkoutCmd.add( checkoutDir.getAbsolutePath() );
+        if ( version != null && StringUtils.isNotEmpty( version.getName() ) ) {
+             checkoutCmd.add( BazaarConstants.REVISION_OPTION );
+             checkoutCmd.add( "tag:" + version.getName() );
+        }
         BazaarConsumer checkoutConsumer = new BazaarConsumer( getLogger() );
-        BazaarUtils.execute( checkoutConsumer, getLogger(), checkoutDir.getParentFile(),
checkoutCmd );
+        BazaarUtils.execute( checkoutConsumer, getLogger(), checkoutDir.getParentFile(),
+                             (String[]) checkoutCmd.toArray( new String[0] ) );
 
         // Do inventory to find list of checkedout files
         String[] inventoryCmd = new String[]{BazaarConstants.INVENTORY_CMD};

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.java?rev=806087&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.java
Thu Aug 20 08:41:15 2009
@@ -0,0 +1,77 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.maven.scm.provider.bazaar.command.tag;
+
+import java.io.File;
+import java.util.LinkedList;
+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;
+
+/**
+ * Parse output from "bzr ls".
+ * @author <a href="mailto:johan.walles@gmail.com">Johan Walles</a>
+ * @version $Id$
+ */
+class BazaarLsConsumer extends BazaarConsumer {
+    /**
+     * The root directory of this bazaar repository.
+     */
+    private File repositoryRoot;
+    
+    /**
+     * A list of the files found by ls.
+     */
+    private List files;
+    
+    /**
+     * Create a new "bzr ls" consumer.
+     * @param repositoryRoot The root directory of this bazaar repository.
+     * @param wantedStatus The status we'll report for the files listed.
+     */
+    public BazaarLsConsumer(ScmLogger logger,
+            File repositoryRoot,
+            ScmFileStatus wantedStatus) 
+    {
+        super( logger );
+        files = new LinkedList();
+    }
+    
+    public void doConsume( ScmFileStatus status, String trimmedLine ) {
+        if ( trimmedLine.endsWith( File.separator ) ) {
+            // Don't report directories
+            return;
+        }
+        
+        String path = new File( repositoryRoot, trimmedLine ).toString();
+        files.add( new ScmFile( path, ScmFileStatus.TAGGED ) );
+    }
+    
+    /**
+     * Answer what files were listed by bzr ls.
+     * @return A list of files listed by bzr ls.
+     */
+    public List getListedFiles() {
+        return files;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarLsConsumer.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/command/tag/BazaarLsConsumer.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.java?rev=806087&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.java
Thu Aug 20 08:41:15 2009
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.maven.scm.provider.bazaar.command.tag;
+
+import java.io.File;
+
+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.ScmTagParameters;
+import org.apache.maven.scm.command.tag.AbstractTagCommand;
+import org.apache.maven.scm.command.tag.TagScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.bazaar.BazaarUtils;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConstants;
+import org.apache.maven.scm.provider.bazaar.command.BazaarConsumer;
+import org.apache.maven.scm.provider.bazaar.repository.BazaarScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+
+/**
+ * @author <a href="mailto:johan.walles@gmail.com">Johan Walles</a>
+ * @version $Id$
+ */
+public class BazaarTagCommand extends AbstractTagCommand {
+    protected ScmResult executeTagCommand( ScmProviderRepository repository,
+            ScmFileSet fileSet, String tagName,
+            ScmTagParameters scmTagParameters ) throws ScmException
+    {
+        if ( tagName == null || StringUtils.isEmpty( tagName.trim() ) ) {
+            throw new ScmException( "tag name must be specified" );
+        }
+        
+        if ( !fileSet.getFileList().isEmpty() ) {
+            throw new ScmException( "tagging specific files is not allowed" );
+        }
+        
+        // Perform the tagging operation
+        File bazaarRoot = fileSet.getBasedir();
+        BazaarConsumer consumer = new BazaarConsumer( getLogger() );
+        String[] tagCmd = new String[] { BazaarConstants.TAG_CMD, tagName };
+        ScmResult tagResult = BazaarUtils.execute( consumer, getLogger(), bazaarRoot, tagCmd
);
+        if ( !tagResult.isSuccess() ) {
+            return new TagScmResult( null, tagResult );
+        }
+
+        // Do "bzr ls -R -r tag:tagName" to get a list of the tagged files
+        BazaarLsConsumer lsConsumer = 
+            new BazaarLsConsumer( getLogger(), bazaarRoot, ScmFileStatus.TAGGED );
+        String[] lsCmd = new String[] {
+                                       BazaarConstants.LS_CMD,
+                                       BazaarConstants.RECURSIVE_OPTION,
+                                       BazaarConstants.REVISION_OPTION,
+                                       "tag:" + tagName
+                                       };
+        ScmResult lsResult = BazaarUtils.execute(lsConsumer, getLogger(), bazaarRoot, lsCmd);
+        if ( !lsResult.isSuccess() ) {
+            return new TagScmResult( null, lsResult );
+        }
+        
+        // Push new tags to parent branch if any
+        BazaarScmProviderRepository bazaarRepository = (BazaarScmProviderRepository) repository;
+        if ( !bazaarRepository.getURI().equals( fileSet.getBasedir().getAbsolutePath() )
)
+        {
+            String[] pushCmd = new String[] { BazaarConstants.PUSH_CMD, bazaarRepository.getURI()
};
+            ScmResult pushResult =
+                BazaarUtils.execute( new BazaarConsumer( getLogger() ), getLogger(), fileSet.getBasedir(),
pushCmd );
+            if ( !pushResult.isSuccess() ) {
+                return new TagScmResult( null, pushResult );
+            }
+        }
+        
+        return new TagScmResult( lsConsumer.getListedFiles(), tagResult );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/main/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommand.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/command/tag/BazaarTagCommand.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.java?rev=806087&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.java
Thu Aug 20 08:41:15 2009
@@ -0,0 +1,38 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you 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.
+ */
+
+package org.apache.maven.scm.provider.bazaar.command.tag;
+
+import org.apache.maven.scm.provider.bazaar.BazaarRepoUtils;
+import org.apache.maven.scm.tck.command.tag.TagCommandTckTest;
+
+/**
+ * Tests for bzr tag command requiring an actual bzr client.
+ * 
+ * @author <a href="mailto:johan.walles@gmail.com">Johan Walles</a>
+ */
+public class BazaarTagCommandTckTest extends TagCommandTckTest {
+    public String getScmUrl() throws Exception {
+        return BazaarRepoUtils.getScmUrl();
+    }
+    
+    public void initRepo() throws Exception {
+        BazaarRepoUtils.initRepo();
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-bazaar/src/test/java/org/apache/maven/scm/provider/bazaar/command/tag/BazaarTagCommandTckTest.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/tag/BazaarTagCommandTckTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision



Mime
View raw message