Package org.apache.maven.scm.command.update

Examples of org.apache.maven.scm.command.update.UpdateScmResult


        CvsScmTestUtils.executeCVS( assertionDirectory.getParentFile(), arguments );

        // A new check out should return 0 updated files.
        ScmRepository scmRepository = scmManager.makeScmRepository( scmUrl );

        UpdateScmResult result = scmManager.update( scmRepository, new ScmFileSet( assertionDirectory ) );

        assertNotNull( result );

        if ( !result.isSuccess() )
        {
            System.out.println( "result.providerMessage: " + result.getProviderMessage() );

            System.out.println( "result.commandOutput: " + result.getCommandOutput() );

            fail( "Command failed" );
        }

        assertNull( result.getProviderMessage() );

        assertNull( result.getCommandOutput() );

        assertNotNull( result.getUpdatedFiles() );

        assertEquals( 0, result.getUpdatedFiles().size() );

        // Modifing a file
        File fooJava = new File( workingDirectory, "Foo.java" );

        String content = FileUtils.fileRead( fooJava );

        FileWriter writer = new FileWriter( fooJava );

        writer.write( content + System.getProperty( "line.separator" ) );
        writer.write( "extra line" );

        writer.close();

        // Adding a new file
        writer = new FileWriter( new File( workingDirectory, "New.txt" ) );

        writer.write( "new file" );

        writer.close();

        arguments = "-f -d " + repository.getAbsolutePath() + " add New.txt";

        CvsScmTestUtils.executeCVS( workingDirectory, arguments );

        // Committing
        arguments = "-f -d " + repository.getAbsolutePath() + " commit -m .";

        CvsScmTestUtils.executeCVS( workingDirectory, arguments );

        // Check the updated files
        result = scmManager.update( scmRepository, new ScmFileSet( assertionDirectory ) );

        assertNotNull( result );

        if ( !result.isSuccess() )
        {
            System.out.println( "result.providerMessage: " + result.getProviderMessage() );

            System.out.println( "result.commandOutput: " + result.getCommandOutput() );

            fail( "Command failed" );
        }

        assertNull( result.getProviderMessage() );

        assertNull( result.getCommandOutput() );

        assertNotNull( result.getUpdatedFiles() );

        assertEquals( 2, result.getUpdatedFiles().size() );

        ScmFile file1 = (ScmFile) result.getUpdatedFiles().get( 0 );

        assertPath( "Foo.java", file1.getPath() );

        assertEquals( ScmFileStatus.UPDATED, file1.getStatus() );

        ScmFile file2 = (ScmFile) result.getUpdatedFiles().get( 1 );

        assertPath( "New.txt", file2.getPath() );

        assertEquals( ScmFileStatus.UPDATED, file2.getStatus() );
    }
View Full Code Here


                                                              cl.getWorkingDirectory().getAbsolutePath(), logListener,
                                                              getLogger() );

            if ( !isSuccess )
            {
                return new UpdateScmResult( cl.toString(), "The cvs command failed.",
                                            logListener.getStderr().toString(), false );
            }
            BufferedReader stream = new BufferedReader(
                new InputStreamReader( new ByteArrayInputStream( logListener.getStdout().toString().getBytes() ) ) );

            String line;

            while ( ( line = stream.readLine() ) != null )
            {
                consumer.consumeLine( line );
            }
        }
        catch ( Exception e )
        {
            e.printStackTrace();
            return new UpdateScmResult( cl.toString(), "The cvs command failed.", logListener.getStderr().toString(),
                                        false );
        }

        return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() );
    }
View Full Code Here

            throw new ScmException( "Error while executing command.", ex );
        }

        if ( exitCode != 0 )
        {
            return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
        }

        return new UpdateScmResult( cl.toString(), consumer.getUpdatedFiles() );
    }
View Full Code Here

        // ----------------------------------------------------------------------

        ScmManager scmManager = getScmManager();
        Date lastUpdate = new Date( System.currentTimeMillis() );
        Thread.sleep( 1000 );
        UpdateScmResult result =
            scmManager.update( repository, new ScmFileSet( getUpdatingCopy() ), lastUpdate );

        assertNotNull( "The command returned a null result.", result );

        assertResultIsSuccess( result );

        List<ScmFile> updatedFiles = result.getUpdatedFiles();

        assertEquals( "Expected 1 files in the updated files list " + updatedFiles, 1, updatedFiles.size() );

        // ----------------------------------------------------------------------
        // Assert the files in the updated files list
