From scm-commitssandra01@example.org Mon Oct 09 07:55:57 2006 Return-Path: <scm-commitssandra01@example.org> Delivered-To: sandra01@example.org Received: (qmail 16402 invoked from network); 9 Oct 2006 07:55:57 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Oct 2006 07:55:57 -0000 Received: (qmail 45242 invoked by uid 500); 9 Oct 2006 07:55:57 -0000 Delivered-To: sandra01@example.org Received: (qmail 45221 invoked by uid 500); 9 Oct 2006 07:55:57 -0000 Mailing-List: contact sandra01@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:sandra01@example.org> List-Unsubscribe: <mailto:sandra01@example.org> List-Post: <mailto:sandra01@example.org> List-Id: <scm-commits.maven.apache.org> Reply-To: sandra01@example.org Delivered-To: mailing list sandra01@example.org Delivered-To: moderator for sandra01@example.org Received: (qmail 96748 invoked by uid 99); 5 Oct 2006 15:41:34 -0000 X-ASF-Spam-Status: No, hits=-9.4 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r453271 - 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: ./ checkin/ checkout/ update/ Date: Thu, 05 Oct 2006 15:41:29 -0000 To: sandra01@example.org From: sandra01@example.org X-Mailer: svnmailer-1.1.0 Message-Id: <sandra01@example.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kenney Date: Thu Oct 5 08:41:28 2006 New Revision: 453271 URL: http://svn.apache.org/viewvc?view=rev&rev=453271 Log: Fixed timing issue. While parsing the svn commandline output, checks are performed if files are files or directories. At the time of the check, those files may not have been written yet. Moved generic code to a new abstract base class, and added a method that filters the file list after the execution of the command is complete. 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/AbstractFileCheckingConsumer.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/command/SvnCommandLineUtils.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/command/checkin/SvnCheckInConsumer.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/command/checkout/SvnCheckOutConsumer.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/command/update/SvnUpdateCommand.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/command/update/SvnUpdateConsumer.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/AbstractFileCheckingConsumer.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/AbstractFileCheckingConsumer.java?view=auto&rev=453271 ============================================================================== --- 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/AbstractFileCheckingConsumer.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/AbstractFileCheckingConsumer.java Thu Oct 5 08:41:28 2006 @@ -0,0 +1,106 @@ +package org.apache.maven.scm.provider.svn.svnexe.command; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.log.ScmLogger; +import org.codehaus.plexus.util.cli.StreamConsumer; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +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:sandra01@example.org">Kenney Westerhof</a> + * + */ +public abstract class AbstractFileCheckingConsumer + implements StreamConsumer +{ + protected ScmLogger logger; + + protected File workingDirectory; + + private List files = new ArrayList(); + + protected int revision; + + private boolean filtered; + + public AbstractFileCheckingConsumer( ScmLogger logger, File workingDirectory ) + { + this.logger = logger; + this.workingDirectory = workingDirectory; + } + + public final void consumeLine( String line ) + { + if ( line.length() <= 3 ) + { + logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" + line + "'." ); + + return; + } + + parseLine( line ); + } + + protected abstract void parseLine( String line ); + + protected List getFiles() + { + if ( !filtered ) + { + for ( Iterator it = files.iterator(); it.hasNext(); ) + { + if ( !new File( workingDirectory, ( (ScmFile) it.next() ).getPath() ).isFile() ) + { + it.remove(); + } + } + + filtered = true; + } + + return files; + } + + protected final int parseInt( String revisionString ) + { + try + { + return Integer.parseInt( revisionString ); + } + catch ( NumberFormatException ex ) + { + return 0; + } + } + + protected void addFile( ScmFile file ) + { + files.add( file ); + } + + public final int getRevision() + { + return revision; + } + +} 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/AbstractFileCheckingConsumer.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/AbstractFileCheckingConsumer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" 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/command/SvnCommandLineUtils.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/SvnCommandLineUtils.java?view=diff&rev=453271&r1=453270&r2=453271 ============================================================================== --- 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/SvnCommandLineUtils.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/command/SvnCommandLineUtils.java Thu Oct 5 08:41:28 2006 @@ -62,14 +62,14 @@ cl.createArgument().setValue( SvnUtil.getSettings().getConfigDirectory() ); } - if ( !StringUtils.isEmpty( repository.getUser() ) ) + if ( repository != null && !StringUtils.isEmpty( repository.getUser() ) ) { cl.createArgument().setValue( "--username" ); cl.createArgument().setValue( repository.getUser() ); } - if ( !StringUtils.isEmpty( repository.getPassword() ) ) + if ( repository != null && !StringUtils.isEmpty( repository.getPassword() ) ) { cl.createArgument().setValue( "--password" ); 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/command/checkin/SvnCheckInConsumer.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/checkin/SvnCheckInConsumer.java?view=diff&rev=453271&r1=453270&r2=453271 ============================================================================== --- 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/checkin/SvnCheckInConsumer.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/command/checkin/SvnCheckInConsumer.java Thu Oct 5 08:41:28 2006 @@ -19,10 +19,9 @@ import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.log.ScmLogger; -import org.codehaus.plexus.util.cli.StreamConsumer; +import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; import java.io.File; -import java.util.ArrayList; import java.util.List; /** @@ -30,7 +29,7 @@ * @version $Id$ */ public class SvnCheckInConsumer - implements StreamConsumer + extends AbstractFileCheckingConsumer { private final static String SENDING_TOKEN = "Sending "; @@ -42,13 +41,6 @@ private final static String COMMITTED_REVISION_TOKEN = "Committed revision"; - private ScmLogger logger; - - private File workingDirectory; - - private List checkedInFiles = new ArrayList(); - - private int revision; // ---------------------------------------------------------------------- // @@ -56,26 +48,15 @@ public SvnCheckInConsumer( ScmLogger logger, File workingDirectory ) { - this.logger = logger; - - this.workingDirectory = workingDirectory; + super( logger, workingDirectory ); } // ---------------------------------------------------------------------- // StreamConsumer Implementation // ---------------------------------------------------------------------- - public void consumeLine( String line ) + protected void parseLine( String line ) { - logger.debug( line ); - - if ( line.length() <= 3 ) - { - logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" + line + "'." ); - - return; - } - String file; if ( line.startsWith( COMMITTED_REVISION_TOKEN ) ) @@ -110,38 +91,11 @@ return; } - // If the file isn't a file; don't add it. - if ( !new File( workingDirectory, file ).isFile() ) - { - return; - } - - checkedInFiles.add( new ScmFile( file, ScmFileStatus.CHECKED_IN ) ); + addFile( new ScmFile( file, ScmFileStatus.CHECKED_IN ) ); } public List getCheckedInFiles() { - return checkedInFiles; - } - - public int getRevision() - { - return revision; - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - private int parseInt( String revisionString ) - { - try - { - return Integer.parseInt( revisionString ); - } - catch ( NumberFormatException ex ) - { - return 0; - } + return getFiles(); } } 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/command/checkout/SvnCheckOutConsumer.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/checkout/SvnCheckOutConsumer.java?view=diff&rev=453271&r1=453270&r2=453271 ============================================================================== --- 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/checkout/SvnCheckOutConsumer.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/command/checkout/SvnCheckOutConsumer.java Thu Oct 5 08:41:28 2006 @@ -1,28 +1,11 @@ package org.apache.maven.scm.provider.svn.svnexe.command.checkout; -/* - * 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.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.log.ScmLogger; -import org.codehaus.plexus.util.cli.StreamConsumer; +import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; import java.io.File; -import java.util.ArrayList; import java.util.List; /** @@ -30,40 +13,17 @@ * @version $Id$ */ public class SvnCheckOutConsumer - implements StreamConsumer + extends AbstractFileCheckingConsumer { private final static String CHECKED_OUT_REVISION_TOKEN = "Checked out revision"; - private ScmLogger logger; - - private File workingDirectory; - - private List checkedOutFiles = new ArrayList(); - - private int revision; - public SvnCheckOutConsumer( ScmLogger logger, File workingDirectory ) { - this.logger = logger; - - this.workingDirectory = workingDirectory; + super( logger, workingDirectory ); } - // ---------------------------------------------------------------------- - // StreamConsumer Implementation - // ---------------------------------------------------------------------- - - public void consumeLine( String line ) + protected void parseLine( String line ) { - logger.debug( line ); - - if ( line.length() <= 3 ) - { - logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" + line + "'." ); - - return; - } - String statusString = line.substring( 0, 1 ); String file = line.substring( 3 ).trim(); @@ -74,14 +34,7 @@ { String revisionString = line.substring( CHECKED_OUT_REVISION_TOKEN.length() + 1, line.length() - 1 ); - try - { - revision = Integer.parseInt( revisionString ); - } - catch ( NumberFormatException ex ) - { - // ignored - } + revision = parseInt( revisionString ); return; } @@ -100,14 +53,7 @@ return; } - // If the file isn't a file; don't add it. - if ( !new File( workingDirectory, file ).isFile() ) - { - logger.debug( "Skipping non-file: " + file ); - return; - } - - checkedOutFiles.add( new ScmFile( file, status ) ); + addFile( new ScmFile( file, status ) ); } // ---------------------------------------------------------------------- @@ -116,11 +62,6 @@ public List getCheckedOutFiles() { - return checkedOutFiles; - } - - public int getRevision() - { - return revision; + return getFiles(); } } 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/command/update/SvnUpdateCommand.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/update/SvnUpdateCommand.java?view=diff&rev=453271&r1=453270&r2=453271 ============================================================================== --- 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/update/SvnUpdateCommand.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/command/update/SvnUpdateCommand.java Thu Oct 5 08:41:28 2006 @@ -102,7 +102,7 @@ } else { - // The tag specified does not appear to be numeric, so assume it refers + // The tag specified does not appear to be numeric, so assume it refers // to a branch/tag url and perform a switch operation rather than update cl.createArgument().setValue( "switch" ); cl.createArgument().setValue( SvnTagBranchUtils.resolveTagUrl( repository, tag ) ); 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/command/update/SvnUpdateConsumer.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/update/SvnUpdateConsumer.java?view=diff&rev=453271&r1=453270&r2=453271 ============================================================================== --- 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/update/SvnUpdateConsumer.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/command/update/SvnUpdateConsumer.java Thu Oct 5 08:41:28 2006 @@ -19,10 +19,9 @@ import org.apache.maven.scm.ScmFile; import org.apache.maven.scm.ScmFileStatus; import org.apache.maven.scm.log.ScmLogger; -import org.codehaus.plexus.util.cli.StreamConsumer; +import org.apache.maven.scm.provider.svn.svnexe.command.AbstractFileCheckingConsumer; import java.io.File; -import java.util.ArrayList; import java.util.List; /** @@ -30,21 +29,13 @@ * @version $Id$ */ public class SvnUpdateConsumer - implements StreamConsumer + extends AbstractFileCheckingConsumer { - private final static String UPDATED_TO_REVISION_TOKEN = "Updated to revision"; + private static final String UPDATED_TO_REVISION_TOKEN = "Updated to revision"; - private final static String AT_REVISION_TOKEN = "At revision"; + private static final String AT_REVISION_TOKEN = "At revision"; - private final static String RESTORED_TOKEN = "Restored"; - - private ScmLogger logger; - - private File workingDirectory; - - private List updatedFiles = new ArrayList(); - - private int revision; + private static final String RESTORED_TOKEN = "Restored"; // ---------------------------------------------------------------------- // @@ -52,26 +43,15 @@ public SvnUpdateConsumer( ScmLogger logger, File workingDirectory ) { - this.logger = logger; - - this.workingDirectory = workingDirectory; + super( logger, workingDirectory ); } // ---------------------------------------------------------------------- // StreamConsumer Implementation // ---------------------------------------------------------------------- - public void consumeLine( String line ) + protected void parseLine( String line ) { - logger.debug( line ); - - if ( line.length() <= 3 ) - { - logger.warn( "Unexpected input, the line must be at least three characters long. Line: '" + line + "'." ); - - return; - } - String statusString = line.substring( 0, 1 ); String file = line.substring( 3 ).trim(); @@ -117,39 +97,11 @@ return; } - // If the file isn't a file; don't add it. - if ( !new File( workingDirectory, file ).isFile() ) - { - logger.debug( "Skipping non-file: " + file ); - return; - } - - updatedFiles.add( new ScmFile( file, status ) ); + addFile(new ScmFile( file, status ) ); } public List getUpdatedFiles() { - return updatedFiles; - } - - public int getRevision() - { - return revision; - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - private int parseInt( String revisionString ) - { - try - { - return Integer.parseInt( revisionString ); - } - catch ( NumberFormatException ex ) - { - return 0; - } + return getFiles(); } } From scm-commitssandra01@example.org Mon Oct 09 07:56:06 2006 Return-Path: <scm-commitssandra01@example.org> Delivered-To: sandra01@example.org Received: (qmail 16441 invoked from network); 9 Oct 2006 07:56:06 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 9 Oct 2006 07:56:06 -0000 Received: (qmail 45345 invoked by uid 500); 9 Oct 2006 07:56:06 -0000 Delivered-To: sandra01@example.org Received: (qmail 45330 invoked by uid 500); 9 Oct 2006 07:56:06 -0000 Mailing-List: contact sandra01@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:sandra01@example.org> List-Unsubscribe: <mailto:sandra01@example.org> List-Post: <mailto:sandra01@example.org> List-Id: <scm-commits.maven.apache.org> Reply-To: sandra01@example.org Delivered-To: mailing list sandra01@example.org Delivered-To: moderator for sandra01@example.org Received: (qmail 59133 invoked by uid 99); 5 Oct 2006 16:07:37 -0000 X-ASF-Spam-Status: No, hits=-8.6 required=5.0 tests=ALL_TRUSTED,INFO_TLD,NO_REAL_NAME Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sandra01@example.org From: sandra01@example.org X-Mailer: svnmailer-1.1.0 Message-Id: <sandra01@example.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N 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:sandra01@example.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:sandra01@example.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:sandra01@example.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:sandra01@example.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:sandra01@example.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:sandra01@example.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" From scm-commitssandra01@example.org Tue Oct 10 08:13:35 2006 Return-Path: <scm-commitssandra01@example.org> Delivered-To: sandra01@example.org Received: (qmail 13974 invoked from network); 10 Oct 2006 08:13:34 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 10 Oct 2006 08:13:34 -0000 Received: (qmail 24578 invoked by uid 500); 10 Oct 2006 08:13:34 -0000 Delivered-To: sandra01@example.org Received: (qmail 24537 invoked by uid 500); 10 Oct 2006 08:13:34 -0000 Mailing-List: contact sandra01@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:sandra01@example.org> List-Unsubscribe: <mailto:sandra01@example.org> List-Post: <mailto:sandra01@example.org> List-Id: <scm-commits.maven.apache.org> Reply-To: sandra01@example.org Delivered-To: mailing list sandra01@example.org Received: (qmail 24524 invoked by uid 99); 10 Oct 2006 08:13:34 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2006 01:13:34 -0700 X-ASF-Spam-Status: No, hits=-9.4 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: local policy) Received: from [83.161.120.155] (HELO eris.apache.org) (83.161.120.155) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Oct 2006 01:13:33 -0700 Received: by eris.apache.org (Postfix, from userid 65534) id 0B4E81A981A; Tue, 10 Oct 2006 01:13:13 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r454658 - /maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.java Date: Tue, 10 Oct 2006 08:13:12 -0000 To: sandra01@example.org From: sandra01@example.org X-Mailer: svnmailer-1.1.0 Message-Id: <sandra01@example.org> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kenney Date: Tue Oct 10 01:13:11 2006 New Revision: 454658 URL: http://svn.apache.org/viewvc?view=rev&rev=454658 Log: PR: SCM-242 Fix NPE due to assumption that ScmRepositoryException.getValidationMessages() != null. Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/repository/ScmRepositoryException.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=454658&r1=454657&r2=454658 ============================================================================== --- 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 Tue Oct 10 01:13:11 2006 @@ -18,6 +18,7 @@ import org.apache.maven.scm.ScmException; +import java.util.Collections; import java.util.List; /** @@ -27,7 +28,7 @@ public class ScmRepositoryException extends ScmException { - private List validationMessages; + private List validationMessages = Collections.EMPTY_LIST; public ScmRepositoryException( String msg ) { From scm-commitssandra01@example.org Sun Oct 15 14:34:48 2006 Return-Path: <scm-commitssandra01@example.org> Delivered-To: sandra01@example.org Received: (qmail 36621 invoked from network); 15 Oct 2006 14:34:48 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 15 Oct 2006 14:34:48 -0000 Received: (qmail 45360 invoked by uid 500); 15 Oct 2006 14:34:47 -0000 Delivered-To: sandra01@example.org Received: (qmail 45335 invoked by uid 500); 15 Oct 2006 14:34:47 -0000 Mailing-List: contact sandra01@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:sandra01@example.org> List-Unsubscribe: <mailto:sandra01@example.org> List-Post: <mailto:sandra01@example.org> List-Id: <scm-commits.maven.apache.org> Reply-To: sandra01@example.org Delivered-To: mailing list sandra01@example.org Delivered-To: moderator for sandra01@example.org Received: (qmail 78803 invoked by uid 99); 5 Oct 2006 12:45:13 -0000 X-ASF-Spam-Status: No, hits=-9.3 required=5.0 tests=ALL_TRUSTED,NO_REAL_NAME,SUBJECT_NOVOWEL Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r453208 - /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 Date: Thu, 05 Oct 2006 12:44:06 -0000 To: sandra01@example.org From: sandra01@example.org X-Mailer: svnmailer-1.1.0 Message-Id: <sandra01@example.org> X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N Author: kenney Date: Thu Oct 5 05:44:05 2006 New Revision: 453208 URL: http://svn.apache.org/viewvc?view=rev&rev=453208 Log: Fix & Detect NPE 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 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=453208&r1=453207&r2=453208 ============================================================================== --- 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 05:44:05 2006 @@ -48,7 +48,7 @@ /** * SCM Provider for Subversion - * + * * @author <a href="mailto:sandra01@example.org">Emmanuel Venisse</a> * @version $Id$ */ @@ -94,7 +94,12 @@ public ScmProviderRepository makeProviderScmRepository( File path ) throws ScmRepositoryException, UnknownRepositoryStructure { - if ( path == null || !path.isDirectory() ) + if ( path == null ) + { + throw new NullPointerException( "Path argument is null" ); + } + + if ( !path.isDirectory() ) { throw new ScmRepositoryException( path.getAbsolutePath() + " isn't a valid directory." ); } From scm-commitssandra01@example.org Fri Oct 27 23:01:53 2006 Return-Path: <scm-commitssandra01@example.org> Delivered-To: sandra01@example.org Received: (qmail 85820 invoked from network); 27 Oct 2006 23:01:53 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (83.161.120.155) by minotaur.apache.org with SMTP; 27 Oct 2006 23:01:53 -0000 Received: (qmail 42735 invoked by uid 500); 27 Oct 2006 23:02:03 -0000 Delivered-To: sandra01@example.org Received: (qmail 42694 invoked by uid 500); 27 Oct 2006 23:02:03 -0000 Mailing-List: contact sandra01@example.org; run by ezmlm Precedence: bulk List-Help: <mailto:sandra01@example.org> List-Unsubscribe: <mailto:sandra01@example.org> List-Post: <mailto:sandra01@example.org> List-Id: <scm-commits.maven.apache.org> Reply-To: sandra01@example.org Delivered-To: mailing list sandra01@example.org Delivered-To: moderator for sandra01@example.org Received: (qmail 33403 invoked by uid 99); 27 Oct 2006 22:55:28 -0000 X-ASF-Spam-Status: No, hits=0.6 required=10.0 tests=NO_REAL_NAME X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r468577 [2/2] - in /maven/scm/trunk/sandbox/maven-scm-provider-hg: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/scm/ src/main/java/org/apache/ma... Date: Fri, 27 Oct 2006 22:54:51 -0000 To: sandra01@example.org From: sandra01@example.org X-Mailer: svnmailer-1.1.0 Message-Id: <sandra01@example.org> X-Virus-Checked: Checked by ClamAV on apache.org Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,159 @@ +package org.apache.maven.scm.provider.hg.command.diff; + +/* + * 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.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.log.ScmLogger; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgDiffConsumer + extends HgConsumer +{ + + // private final static String MODIFIED_FILE_TOKEN = "=== modified file "; + + private final static String INDEX_TOKEN = "diff -r "; + + private final static String FILE_SEPARATOR_TOKEN = "==="; + + private final static String START_REVISION_TOKEN = "---"; + + private final static String END_REVISION_TOKEN = "+++"; + + private final static String ADDED_LINE_TOKEN = "+"; + + private final static String REMOVED_LINE_TOKEN = "-"; + + private final static String UNCHANGED_LINE_TOKEN = " "; + + private final static String CHANGE_SEPARATOR_TOKEN = "@@"; + + private final static String NO_NEWLINE_TOKEN = "\\ No newline at end of file"; + + private final static int HASH_ID_LEN = 12; + + private ScmLogger logger; + + private String currentFile; + + private StringBuffer currentDifference; + + private List changedFiles = new ArrayList(); + + private Map differences = new HashMap(); + + private StringBuffer patch = new StringBuffer(); + + private File workingDirectory; + + + public HgDiffConsumer( ScmLogger logger, File workingDirectory ) + { + super( logger ); + this.logger = logger; + this.workingDirectory = workingDirectory; + } + + // ---------------------------------------------------------------------- + // StreamConsumer Implementation + // ---------------------------------------------------------------------- + + public void consumeLine( String line ) + { + if ( line.startsWith( INDEX_TOKEN ) ) + { + // start a new file + currentFile = line.substring( INDEX_TOKEN.length() + HASH_ID_LEN + 1 ); + + changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) ); + + currentDifference = new StringBuffer(); + + differences.put( currentFile, currentDifference ); + + patch.append( line ).append( "\n" ); + + return; + } + + if ( currentFile == null ) + { + logger.warn( "Unparseable line: '" + line + "'" ); + patch.append( line ).append( "\n" ); + return; + } + + if ( line.startsWith( FILE_SEPARATOR_TOKEN ) ) + { + // skip + patch.append( line ).append( "\n" ); + } + else if ( line.startsWith( START_REVISION_TOKEN ) ) + { + // skip, though could parse to verify filename, start revision + patch.append( line ).append( "\n" ); + } + else if ( line.startsWith( END_REVISION_TOKEN ) ) + { + // skip, though could parse to verify filename, end revision + patch.append( line ).append( "\n" ); + } + else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN ) || + line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) || + line.equals( NO_NEWLINE_TOKEN ) ) + { + // add to buffer + currentDifference.append( line ).append( "\n" ); + patch.append( line ).append( "\n" ); + } + else + { + // TODO: handle property differences + + logger.warn( "Unparseable line: '" + line + "'" ); + patch.append( line ).append( "\n" ); + // skip to next file + currentFile = null; + currentDifference = null; + } + } + + public List getChangedFiles() + { + return changedFiles; + } + + public Map getDifferences() + { + return differences; + } + + public String getPatch() + { + return patch.toString(); + } +} Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/diff/HgDiffConsumer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,50 @@ +package org.apache.maven.scm.provider.hg.command.remove; + +/* + * 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.ScmException; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmResult; +import org.apache.maven.scm.command.remove.AbstractRemoveCommand; +import org.apache.maven.scm.command.remove.RemoveScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.hg.HgUtils; +import org.apache.maven.scm.provider.hg.command.HgCommand; + +import java.io.File; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgRemoveCommand + extends AbstractRemoveCommand + implements HgCommand +{ + protected ScmResult executeRemoveCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message ) + throws ScmException + { + + String[] command = new String[] { REMOVE_CMD }; + HgUtils.expandCommandLine( command, fileSet ); + + File workingDir = fileSet.getBasedir(); + HgRemoveConsumer consumer = new HgRemoveConsumer( getLogger(), workingDir ); + + ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, command ); + return new RemoveScmResult( consumer.getRemovedFiles(), result ); + } +} Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveCommand.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,67 @@ +package org.apache.maven.scm.provider.hg.command.remove; + +/* + * 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.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.log.ScmLogger; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgRemoveConsumer + extends HgConsumer +{ + private final File workingDir; + + private final List removedFiles = new ArrayList(); + + public HgRemoveConsumer( ScmLogger logger, File workingDir ) + { + super( logger ); + this.workingDir = workingDir; + } + + public void doConsume( ScmFileStatus status, String trimmedLine ) + { + if ( status != null && status == ScmFileStatus.DELETED ) + { + //Only include real files (not directories) + File tmpFile = new File( workingDir, trimmedLine ); + if ( !tmpFile.exists() ) + { + getLogger().warn( "Not a file: " + tmpFile + ". Ignored" ); + } + else + { + ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.DELETED ); + getLogger().info( scmFile.toString() ); + removedFiles.add( scmFile ); + } + } + } + + public List getRemovedFiles() + { + return removedFiles; + } +} \ No newline at end of file Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/remove/HgRemoveConsumer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,54 @@ +package org.apache.maven.scm.provider.hg.command.status; + +/* + * 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.ScmException; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmResult; +import org.apache.maven.scm.command.status.AbstractStatusCommand; +import org.apache.maven.scm.command.status.StatusScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.hg.HgUtils; +import org.apache.maven.scm.provider.hg.command.HgCommand; + +import java.io.File; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgStatusCommand + extends AbstractStatusCommand + implements HgCommand +{ + + public HgStatusCommand() + { + super(); + } + + public StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) + throws ScmException + { + + File workingDir = fileSet.getBasedir(); + HgStatusConsumer consumer = new HgStatusConsumer( getLogger(), workingDir ); + String[] statusCmd = new String[] { STATUS_CMD }; + ScmResult result = HgUtils.execute( consumer, getLogger(), workingDir, statusCmd ); + + return new StatusScmResult( consumer.getStatus(), result ); + } +} Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusCommand.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,69 @@ +package org.apache.maven.scm.provider.hg.command.status; + +/* + * 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.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.log.ScmLogger; +import org.apache.maven.scm.provider.hg.command.HgConsumer; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +class HgStatusConsumer + extends HgConsumer +{ + private final List repositoryStatus = new ArrayList(); + + private final File workingDir; + + + HgStatusConsumer( ScmLogger logger, File workingDir ) + { + super( logger ); + this.workingDir = workingDir; + } + + public void doConsume( ScmFileStatus status, String trimmedLine ) + { + //Only include real files (not directories) + File tmpFile = new File( workingDir, trimmedLine ); + if ( !tmpFile.exists() ) + { + getLogger().info( "Not a file: " + tmpFile + ". Ignoring" ); + } + else if ( tmpFile.isDirectory() ) + { + getLogger().info( "New directory added: " + tmpFile ); + } + else + { + ScmFile scmFile = new ScmFile( trimmedLine, status ); + getLogger().info( scmFile.toString() ); + repositoryStatus.add( scmFile ); + } + } + + List getStatus() + { + return repositoryStatus; + } +} Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/status/HgStatusConsumer.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,106 @@ +package org.apache.maven.scm.provider.hg.command.update; + +/* + * 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.ScmException; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmResult; +import org.apache.maven.scm.command.changelog.ChangeLogCommand; +import org.apache.maven.scm.command.update.AbstractUpdateCommand; +import org.apache.maven.scm.command.update.UpdateScmResult; +import org.apache.maven.scm.command.update.UpdateScmResultWithRevision; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.hg.HgUtils; +import org.apache.maven.scm.provider.hg.command.HgCommand; +import org.apache.maven.scm.provider.hg.command.HgConsumer; +import org.apache.maven.scm.provider.hg.command.changelog.HgChangeLogCommand; +import org.apache.maven.scm.provider.hg.command.diff.HgDiffConsumer; +import org.codehaus.plexus.util.StringUtils; + +import java.io.File; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgUpdateCommand + extends AbstractUpdateCommand + implements HgCommand +{ + + protected UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag ) + throws ScmException + { + + if ( !StringUtils.isEmpty( tag ) ) + { + throw new ScmException( "This provider can't handle tags." ); + } + + File workingDir = fileSet.getBasedir(); + + // Update branch + String[] update_cmd = new String[] { HgCommand.PULL_CMD }; + ScmResult updateResult = HgUtils.execute( new HgConsumer( getLogger() ), getLogger(), workingDir, + update_cmd ); + + if ( !updateResult.isSuccess() ) + { + return new UpdateScmResult( null, null, updateResult ); + } + + // Find changes from last revision + int currentRevision = HgUtils.getCurrentRevisionNumber( getLogger(), workingDir ); + int previousRevision = currentRevision - 1; + String[] diffCmd = new String[] { DIFF_CMD, REVISION_OPTION, "" + previousRevision }; + HgDiffConsumer diffConsumer = new HgDiffConsumer( getLogger(), workingDir ); + ScmResult diffResult = HgUtils.execute( diffConsumer, getLogger(), workingDir, diffCmd ); + + // Now translate between diff and update file status + List updatedFiles = new ArrayList(); + List changes = new ArrayList(); + List diffFiles = diffConsumer.getChangedFiles(); + Map diffChanges = diffConsumer.getDifferences(); + for ( Iterator it = diffFiles.iterator(); it.hasNext(); ) + { + ScmFile file = (ScmFile) it.next(); + changes.add( diffChanges.get( file.getPath() ) ); + if ( file.getStatus() == ScmFileStatus.MODIFIED ) + { + updatedFiles.add( new ScmFile( file.getPath(), ScmFileStatus.PATCHED ) ); + } + else + { + updatedFiles.add( file ); + } + } + + return new UpdateScmResultWithRevision( updatedFiles, changes, String.valueOf( currentRevision ), diffResult ); + } + + protected ChangeLogCommand getChangeLogCommand() + { + HgChangeLogCommand command = new HgChangeLogCommand(); + command.setLogger( getLogger() ); + return command; + } +} Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/command/update/HgUpdateCommand.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java URL: http://svn.apache.org/viewvc/maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java?view=auto&rev=468577 ============================================================================== --- maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java (added) +++ maven/scm/trunk/sandbox/maven-scm-provider-hg/src/main/java/org/apache/maven/scm/provider/hg/repository/HgScmProviderRepository.java Fri Oct 27 15:54:48 2006 @@ -0,0 +1,255 @@ +package org.apache.maven.scm.provider.hg.repository; + +/* + * 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.ScmProviderRepositoryWithHost; +import org.codehaus.plexus.util.StringUtils; + +import java.io.File; + +/** + * @author <a href="mailto:sandra01@example.org">thurner rupert</a> + */ +public class HgScmProviderRepository + extends ScmProviderRepositoryWithHost +{ + //Known and tested protocols + private static final String FILE = ""; + + private static final String SFTP = "sftp://"; + + private static final String FTP = "ftp://"; + + private static final String AFTP = "aftp://"; + + private static final String HTTP = "http://"; + + private static final String HTTPS = "https://"; + + private final String path; + + private final String protocol; + + private final String orgUrl; + + public HgScmProviderRepository( String url ) + { + orgUrl = url; + protocol = getProtocol( url ); + path = parseUrl( url ); + } + + public String getURI() + { + return protocol + (needsAuthentication() ? addUser() + addPassword() + addAt() : "") + addHost() + addPort()
{'source': 'Apache Software Foundation Public Mail Archives'}