maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken...@apache.org
Subject svn commit: r453277 - in /maven/scm/trunk: maven-scm-api/src/main/java/org/apache/maven/scm/repository/ maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/ maven-scm-providers/mave...
Date Thu, 05 Oct 2006 16:07:30 GMT
Author: kenney
Date: Thu Oct  5 09:07:28 2006
New Revision: 453277

URL: http://svn.apache.org/viewvc?view=rev&rev=453277
Log:
PR: SCM-239

Support Subversion 1.4 working copies.

Approach: instead of hacking another parser for some internal
format I'm using 'svn info' which also provides the URL in a more
implementation-independent way.

Changes: (mentioned verbosely here since there are some api additions,
but everything is backwards compatible)

* Added support for 'svn info', only at the SVN level.

* Removed old and unused Entry/EntriesReader

* Added a protected 'getRepositoryURL' to AbstractSvnScmProvider.
  Different implementations may use different methods to return
  that URL.

* Removed testcase for constructing a provider for the TestSvnScmProvider:
  Now the code to actually get the repo url is not in the abstract base class,
  I didn't see the need to implement a method in TestSvnScmProvider just so
  we can test it; all other methods there return null anyway.

* Implemented the getRepositoryURL in SvnExeScmProvider using the output
  from SvnInfoScmCommand. This method _CAN_ throw an ScmException, since it's
  performing an SCM action.