View Full Code Here

        AccuRevScmProviderRepository accurevRepo = (AccuRevScmProviderRepository) repository;

        AccuRevUpdateCommand command = new AccuRevUpdateCommand( getLogger() );

        UpdateScmResult result = command.update( repository, fileSet, parameters );

        if ( result.isSuccess() && parameters.getBoolean( CommandParameter.RUN_CHANGELOG_WITH_UPDATE ) )
        {
            AccuRevUpdateScmResult accuRevResult = (AccuRevUpdateScmResult) result;

            ScmRevision fromRevision = new ScmRevision( accuRevResult.getFromRevision() );
            ScmRevision toRevision = new ScmRevision( accuRevResult.getToRevision() );

            parameters.setScmVersion( CommandParameter.START_SCM_VERSION, fromRevision );
            parameters.setScmVersion( CommandParameter.END_SCM_VERSION, toRevision );

            AccuRevVersion startVersion = accurevRepo.getAccuRevVersion( fromRevision );
            AccuRevVersion endVersion = accurevRepo.getAccuRevVersion( toRevision );
            if ( startVersion.getBasisStream().equals( endVersion.getBasisStream() ) )
            {
                ChangeLogScmResult changeLogResult = changelog( repository, fileSet, parameters );

                if ( changeLogResult.isSuccess() )
                {
                    result.setChanges( changeLogResult.getChangeLog().getChangeSets() );
                }
                else
                {
                    getLogger().warn( "Changelog from " + fromRevision + " to " + toRevision + " failed" );
                }
            }
            else
            {
                String comment = "Cross stream update result from " + startVersion + " to " + endVersion;
                String author = "";
                List<ScmFile> files = result.getUpdatedFiles();
                List<ChangeFile> changeFiles = new ArrayList<ChangeFile>( files.size() );
                for (ScmFile scmFile : files)
                {
                    changeFiles.add(new ChangeFile( scmFile.getPath() ));
                }
                ChangeSet dummyChangeSet = new ChangeSet( new Date(), comment, author, changeFiles );
                // different streams invalidates the change log, insert a dummy change instead.
                List<ChangeSet> changeSets = Collections.singletonList( dummyChangeSet );
                result.setChanges( changeSets );
            }

        }
        return result;
    }
View Full Code Here

        catch ( NoSuchScmProviderException e )
        {
            throw new ReleaseExecutionException( "Unable to configure SCM repository: " + e.getMessage(), e );
        }

        UpdateScmResult result;
        try
        {
            result = provider.update( repository, new ScmFileSet( new File( releaseDescriptor.getWorkingDirectory() ) ),
                                      (ScmVersion) null );
        }
        catch ( ScmException e )
        {
            throw new ReleaseExecutionException( "An error occurred while updating your local copy: " + e.getMessage(),
                                                 e );
        }

        if ( !result.isSuccess() )
        {
            throw new ReleaseScmCommandException( "Unable to update current working copy", result );
        }

        copyUpdated = ( result.getUpdatedFiles().size() > 0 );

        relResult.setResultCode( ReleaseResult.SUCCESS );

        return relResult;
    }
View Full Code Here

            // Remove the clientspec name, so it will be recalculated between each command for each project
            // instead of use the same for all projects
            System.setProperty( "maven.scm.starteam.deleteLocal", "true" );
        }

        UpdateScmResult result;

        ScmFileSet fileSet = new ScmFileSet( workingDirectory );

        // TODO: shouldn't need to synchronize this
        synchronized ( this )
View Full Code Here

        project.setState( ContinuumProjectState.UPDATING );

        projectDao.updateProject( project );

        UpdateScmResult scmResult;

        Date latestUpdateDate = null;
        try
        {
            BuildResult result = buildResultDao.getLatestBuildResultForProject( project.getId() );

            latestUpdateDate = new Date( result.getStartTime() );
        }
        catch ( Exception e )
        {
        }

        try
        {
            notifier.checkoutStarted( project, buildDefinition );

            // TODO: not sure why this is different to the context, but it all needs to change
            File workingDirectory = workingDirectoryService.getWorkingDirectory( project );
            ContinuumScmConfiguration config = createScmConfiguration( project, workingDirectory );
            config.setLatestUpdateDate( latestUpdateDate );
            String tag = config.getTag();
            String msg = project.getName() + "', id: '" + project.getId() + "' to '" +
                workingDirectory.getAbsolutePath() + "'" + ( tag != null ? " with branch/tag " + tag + "." : "." );
            getLogger().info( "Updating project: " + msg );
            scmResult = scm.update( config );

            if ( !scmResult.isSuccess() )
            {
                getLogger().warn( "Error while updating the code for project: '" + msg );

                getLogger().warn( "Command output: " + scmResult.getCommandOutput() );

                getLogger().warn( "Provider message: " + scmResult.getProviderMessage() );
            }

            if ( scmResult.getUpdatedFiles() != null && scmResult.getUpdatedFiles().size() > 0 )
            {
                getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files." );
            }

            context.put( KEY_UPDATE_SCM_RESULT, convertScmResult( scmResult ) );
        }
        finally
View Full Code Here

            ScmRepository repository = getScmRepository( project, project.isScmUseCache() );

            ScmResult result;

            UpdateScmResult scmResult;

            ScmFileSet fileSet = new ScmFileSet( workingDirectory );

            synchronized ( this )
            {
                scmResult = scmManager.getProviderByRepository( repository )
                    .update( repository, fileSet, tag, getLatestUpdateDate( project ) );
                result = convertScmResult( scmResult );
            }

            if ( !result.isSuccess() )
            {
                getLogger().warn( "Error while updating the code for project: '" + project.getName() + "', id: '" +
                    project.getId() + "' to '" + workingDirectory.getAbsolutePath() + "'" + tagMessage + "." );

                getLogger().warn( "Command output: " + result.getCommandOutput() );

                getLogger().warn( "Provider message: " + result.getProviderMessage() );
            }

            if ( scmResult.getUpdatedFiles() != null && scmResult.getUpdatedFiles().size() > 0 )
            {
                getLogger().info( "Updated " + scmResult.getUpdatedFiles().size() + " files." );
            }

            return result;
        }
        catch ( ScmRepositoryException e )
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.command.update.UpdateScmResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.