You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by br...@apache.org on 2005/01/12 12:17:00 UTC
cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/update CvsUpdateCommandTest.java
brett 2005/01/12 03:17:00
Modified: maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff
SvnDiffConsumer.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/add
CvsAddCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog
CvsChangeLogCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkin
CvsCheckInCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkout
CvsCheckOutCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag
CvsTagCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/update
CvsUpdateCommand.java
maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/changelog
CvsChangeLogCommandTest.java
maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/update
CvsUpdateCommandTest.java
Added: maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff
CvsDiffCommand.java CvsDiffCommandTckTest.java
CvsDiffConsumer.java
Log:
implement diff for CVS, add "-f" to all CVS commands
Revision Changes Path
1.3 +7 -10 maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java
Index: SvnDiffConsumer.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SvnDiffConsumer.java 12 Jan 2005 10:30:53 -0000 1.2
+++ SvnDiffConsumer.java 12 Jan 2005 11:16:59 -0000 1.3
@@ -28,12 +28,10 @@
import java.util.Map;
/**
- * @todo share with CVS
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
*/
-public class SvnDiffConsumer
- implements StreamConsumer
+public class SvnDiffConsumer implements StreamConsumer
{
//
// Index: plugin.jelly
@@ -97,7 +95,7 @@
{
// start a new file
currentFile = line.substring( INDEX_TOKEN.length() );
-
+
changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) );
currentDifference = new StringBuffer();
@@ -106,7 +104,7 @@
return;
}
-
+
if ( currentFile == null )
{
logger.warn( "Unparseable line: '" + line + "'" );
@@ -123,18 +121,17 @@
}
else if ( line.startsWith( END_REVISION_TOKEN ) )
{
- // skip, though could parse to verify filename, start revision
+ // skip, though could parse to verify filename, end revision
}
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 ) )
+ line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN ) ||
+ line.equals( NO_NEWLINE_TOKEN ) )
{
// add to buffer
currentDifference.append( line ).append( "\n" );
}
else
{
- // TODO: append the "no new line" part
// TODO: handle property differences
logger.warn( "Unparseable line: '" + line + "'" );
1.2 +8 -7 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/add/CvsAddCommand.java
Index: CvsAddCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/add/CvsAddCommand.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- CvsAddCommand.java 30 Dec 2004 13:12:00 -0000 1.1
+++ CvsAddCommand.java 12 Jan 2005 11:16:59 -0000 1.2
@@ -35,15 +35,14 @@
import java.util.List;
/**
- * @todo separate the CVSlib stuff from the cvs command line so it is clear what needs to be updated eventually
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id$
+ * @todo separate the CVSlib stuff from the cvs command line so it is clear what needs to be updated eventually
*/
-public class CvsAddCommand
- extends AbstractAddCommand
- implements CvsCommand
+public class CvsAddCommand extends AbstractAddCommand implements CvsCommand
{
- protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary )
+ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
+ boolean binary )
throws ScmException
{
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
@@ -54,6 +53,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
cl.createArgument().setValue( "-d" );
cl.createArgument().setValue( repository.getCvsRoot() );
@@ -93,7 +94,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
1.7 +5 -5 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogCommand.java
Index: CvsChangeLogCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CvsChangeLogCommand.java 24 Dec 2004 03:04:45 -0000 1.6
+++ CvsChangeLogCommand.java 12 Jan 2005 11:16:59 -0000 1.7
@@ -35,9 +35,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsChangeLogCommand
- extends AbstractChangeLogCommand
- implements CvsCommand
+public class CvsChangeLogCommand extends AbstractChangeLogCommand implements CvsCommand
{
protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet,
Date startDate, Date endDate, int numDays, String branch )
@@ -58,6 +56,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
cl.createArgument().setValue( "-d" );
cl.createArgument().setValue( repository.getCvsRoot() );
@@ -99,7 +99,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing cvs command.", ex );
}
1.7 +8 -8 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkin/CvsCheckInCommand.java
Index: CvsCheckInCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkin/CvsCheckInCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CvsCheckInCommand.java 3 Jan 2005 03:19:56 -0000 1.6
+++ CvsCheckInCommand.java 12 Jan 2005 11:16:59 -0000 1.7
@@ -37,9 +37,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsCheckInCommand
- extends AbstractCheckInCommand
- implements CvsCommand
+public class CvsCheckInCommand extends AbstractCheckInCommand implements CvsCommand
{
protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message,
String tag )
@@ -53,6 +51,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
File messageFile;
try
@@ -61,7 +61,7 @@
FileUtils.fileWrite( messageFile.getAbsolutePath(), message );
}
- catch( IOException ex )
+ catch ( IOException ex )
{
throw new ScmException( "Error while making a temporary commit message file." );
}
@@ -89,7 +89,7 @@
for ( int i = 0; i < files.length; i++ )
{
cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
- }
+ }
CvsCheckInConsumer consumer = new CvsCheckInConsumer( repository.getPath() );
@@ -101,7 +101,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
@@ -110,7 +110,7 @@
{
FileUtils.forceDelete( messageFile );
}
- catch( IOException ex )
+ catch ( IOException ex )
{
// ignore
}
1.6 +5 -5 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkout/CvsCheckOutCommand.java
Index: CvsCheckOutCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkout/CvsCheckOutCommand.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- CvsCheckOutCommand.java 24 Dec 2004 03:04:45 -0000 1.5
+++ CvsCheckOutCommand.java 12 Jan 2005 11:16:59 -0000 1.6
@@ -32,9 +32,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsCheckOutCommand
- extends AbstractCheckOutCommand
- implements CvsCommand
+public class CvsCheckOutCommand extends AbstractCheckOutCommand implements CvsCommand
{
protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
throws ScmException
@@ -47,6 +45,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getParentFile().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
cl.createArgument().setValue( "-d" );
cl.createArgument().setValue( repository.getCvsRoot() );
@@ -79,7 +79,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
1.7 +7 -6 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagCommand.java
Index: CvsTagCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/tag/CvsTagCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CvsTagCommand.java 3 Jan 2005 05:10:12 -0000 1.6
+++ CvsTagCommand.java 12 Jan 2005 11:16:59 -0000 1.7
@@ -33,11 +33,10 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsTagCommand
- extends AbstractTagCommand
- implements CvsCommand
+public class CvsTagCommand extends AbstractTagCommand implements CvsCommand
{
- public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag ) throws ScmException
+ public ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
+ throws ScmException
{
CvsScmProviderRepository repository = (CvsScmProviderRepository) repo;
@@ -47,6 +46,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
cl.createArgument().setValue( "-d" );
cl.createArgument().setValue( repository.getCvsRoot() );
@@ -71,7 +72,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
1.7 +5 -5 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/update/CvsUpdateCommand.java
Index: CvsUpdateCommand.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/update/CvsUpdateCommand.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- CvsUpdateCommand.java 7 Jan 2005 15:45:10 -0000 1.6
+++ CvsUpdateCommand.java 12 Jan 2005 11:16:59 -0000 1.7
@@ -31,9 +31,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsUpdateCommand
- extends AbstractUpdateCommand
- implements CvsCommand
+public class CvsUpdateCommand extends AbstractUpdateCommand implements CvsCommand
{
public UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag )
throws ScmException
@@ -44,6 +42,8 @@
cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
+ cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
+
cl.createArgument().setValue( "-q" );
cl.createArgument().setValue( "update" );
@@ -68,7 +68,7 @@
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
- catch( CommandLineException ex )
+ catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
1.8 +6 -6 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogCommandTest.java
Index: CvsChangeLogCommandTest.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/changelog/CvsChangeLogCommandTest.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- CvsChangeLogCommandTest.java 30 Dec 2004 03:33:09 -0000 1.7
+++ CvsChangeLogCommandTest.java 12 Jan 2005 11:17:00 -0000 1.8
@@ -29,8 +29,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsChangeLogCommandTest
- extends AbstractCvsScmTest
+public class CvsChangeLogCommandTest extends AbstractCvsScmTest
{
protected String getModule()
{
@@ -72,10 +71,11 @@
{
ScmManager scmManager = getScmManager();
- CvsScmTestUtils.executeCVS( getWorkingDirectory(), "-d " + getTestFile( "src/test/repository/" ) + " co " + getModule() );
+ CvsScmTestUtils.executeCVS( getWorkingDirectory(),
+ "-f -d " + getTestFile( "src/test/repository/" ) + " co " + getModule() );
- ChangeLogScmResult changeLogResult = scmManager.changeLog( getScmRepository(), getScmFileSet(), startDate, endDate, 0,
- branch );
+ ChangeLogScmResult changeLogResult = scmManager.changeLog( getScmRepository(), getScmFileSet(), startDate,
+ endDate, 0, branch );
if ( !changeLogResult.isSuccess() )
{
1.1 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffCommand.java
Index: CvsDiffCommand.java
===================================================================
package org.apache.maven.scm.provider.cvslib.command.diff;
/*
* Copyright 2003-2004 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.command.diff.AbstractDiffCommand;
import org.apache.maven.scm.command.diff.DiffScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.cvslib.command.CvsCommand;
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;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: CvsDiffCommand.java,v 1.1 2005/01/12 11:17:00 brett Exp $
*/
public class CvsDiffCommand extends AbstractDiffCommand implements CvsCommand
{
protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, String startRevision,
String endRevision )
throws ScmException
{
Commandline cl = createCommandLine( fileSet.getBasedir(), startRevision, endRevision );
CvsDiffConsumer consumer = new CvsDiffConsumer( getLogger(), fileSet.getBasedir() );
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
getLogger().info( "Executing: " + cl );
getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() );
int exitCode;
try
{
exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr );
}
catch ( CommandLineException ex )
{
throw new ScmException( "Error while executing command.", ex );
}
// TODO: a difference returns a code of "1", as does errors. How to tell the difference?
// if ( exitCode != 0 )
// {
// return new DiffScmResult( "The cvs command failed.", stderr.getOutput(), false );
// }
return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences() );
}
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public static Commandline createCommandLine( File workingDirectory, String startRevision, String endRevision )
{
Commandline cl = new Commandline();
cl.setExecutable( "cvs" );
cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
cl.createArgument().setValue( "-q" );
cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc
cl.createArgument().setValue( "diff" );
cl.createArgument().setValue( "-u" );
cl.createArgument().setValue( "-N" );
if ( startRevision != null )
{
cl.createArgument().setValue( "-r" );
cl.createArgument().setValue( startRevision );
}
if ( endRevision != null )
{
cl.createArgument().setValue( "-r" );
cl.createArgument().setValue( endRevision );
}
return cl;
}
}
1.1 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffCommandTckTest.java
Index: CvsDiffCommandTckTest.java
===================================================================
package org.apache.maven.scm.provider.cvslib.command.diff;
/*
* Copyright 2003-2004 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.cvslib.CvsScmTestUtils;
import org.apache.maven.scm.tck.command.diff.DiffCommandTckTest;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: CvsDiffCommandTckTest.java,v 1.1 2005/01/12 11:17:00 brett Exp $
*/
public class CvsDiffCommandTckTest extends DiffCommandTckTest
{
public String getScmUrl()
{
return CvsScmTestUtils.getScmUrl( getRepositoryRoot(), getModule() );
}
protected String getModule()
{
return "test-repo/module";
}
public void initRepo()
throws Exception
{
CvsScmTestUtils.initRepo( "src/test/tck-repository/", getRepositoryRoot(), getWorkingDirectory() );
}
}
1.1 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffConsumer.java
Index: CvsDiffConsumer.java
===================================================================
package org.apache.maven.scm.provider.cvslib.command.diff;
/*
* Copyright 2003-2004 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.codehaus.plexus.logging.Logger;
import org.codehaus.plexus.util.cli.StreamConsumer;
import java.io.File;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author <a href="mailto:brett@apache.org">Brett Porter</a>
* @version $Id: CvsDiffConsumer.java,v 1.1 2005/01/12 11:17:00 brett Exp $
* @todo share with SVN (3 extra lines can be ignored)
*/
public class CvsDiffConsumer implements StreamConsumer
{
//
// Index: plugin.jelly
// ===================================================================
// RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/resources/META-INF/plexus/components.xml,v
// retrieving revision 1.2
// diff -u -r1.2 components.xml
// --- plugin.jelly (revision 124799)
// +++ plugin.jelly (working copy)
//
private final static String RCS_TOKEN = "RCS file: ";
private final static String RETRIEVING_TOKEN = "retrieving revision ";
private final static String DIFF_TOKEN = "diff ";
private final static String INDEX_TOKEN = "Index: ";
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 Logger logger;
private File workingDirectory;
private String currentFile;
private StringBuffer currentDifference;
private List changedFiles = new ArrayList();
private Map differences = new HashMap();
// ----------------------------------------------------------------------
//
// ----------------------------------------------------------------------
public CvsDiffConsumer( Logger logger, File workingDirectory )
{
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() );
changedFiles.add( new ScmFile( currentFile, ScmFileStatus.MODIFIED ) );
currentDifference = new StringBuffer();
differences.put( currentFile, currentDifference );
return;
}
if ( currentFile == null )
{
logger.warn( "Unparseable line: '" + line + "'" );
return;
}
if ( line.startsWith( FILE_SEPARATOR_TOKEN ) )
{
// skip
}
else if ( line.startsWith( START_REVISION_TOKEN ) )
{
// skip, though could parse to verify filename, start revision
}
else if ( line.startsWith( END_REVISION_TOKEN ) )
{
// skip, though could parse to verify filename, end revision
}
else if ( line.startsWith( RCS_TOKEN ) )
{
// skip, though could parse to verify filename
}
else if ( line.startsWith( RETRIEVING_TOKEN ) )
{
// skip, though could parse to verify version
}
else if ( line.startsWith( DIFF_TOKEN ) )
{
// skip, though could parse to verify command
}
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" );
}
else
{
logger.warn( "Unparseable line: '" + line + "'" );
// skip to next file
currentFile = null;
currentDifference = null;
}
}
public List getChangedFiles()
{
return changedFiles;
}
public Map getDifferences()
{
return differences;
}
}
1.10 +10 -11 maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/update/CvsUpdateCommandTest.java
Index: CvsUpdateCommandTest.java
===================================================================
RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/update/CvsUpdateCommandTest.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- CvsUpdateCommandTest.java 2 Jan 2005 03:05:13 -0000 1.9
+++ CvsUpdateCommandTest.java 12 Jan 2005 11:17:00 -0000 1.10
@@ -34,8 +34,7 @@
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
* @version $Id$
*/
-public class CvsUpdateCommandTest
- extends AbstractCvsScmTest
+public class CvsUpdateCommandTest extends AbstractCvsScmTest
{
private File repository;
@@ -44,7 +43,7 @@
private File assertionDirectory;
public void setUp()
- throws Exception
+ throws Exception
{
super.setUp();
@@ -62,7 +61,9 @@
return "test-repo/update";
}
- /** @todo merge into tck */
+ /**
+ * @todo merge into tck
+ */
public void testCvsUpdate()
throws Exception
{
@@ -71,14 +72,12 @@
String scmUrl = "scm:cvs:local:" + repository.getAbsolutePath() + ":" + getModule();
// Check out the repo to a workding directory where files will be modified and committed
- String arguments = "-d " + repository.getAbsolutePath() + " " +
- "co -d " + workingDirectory.getName() + " " + getModule();
+ String arguments = "-f -d " + repository.getAbsolutePath() + " " + "co -d " + workingDirectory.getName() + " " + getModule();
CvsScmTestUtils.executeCVS( workingDirectory.getParentFile(), arguments );
// Check out the repo to a assertion directory where the command will be used
- arguments = "-d " + repository.getAbsolutePath() + " " +
- "co -d " + assertionDirectory.getName() + " " + getModule();
+ arguments = "-f -d " + repository.getAbsolutePath() + " " + "co -d " + assertionDirectory.getName() + " " + getModule();
CvsScmTestUtils.executeCVS( assertionDirectory.getParentFile(), arguments );
@@ -125,12 +124,12 @@
writer.close();
- arguments = "-d " + repository.getAbsolutePath() + " add New.txt";
+ arguments = "-f -d " + repository.getAbsolutePath() + " add New.txt";
CvsScmTestUtils.executeCVS( workingDirectory, arguments );
// Committing
- arguments = "-d " + repository.getAbsolutePath() + " commit -m .";
+ arguments = "-f -d " + repository.getAbsolutePath() + " commit -m .";
CvsScmTestUtils.executeCVS( workingDirectory, arguments );