maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From car...@apache.org
Subject svn commit: r399931 - in /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/list/
Date Fri, 05 May 2006 03:29:31 GMT
Author: carlos
Date: Thu May  4 20:29:30 2006
New Revision: 399931

URL: http://svn.apache.org/viewcvs?rev=399931&view=rev
Log:
[SCM-183] Add list method to ScmProvider

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/list/SvnListCommand.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/list/SvnListConsumer.java
  (with props)
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

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/viewcvs/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?rev=399931&r1=399930&r2=399931&view=diff
==============================================================================
--- 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 May  4 20:29:30 2006
@@ -23,6 +23,7 @@
 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.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;
@@ -78,5 +79,10 @@
     protected SvnCommand getUpdateCommand()
     {
         return new SvnUpdateCommand();
+    }
+
+    protected SvnCommand getListCommand()
+    {
+        return new SvnListCommand();
     }
 }

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/list/SvnListCommand.java
URL: http://svn.apache.org/viewcvs/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/list/SvnListCommand.java?rev=399931&view=auto
==============================================================================
--- 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/list/SvnListCommand.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/list/SvnListCommand.java
Thu May  4 20:29:30 2006
@@ -0,0 +1,109 @@
+package org.apache.maven.scm.provider.svn.svnexe.command.list;
+
+/*
+ * Copyright 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 java.util.Iterator;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.list.AbstractListCommand;
+import org.apache.maven.scm.command.list.ListScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.svn.command.SvnCommand;
+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;
+
+/**
+ * Command to list files in SVN ( <code>svn list</code> command )
+ * 
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SvnListCommand
+    extends AbstractListCommand
+    implements SvnCommand
+{
+    private static final File TMP_DIR = new File( System.getProperty( "java.io.tmpdir" )
);
+
+    protected ListScmResult executeListCommand( ScmProviderRepository repository, ScmFileSet
fileSet, boolean recursive )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (SvnScmProviderRepository) repository, fileSet,
recursive, null );
+
+        SvnListConsumer consumer = new SvnListConsumer();
+
+        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 ListScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(),
false );
+        }
+
+        return new ListScmResult( cl.toString(), consumer.getFiles() );
+    }
+
+    static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet
fileSet, boolean recursive,
+                                          String revision )
+    {
+        Commandline cl = SvnCommandLineUtils.getBaseSvnCommandLine( TMP_DIR, repository );
+
+        cl.createArgument().setValue( "list" );
+
+        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();
+
+            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/list/SvnListCommand.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/list/SvnListCommand.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/list/SvnListConsumer.java
URL: http://svn.apache.org/viewcvs/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/list/SvnListConsumer.java?rev=399931&view=auto
==============================================================================
--- 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/list/SvnListConsumer.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/list/SvnListConsumer.java
Thu May  4 20:29:30 2006
@@ -0,0 +1,49 @@
+package org.apache.maven.scm.provider.svn.svnexe.command.list;
+
+/*
+ * Copyright 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.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+/**
+ * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a>
+ * @version $Id$
+ */
+public class SvnListConsumer
+    implements StreamConsumer
+{
+    private List files = new ArrayList();
+
+    // ----------------------------------------------------------------------
+    // StreamConsumer Implementation
+    // ----------------------------------------------------------------------
+
+    public void consumeLine( String line )
+    {
+        files.add( new ScmFile( line, ScmFileStatus.CHECKED_IN ) );
+    }
+
+    public List getFiles()
+    {
+        return files;
+    }
+
+}

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/list/SvnListConsumer.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/list/SvnListConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message