* Modified ScmRepositoryException to extend ScmException (not strictly needed but seems
  logical to me), and added a new constructor with a Throwable cause parameter.

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java
  (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java
  (with props)
Removed:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/EntriesReader.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/util/Entry.java
Modified:
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java?view=diff&rev=453277&r1=453276&r2=453277
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java
Thu Oct  5 09:07:28 2006
@@ -16,6 +16,8 @@
  * limitations under the License.
  */
 
+import org.apache.maven.scm.ScmException;
+
 import java.util.List;
 
 /**
@@ -23,13 +25,18 @@
  * @version $Id$
  */
 public class ScmRepositoryException
-    extends Exception
+    extends ScmException
 {
     private List validationMessages;
 
     public ScmRepositoryException( String msg )
     {
         super( msg );
+    }
+
+    public ScmRepositoryException( String msg, Throwable cause )
+    {
+        super( msg, cause );
     }
 
     public ScmRepositoryException( String msg, List validationMessages )

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java?view=diff&rev=453277&r1=453276&r2=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/AbstractSvnScmProvider.java
Thu Oct  5 09:07:28 2006
@@ -33,17 +33,14 @@
 import org.apache.maven.scm.provider.AbstractScmProvider;
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.info.SvnInfoScmResult;
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
-import org.apache.maven.scm.provider.svn.util.EntriesReader;
-import org.apache.maven.scm.provider.svn.util.Entry;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.scm.repository.ScmRepositoryException;
 import org.apache.maven.scm.repository.UnknownRepositoryStructure;
 
 import java.io.File;
-import java.io.FileReader;
 import java.util.ArrayList;
-import java.util.Iterator;
 import java.util.List;
 
 /**
@@ -104,47 +101,24 @@
             throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory."
);
         }
 
-        File svnDirectory = new File( path, ".svn" );
-
-        if ( !svnDirectory.exists() )
+        if ( !new File( path, ".svn" ).exists() )
         {
             throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a svn checkout
directory." );
         }
 
-        File svnEntriesFile = new File( svnDirectory, "entries" );
-
-        String svnUrl = null;
-
         try
         {
-            FileReader reader = new FileReader( svnEntriesFile );
-
-            EntriesReader entriesReader = new EntriesReader();
-
-            List entries = entriesReader.read( reader );
-
-            for ( Iterator i = entries.iterator(); i.hasNext(); )
-            {
-                Entry svnEntry = (Entry) i.next();
-
-                if ( "".equals( svnEntry.getName() ) )
-                {
-                    svnUrl = svnEntry.getUrl();
-                }
-            }
+            return makeProviderScmRepository( getRepositoryURL( path ), ':' );
         }
-        catch ( Exception e )
+        catch ( ScmException e )
         {
-            ScmRepositoryException ex = new ScmRepositoryException( "Can't read " + svnEntriesFile.getAbsolutePath()
);
-
-            ex.setStackTrace( e.getStackTrace() );
-
-            throw ex;
+            // XXX We should allow throwing of SCMException.
+            throw new ScmRepositoryException( "Error executing info command", e );
         }
-
-        return makeProviderScmRepository( svnUrl, ':' );
     }
 
+    protected abstract String getRepositoryURL( File path )
+        throws ScmException;
 
     public List validateScmUrl( String scmSpecificUrl, char delimiter )
     {
@@ -355,6 +329,16 @@
         SvnCommand cmd = getListCommand();
 
         return (ListScmResult) executeCommand( cmd, repository, fileSet, parameters );
+    }
+
+    protected abstract SvnCommand getInfoCommand();
+
+    public SvnInfoScmResult info( ScmRepository repository, ScmFileSet fileSet, CommandParameters
parameters )
+        throws ScmException
+    {
+        SvnCommand cmd = getInfoCommand();
+
+        return (SvnInfoScmResult) executeCommand( cmd, repository, fileSet, parameters );
     }
 
 }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java?view=auto&rev=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java
Thu Oct  5 09:07:28 2006
@@ -0,0 +1,146 @@
+package org.apache.maven.scm.provider.svn.command.info;
+
+/*
+ * 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.
+ */
+
+/**
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ *
+ * $Id$
+ */
+public class SvnInfoItem
+{
+    private String path;
+
+    private String url;
+
+    private String repositoryRoot;
+
+    private String repositoryUUID;
+
+    private String revision;
+
+    private String nodeKind;
+
+    private String schedule;
+
+    private String lastChangedAuthor;
+
+    private String lastChangedRevision;
+
+    private String lastChangedDate;
+
+    public String getPath()
+    {
+        return path;
+    }
+
+    public void setPath( String path )
+    {
+        this.path = path;
+    }
+
+    public String getURL()
+    {
+        return url;
+    }
+
+    public void setURL( String url )
+    {
+        this.url = url;
+    }
+
+    public String getRepositoryRoot()
+    {
+        return repositoryRoot;
+    }
+
+    public void setRepositoryRoot( String repositoryRoot )
+    {
+        this.repositoryRoot = repositoryRoot;
+    }
+
+    public String getRepositoryUUID()
+    {
+        return repositoryUUID;
+    }
+
+    public void setRepositoryUUID( String repositoryUUID )
+    {
+        this.repositoryUUID = repositoryUUID;
+    }
+
+    public String getRevision()
+    {
+        return revision;
+    }
+
+    public void setRevision( String revision )
+    {
+        this.revision = revision;
+    }
+
+    public String getNodeKind()
+    {
+        return nodeKind;
+    }
+
+    public void setNodeKind( String nodeKind )
+    {
+        this.nodeKind = nodeKind;
+    }
+
+    public String getSchedule()
+    {
+        return schedule;
+    }
+
+    public void setSchedule( String schedule )
+    {
+        this.schedule = schedule;
+    }
+
+    public String getLastChangedAuthor()
+    {
+        return lastChangedAuthor;
+    }
+
+    public void setLastChangedAuthor( String lastChangedAuthor )
+    {
+        this.lastChangedAuthor = lastChangedAuthor;
+    }
+
+    public String getLastChangedRevision()
+    {
+        return lastChangedRevision;
+    }
+
+    public void setLastChangedRevision( String lastChangedRevision )
+    {
+        this.lastChangedRevision = lastChangedRevision;
+    }
+
+    public String getLastChangedDate()
+    {
+        return lastChangedDate;
+    }
+
+    public void setLastChangedDate( String lastChangedDate )
+    {
+        this.lastChangedDate = lastChangedDate;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoItem.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java?view=auto&rev=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java
Thu Oct  5 09:07:28 2006
@@ -0,0 +1,59 @@
+package org.apache.maven.scm.provider.svn.command.info;
+
+import org.apache.maven.scm.ScmResult;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/*
+ * 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.
+ */
+
+/**
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ *
+ * $Id$
+ */
+public class SvnInfoScmResult
+    extends ScmResult
+{
+    private List infoItems;
+
+    public SvnInfoScmResult( String commandLine, String providerMessage, String commandOutput,
boolean success )
+    {
+        super( commandLine, providerMessage, commandOutput, success );
+
+        infoItems = new ArrayList( 0 );
+    }
+
+    public SvnInfoScmResult( String commandLine, List files )
+    {
+        super( commandLine, null, null, true );
+
+        this.infoItems = files;
+    }
+
+    public SvnInfoScmResult( List files, ScmResult result )
+    {
+        super( result );
+
+        this.infoItems = files;
+    }
+
+    public List getInfoItems()
+    {
+        return infoItems;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/main/java/org/apache/maven/scm/provider/svn/command/info/SvnInfoScmResult.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java?view=diff&rev=453277&r1=453276&r2=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/TestSvnScmProvider.java
Thu Oct  5 09:07:28 2006
@@ -18,6 +18,8 @@
 
 import org.apache.maven.scm.provider.svn.command.SvnCommand;
 
+import java.io.File;
+
 public class TestSvnScmProvider
     extends AbstractSvnScmProvider
 {
@@ -67,6 +69,16 @@
     }
 
     protected SvnCommand getListCommand()
+    {
+        return null;
+    }
+
+    protected SvnCommand getInfoCommand()
+    {
+        return null;
+    }
+
+    protected String getRepositoryURL( File path )
     {
         return null;
     }

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java?view=diff&rev=453277&r1=453276&r2=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svn-commons/src/test/java/org/apache/maven/scm/provider/svn/repository/SvnScmProviderRepositoryTest.java
Thu Oct  5 09:07:28 2006
@@ -18,12 +18,9 @@
 
 import org.apache.maven.scm.ScmTestCase;
 import org.apache.maven.scm.manager.ScmManager;
-import org.apache.maven.scm.provider.svn.TestSvnScmProvider;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.apache.maven.scm.repository.ScmRepositoryException;
 
-import java.io.File;
-
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
  * @version $Id$
@@ -120,18 +117,6 @@
         throws Exception
     {
         testIllegalUrl( "file:/tmp/svn" );
-    }
-
-    // ----------------------------------------------------------------------
-    // Testing provider from path
-    // ----------------------------------------------------------------------
-
-    public void testSvnFromPath()
-        throws Exception
-    {
-        TestSvnScmProvider provider = new TestSvnScmProvider();
-
-        provider.makeProviderScmRepository( new File( getBasedir() ) );
     }
 
     // ----------------------------------------------------------------------

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java?view=diff&rev=453277&r1=453276&r2=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/SvnExeScmProvider.java
Thu Oct  5 09:07:28 2006
@@ -16,18 +16,26 @@
  * limitations under the License.
  */
 
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.provider.svn.AbstractSvnScmProvider;
 import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.info.SvnInfoItem;
+import org.apache.maven.scm.provider.svn.command.info.SvnInfoScmResult;
 import org.apache.maven.scm.provider.svn.svnexe.command.add.SvnAddCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.changelog.SvnChangeLogCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.checkin.SvnCheckInCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.checkout.SvnCheckOutCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.diff.SvnDiffCommand;
+import org.apache.maven.scm.provider.svn.svnexe.command.info.SvnInfoCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.list.SvnListCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.remove.SvnRemoveCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.status.SvnStatusCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.tag.SvnTagCommand;
 import org.apache.maven.scm.provider.svn.svnexe.command.update.SvnUpdateCommand;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+
+import java.io.File;
 
 /**
  * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
@@ -84,5 +92,29 @@
     protected SvnCommand getListCommand()
     {
         return new SvnListCommand();
+    }
+
+    public SvnCommand getInfoCommand()
+    {
+        return new SvnInfoCommand();
+    }
+
+    /**
+     * Implements retrieving the repository url for a certain path using the 'svn info' command.
+     */
+    protected String getRepositoryURL( File path )
+        throws ScmException
+    {
+        // Note: I need to supply just 1 absolute path, but ScmFileSet won't let me without
+        // a basedir (which isn't used here anyway), so use a dummy file.
+        SvnInfoScmResult result = info( null, new ScmFileSet( new File( "" ), path ), null
);
+
+        if ( result.getInfoItems().size() != 1 )
+        {
+            throw new ScmRepositoryException( "Cannot find URL: "
+                + ( result.getInfoItems().size() == 0 ? "no" : "multiple" ) + " items returned
by the info command" );
+        }
+
+        return ( (SvnInfoItem) result.getInfoItems().get( 0 ) ).getURL();
     }
 }

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java?view=auto&rev=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java
Thu Oct  5 09:07:28 2006
@@ -0,0 +1,126 @@
+package org.apache.maven.scm.provider.svn.svnexe.command.info;
+
+/*
+ * 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 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.AbstractCommand;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.svn.command.SvnCommand;
+import org.apache.maven.scm.provider.svn.command.info.SvnInfoScmResult;
+import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
+import org.apache.maven.scm.provider.svn.svnexe.command.SvnCommandLineUtils;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.util.Iterator;
+
+/**
+ *
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ *
+ * $Id$
+ */
+public class SvnInfoCommand
+    extends AbstractCommand
+    implements SvnCommand
+{
+    private static final File TMP_DIR = new File( System.getProperty( "java.io.tmpdir" )
);
+
+    protected ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                        CommandParameters parameters )
+        throws ScmException
+    {
+        return executeInfoCommand( (SvnScmProviderRepository) repository, fileSet, parameters,
false, null );
+    }
+
+    public SvnInfoScmResult executeInfoCommand( SvnScmProviderRepository repository, ScmFileSet
fileSet,
+                                                CommandParameters parameters, boolean recursive,
String revision )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( repository, fileSet, recursive, revision );
+
+        SvnInfoConsumer consumer = new SvnInfoConsumer();
+
+        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+
+        getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) );
+        getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath()
);
+
+        int exitCode;
+
+        try
+        {
+            exitCode = SvnCommandLineUtils.execute( cl, consumer, stderr, getLogger() );
+        }
+        catch ( CommandLineException ex )
+        {
+            throw new ScmException( "Error while executing command.", ex );
+        }
+
+        if ( exitCode != 0 )
+        {
+            return new SvnInfoScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(),
false );
+        }
+
+        return new SvnInfoScmResult( cl.toString(), consumer.getInfoItems() );
+    }
+
+    private static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet
fileSet,
+                                                  boolean recursive, String revision )
+    {
+        Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( TMP_DIR, repository );
+
+        cl.createArgument().setValue( "info" );
+
+        if ( recursive )
+        {
+            cl.createArgument().setValue( "--recursive" );
+        }
+
+        if ( StringUtils.isNotEmpty( revision ) )
+        {
+            cl.createArgument().setValue( "-r" );
+
+            cl.createArgument().setValue( revision );
+        }
+
+        Iterator it = fileSet.getFileList().iterator();
+
+        while ( it.hasNext() )
+        {
+            File file = (File) it.next();
+
+            if ( repository == null )
+            {
+                cl.createArgument().setValue( file.getPath() );
+            }
+            else
+            {
+                cl.createArgument().setValue( repository.getUrl() + "/" + file.getPath().replace(
'\\', '/' ) );
+            }
+        }
+
+        return cl;
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

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

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java?view=auto&rev=453277
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java
Thu Oct  5 09:07:28 2006
@@ -0,0 +1,108 @@
+package org.apache.maven.scm.provider.svn.svnexe.command.info;
+
+/*
+ * 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 org.apache.maven.scm.provider.svn.command.info.SvnInfoItem;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:kenney@apache.org">Kenney Westerhof</a>
+ * @version $Id$
+ */
+public class SvnInfoConsumer
+    implements StreamConsumer
+{
+    private List infoItems = new ArrayList();
+
+    private SvnInfoItem currentItem = new SvnInfoItem();
+
+    public void consumeLine( String s )
+    {
+        if ( s.equals( "" ) )
+        {
+            if ( currentItem != null )
+            {
+                infoItems.add( currentItem );
+            }
+
+            currentItem = new SvnInfoItem();
+        }
+        else if ( s.startsWith( "Path: " ) )
+        {
+            currentItem.setPath( getValue( s ) );
+        }
+        else if ( s.startsWith( "URL: " ) )
+        {
+            currentItem.setURL( getValue( s ) );
+        }
+        else if ( s.startsWith( "Repository Root: " ) )
+        {
+            currentItem.setRepositoryRoot( getValue( s ) );
+        }
+        else if ( s.startsWith( "Repository UUID: " ) )
+        {
+            currentItem.setRepositoryUUID( getValue( s ) );
+        }
+        else if ( s.startsWith( "Revision: " ) )
+        {
+            currentItem.setRevision( getValue( s ) );
+        }
+        else if ( s.startsWith( "Node Kind: " ) )
+        {
+            currentItem.setNodeKind( getValue( s ) );
+        }
+        else if ( s.startsWith( "Schedule: " ) )
+        {
+            currentItem.setSchedule( getValue( s ) );
+        }
+        else if ( s.startsWith( "Last Changed Author: " ) )
+        {
+            currentItem.setLastChangedAuthor( getValue( s ) );
+        }
+        else if ( s.startsWith( "Last Changed Rev: " ) )
+        {
+            currentItem.setLastChangedRevision( getValue( s ) );
+        }
+        else if ( s.startsWith( "Last Changed Date: " ) )
+        {
+            currentItem.setLastChangedDate( getValue( s ) );
+        }
+    }
+
+    private static String getValue( String s )
+    {
+        int idx = s.indexOf( ": " );
+
+        if ( idx < 0 )
+        {
+            // FIXME: Can't throw any exceptions in consumeLine..
+            return null;
+        }
+        else
+        {
+            return s.substring( idx + 2 );
+        }
+    }
+
+    public List getInfoItems()
+    {
+        return infoItems;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/info/SvnInfoConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

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



Mime
View raw message