maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkin CvsCheckInCommand.java
Date Mon, 03 Jan 2005 03:19:56 GMT
brett       2005/01/02 19:19:56

  Modified:    maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add
                        SvnAddCommand.java
               maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin
                        SvnCheckInCommand.java
               maven-scm-providers/maven-scm-provider-svn/src/test/java/org/apache/maven/scm/provider/svn/command/checkin
                        SvnCheckInCommandTest.java
               maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin
                        CheckInCommandTckTest.java
               maven-scm-api/src/main/java/org/apache/maven/scm
                        ScmFileSet.java
               maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add
                        LocalAddCommand.java
               maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin
                        LocalCheckInCommand.java
               maven-scm-providers/maven-scm-provider-cvs/src/main/java/org/apache/maven/scm/provider/cvslib/command/checkin
                        CvsCheckInCommand.java
  Log:
  check in command now supports partial file sets, and is tested in the TCK
  
  Revision  Changes    Path
  1.2       +2 -2      maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add/SvnAddCommand.java
  
  Index: SvnAddCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/add/SvnAddCommand.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- SvnAddCommand.java	30 Dec 2004 10:05:29 -0000	1.1
  +++ SvnAddCommand.java	3 Jan 2005 03:19:56 -0000	1.2
  @@ -49,7 +49,7 @@
   
           if ( fileSet.getFiles().length == 0 )
           {
  -            throw new ScmException( "You must provide at leaast one file/directory to add"
);
  +            throw new ScmException( "You must provide at least one file/directory to add"
);
           }
   
           Commandline cl = createCommandLine( fileSet.getBasedir(), fileSet.getFiles() );
  
  
  
  1.4       +10 -10    maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommand.java
  
  Index: SvnCheckInCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SvnCheckInCommand.java	3 Jan 2005 02:04:08 -0000	1.3
  +++ SvnCheckInCommand.java	3 Jan 2005 03:19:56 -0000	1.4
  @@ -42,12 +42,6 @@
                                                         String tag )
           throws ScmException
       {
  -        // TODO: it should
  -        if ( fileSet.getFiles().length != 0 )
  -        {
  -            throw new ScmException( "This command can only commit entire working directories."
);
  -        }
  -
           if ( !StringUtils.isEmpty( tag ) )
           {
               throw new ScmException( "This provider can't handle tags." );
  @@ -64,7 +58,7 @@
               return new CheckInScmResult( "Error while making a temporary file for the commit
message: " + ex.getMessage(), null, false );
           }
   
  -        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(),
messageFile );
  +        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet, messageFile
);
   
           SvnCheckInConsumer consumer = new SvnCheckInConsumer( getLogger(), fileSet.getBasedir()
);
   
  @@ -107,13 +101,13 @@
       //
       // ----------------------------------------------------------------------
   
  -    public static Commandline createCommandLine( SvnScmProviderRepository repository, File
workingDirectory, File messageFile )
  +    public static Commandline createCommandLine( SvnScmProviderRepository repository, ScmFileSet
fileSet, File messageFile )
       {
           Commandline cl = new Commandline();
   
           cl.setExecutable( "svn" );
   
  -        cl.setWorkingDirectory( workingDirectory.getAbsolutePath() );
  +        cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() );
   
           cl.createArgument().setValue( "commit" );
   
  @@ -136,6 +130,12 @@
           cl.createArgument().setValue( "--file" );
   
           cl.createArgument().setValue( messageFile.getAbsolutePath() );
  +
  +        File[] files = fileSet.getFiles();
  +        for ( int i = 0; i < files.length; i++ )
  +        {
  +            cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
  +        }
   
           return cl;
       }
  
  
  
  1.4       +4 -2      maven-scm/maven-scm-providers/maven-scm-provider-svn/src/test/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTest.java
  
  Index: SvnCheckInCommandTest.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/test/java/org/apache/maven/scm/provider/svn/command/checkin/SvnCheckInCommandTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SvnCheckInCommandTest.java	24 Dec 2004 03:04:47 -0000	1.3
  +++ SvnCheckInCommandTest.java	3 Jan 2005 03:19:56 -0000	1.4
  @@ -16,6 +16,7 @@
    * limitations under the License.
    */
   
  +import org.apache.maven.scm.ScmFileSet;
   import org.apache.maven.scm.ScmTestCase;
   import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
   import org.apache.maven.scm.repository.ScmRepository;
  @@ -89,7 +90,8 @@
   
           SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
   
  -        Commandline cl = SvnCheckInCommand.createCommandLine( svnRepository, workingDirectory,
messageFile );
  +        Commandline cl = SvnCheckInCommand.createCommandLine( svnRepository, new ScmFileSet(
workingDirectory ),
  +                                                              messageFile );
   
           assertEquals( commandLine, cl.toString() );
       }
  
  
  
  1.2       +77 -3     maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java
  
  Index: CheckInCommandTckTest.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-test/src/main/java/org/apache/maven/scm/tck/command/checkin/CheckInCommandTckTest.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CheckInCommandTckTest.java	3 Jan 2005 00:49:39 -0000	1.1
  +++ CheckInCommandTckTest.java	3 Jan 2005 03:19:56 -0000	1.2
  @@ -91,7 +91,7 @@
       {
           super.setUp();
   
  -        File repositoryRoot = getTestFile( "target/checkin-tck-test/repository" );
  +        File repositoryRoot = getRepositoryRoot();
   
           if ( repositoryRoot.exists() )
           {
  @@ -101,7 +101,7 @@
           assertTrue( "Could not make the repository root directory: " + repositoryRoot.getAbsolutePath(),
                       repositoryRoot.mkdirs() );
   
  -        workingDirectory = getTestFile( "target/checkin-tck-test/working-copy" );
  +        workingDirectory = getWorkingCopy();
   
           if ( workingDirectory.exists() )
           {
  @@ -111,6 +111,7 @@
           assertTrue( "Could not make the working directory: " + workingDirectory.getAbsolutePath(),
                       workingDirectory.mkdirs() );
   
  +        // TODO: have assertion directory globally, and cleanup -tck-test stuff
           assertionDirectory = getTestFile( "target/checkin-tck-test/assertion-copy" );
   
           if ( assertionDirectory.exists() )
  @@ -208,6 +209,79 @@
           assertTrue( "check can read readme.txt", readmeTxt.canRead() );
   
           assertEquals( "check readme.txt contents", "changed file", FileUtils.fileRead(
readmeTxt ) );
  +    }
  +
  +    public void testCheckInCommandPartialFileset()
  +        throws Exception
  +    {
  +        // Make sure that the correct files was checked out
  +        File fooJava = new File( workingDirectory, "src/main/java/Foo.java" );
  +
  +        File barJava = new File( workingDirectory, "src/main/java/Bar.java" );
  +
  +        File readmeTxt = new File( workingDirectory, "readme.txt" );
  +
  +        assertFalse( "check Foo.java doesn't yet exist", fooJava.canRead() );
  +
  +        assertFalse( "check Bar.java doesn't yet exist", barJava.canRead() );
  +
  +        assertTrue( "check can read readme.txt", readmeTxt.canRead() );
  +
  +        // Change the files
  +        createFooJava( fooJava );
  +
  +        createBarJava( barJava );
  +
  +        changeReadmeTxt( readmeTxt );
  +
  +        AddScmResult addResult = scmManager.add( repository,
  +                                                 new ScmFileSet( workingDirectory, "src/main/java/Foo.java",
null ) );
  +
  +        assertResultIsSuccess( addResult );
  +
  +        CheckInScmResult result = scmManager.checkIn( repository,
  +                                                      new ScmFileSet( workingDirectory,
"**/Foo.java", null ), null,
  +                                                      "Commit message" );
  +
  +        assertResultIsSuccess( result );
  +
  +        assertNull( "The provider message wasn't null", result.getProviderMessage() );
  +
  +        assertNull( "The command output wasn't null", result.getCommandOutput() );
  +
  +        List files = result.getCheckedInFiles();
  +
  +        assertNotNull( files );
  +
  +        assertEquals( 1, files.size() );
  +
  +        ScmFile file1 = (ScmFile) files.get( 0 );
  +
  +        assertEquals( ScmFileStatus.CHECKED_IN, file1.getStatus() );
  +
  +        assertPath( "/test-repo/check-in/Foo.java", file1.getPath() );
  +
  +        assertNull( result.getProviderMessage() );
  +
  +        assertNull( result.getCommandOutput() );
  +
  +        CheckOutScmResult checkoutResult = scmManager.checkOut( repository, new ScmFileSet(
assertionDirectory ), null );
  +
  +        assertResultIsSuccess( checkoutResult );
  +
  +        fooJava = new File( assertionDirectory, "src/main/java/Foo.java" );
  +
  +        barJava = new File( assertionDirectory, "src/main/java/Bar.java" );
  +
  +        readmeTxt = new File( assertionDirectory, "readme.txt" );
  +
  +        assertTrue( "check can read Foo.java", fooJava.canRead() );
  +
  +        assertFalse( "check Bar.java doesn't exist", barJava.canRead() );
  +
  +        assertTrue( "check can read readme.txt", readmeTxt.canRead() );
  +
  +        assertEquals( "check readme.txt contents", "/readme.txt", FileUtils.fileRead( readmeTxt
) );
       }
   
       private void createFooJava( File fooJava )
  
  
  
  1.5       +3 -2      maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java
  
  Index: ScmFileSet.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileSet.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ScmFileSet.java	30 Dec 2004 10:05:29 -0000	1.4
  +++ ScmFileSet.java	3 Jan 2005 03:19:56 -0000	1.5
  @@ -30,6 +30,7 @@
   {
       private File basedir;
   
  +    /** List of files, all relative to the basedir. */
       private File[] files;
   
       private static final File[] EMPTY_FILE_ARRAY = new File[0];
  @@ -49,7 +50,7 @@
           this.basedir = basedir;
   
           // TODO: just use a list instead?
  -        files = (File[]) FileUtils.getFiles( basedir, includes, excludes ).toArray( EMPTY_FILE_ARRAY
);
  +        files = (File[]) FileUtils.getFiles( basedir, includes, excludes, false ).toArray(
EMPTY_FILE_ARRAY );
       }
   
       public ScmFileSet( File basedir, File[] files )
  
  
  
  1.3       +9 -17     maven-scm/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java
  
  Index: LocalAddCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/add/LocalAddCommand.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LocalAddCommand.java	3 Jan 2005 01:33:58 -0000	1.2
  +++ LocalAddCommand.java	3 Jan 2005 03:19:56 -0000	1.3
  @@ -17,7 +17,9 @@
    */
   
   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.add.AbstractAddCommand;
   import org.apache.maven.scm.command.add.AddScmResult;
  @@ -26,7 +28,8 @@
   import org.apache.maven.scm.provider.local.repository.LocalScmProviderRepository;
   
   import java.io.File;
  -import java.util.Collections;
  +import java.util.ArrayList;
  +import java.util.List;
   
   /**
    * @author <a href="mailto:brett@apache.org">Brett Porter</a>
  @@ -43,26 +46,15 @@
           LocalScmProviderRepository localRepo = (LocalScmProviderRepository) repository;
   
           File[] files = fileSet.getFiles();
  +        List fileList = new ArrayList();
           for ( int i = 0; i < files.length; i++ )
           {
  -            // TODO: better to standardise on relative paths inside fileset
  -
  -            String path = files[i].getPath();
  -            if ( path.startsWith( fileSet.getBasedir().getPath() ) )
  -            {
  -                path = path.substring( fileSet.getBasedir().getPath().length() );
  -            }
  -            path = path.replace( '\\', '/' );
  -
  -            if ( path.startsWith( "/" ) )
  -            {
  -                path = path.substring( 1 );
  -            }
  -
  +            String path = files[i].getPath().replace( '\\', '/' );
               localRepo.addFile( path );
  +            fileList.add( new ScmFile( path, ScmFileStatus.ADDED ) );
           }
   
           // TODO: Also, ensure it is tested from the update test
  -        return new AddScmResult( Collections.EMPTY_LIST );
  +        return new AddScmResult( fileList );
       }
   }
  
  
  
  1.4       +10 -8     maven-scm/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java
  
  Index: LocalCheckInCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-local/src/main/java/org/apache/maven/scm/provider/local/command/checkin/LocalCheckInCommand.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LocalCheckInCommand.java	3 Jan 2005 01:33:58 -0000	1.3
  +++ LocalCheckInCommand.java	3 Jan 2005 03:19:56 -0000	1.4
  @@ -31,6 +31,7 @@
   import java.io.File;
   import java.io.IOException;
   import java.util.ArrayList;
  +import java.util.Arrays;
   import java.util.Iterator;
   import java.util.List;
   
  @@ -83,19 +84,20 @@
               // Only copy files newer than in the repo
               File repoRoot = new File( repository.getRoot(), repository.getModule() );
   
  -            Iterator it = FileUtils.getFiles( baseDestination, "**", null ).iterator();
  +            List files = Arrays.asList( fileSet.getFiles() );
  +            if ( files.isEmpty() )
  +            {
  +                files = FileUtils.getFiles( baseDestination, "**", null, false );
  +            }
  +            Iterator it = files.iterator();
   
               while ( it.hasNext() )
               {
                   File file = (File) it.next();
   
  -                String path = file.getAbsolutePath().substring( baseDestination.getAbsolutePath().length()
).replace( '\\', '/' );
  -                if ( path.startsWith( "/" ) )
  -                {
  -                    path = path.substring( 1 );
  -                }
  -
  +                String path = file.getPath().replace( '\\', '/' );
                   File repoFile = new File( repoRoot, path );
  +                file = new File( baseDestination, path );
   
                   ScmFileStatus status;
   
  
  
  
  1.6       +6 -3      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.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- CvsCheckInCommand.java	24 Dec 2004 03:04:45 -0000	1.5
  +++ CvsCheckInCommand.java	3 Jan 2005 03:19:56 -0000	1.6
  @@ -85,8 +85,11 @@
   
           cl.createArgument().setValue( messageFile.getAbsolutePath() );
   
  -        // TODO: should be committing files here instead - for now check in everything
  -        // cl.createArgument().setValue( repository.getModule() );
  +        File[] files = fileSet.getFiles();
  +        for ( int i = 0; i < files.length; i++ )
  +        {
  +            cl.createArgument().setValue( files[i].getPath().replace( '\\', '/' ) );
  +        }        
   
           CvsCheckInConsumer consumer = new CvsCheckInConsumer( repository.getPath() );
   
  
  
  

Mime
View raw message