Package org.apache.maven.scm.provider

Examples of org.apache.maven.scm.provider.ScmProvider


            else
            {
                defaultTag = project.getArtifactId() + "-" + releaseVersion;
            }

            ScmProvider provider = null;
            try
            {
                provider = getScmProvider( releaseDescriptor, releaseEnvironment );
            }
            catch ( ReleaseScmRepositoryException e )
            {
                throw new ReleaseExecutionException(
                    "No scm provider can be found for url: " + releaseDescriptor.getScmSourceUrl(), e );
            }

            defaultTag = provider.sanitizeTagName( defaultTag );

            if ( releaseDescriptor.isInteractive() )
            {
                try
                {
View Full Code Here


        {
            logger = getScmLogger();

            for ( Entry<String, ScmProvider> entry : scmProviders.entrySet() )
            {
                ScmProvider p = entry.getValue();

                p.addListener( logger );
            }
        }

        String usedProviderType = System.getProperty( "maven.scm.provider." + providerType + ".implementation" );

        if ( usedProviderType == null )
        {
            if ( userProviderTypes.containsKey( providerType ) )
            {
                usedProviderType = userProviderTypes.get( providerType );
            }
            else
            {
                usedProviderType = providerType;
            }
        }

        ScmProvider scmProvider = scmProviders.get( usedProviderType );

        if ( scmProvider == null )
        {
            throw new NoSuchScmProviderException( usedProviderType );
        }
View Full Code Here

        char delimiter = ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 );

        String providerType = ScmUrlUtils.getProvider( scmUrl );

        ScmProvider provider = getProviderByType( providerType );

        String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) );

        ScmProviderRepository providerRepository = provider.makeProviderScmRepository( scmSpecificUrl, delimiter );

        return new ScmRepository( providerType, providerRepository );
    }
View Full Code Here

        if ( providerType == null )
        {
            throw new NullPointerException( "The provider type cannot be null." );
        }

        ScmProvider provider = getProviderByType( providerType );

        ScmProviderRepository providerRepository = provider.makeProviderScmRepository( path );

        return new ScmRepository( providerType, providerRepository );
    }
View Full Code Here

        messages.addAll( ScmUrlUtils.validate( scmUrl ) );

        String providerType = ScmUrlUtils.getProvider( scmUrl );

        ScmProvider provider;

        try
        {
            provider = getProviderByType( providerType );
        }
        catch ( NoSuchScmProviderException e )
        {
            messages.add( "No such provider installed '" + providerType + "'." );

            return messages;
        }

        String scmSpecificUrl = cleanScmUrl( scmUrl.substring( providerType.length() + 5 ) );

        List<String> providerMessages =
            provider.validateScmUrl( scmSpecificUrl, ScmUrlUtils.getDelimiter( scmUrl ).charAt( 0 ) );

        if ( providerMessages == null )
        {
            throw new RuntimeException( "The SCM provider cannot return null from validateScmUrl()." );
        }
View Full Code Here

    public void testChangeLogCommand()
        throws Exception
    {
        Thread.sleep( 1000 );
        ScmProvider provider = getScmManager().getProviderByRepository( getScmRepository() );
        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );

        //We should have one log entry for the initial repository
        ChangeLogScmResult firstResult =
            provider.changeLog( getScmRepository(), fileSet, null, null, 0, (ScmBranch) null, null );
        assertTrue( firstResult.getProviderMessage() + ": " + firstResult.getCommandLine() + "\n" + firstResult.getCommandOutput(),
                    firstResult.isSuccess() );
        assertEquals( 1, firstResult.getChangeLog().getChangeSets().size() );

        //Make a timestamp that we know are after initial revision but before the second
        Date timeBeforeSecond = new Date(); //Current time

        // pause a couple seconds... [SCM-244]
        Thread.sleep( 2000 );

        //Make a change to the readme.txt and commit the change
        ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
        CheckInScmResult checkInResult = provider.checkIn( getScmRepository(), fileSet, COMMIT_MSG );
        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );

        ChangeLogScmResult secondResult = provider.changeLog( getScmRepository(), fileSet, (ScmVersion) null, null );
        assertTrue( secondResult.getProviderMessage(), secondResult.isSuccess() );
        assertEquals( 2, secondResult.getChangeLog().getChangeSets().size() );

        //Now only retrieve the changelog after timeBeforeSecondChangeLog
        Date currentTime = new Date();
        ChangeLogScmResult thirdResult = provider
            .changeLog( getScmRepository(), fileSet, timeBeforeSecond, currentTime, 0, new ScmBranch( "" ) );

        //Thorough assert of the last result
        assertTrue( thirdResult.getProviderMessage(), thirdResult.isSuccess() );
        assertEquals( 1, thirdResult.getChangeLog().getChangeSets().size() );
View Full Code Here

        {
            List changeSets = new ArrayList();

            ScmRepository repository = getScmRepository();

            ScmProvider provider = manager.getProviderByRepository( repository );

            ChangeLogScmResult result;

            if ( "range".equals( type ) )
            {
                result = provider.changeLog( repository, new ScmFileSet( basedir ), null, null, range, (ScmBranch) null,
                                             dateFormat );

                checkResult( result );

                changeSets.add( result.getChangeLog() );
            }
            else if ( "tag".equals( type ) )
            {
                if ( repository.getProvider().equals( "svn" ) )
                {
                    throw new MavenReportException( "The type '" + type + "' isn't supported for svn." );
                }

                Iterator tagsIter = tags.iterator();

                String startTag = (String) tagsIter.next();
                String endTag = null;

                if ( tagsIter.hasNext() )
                {
                    while ( tagsIter.hasNext() )
                    {
                        endTag = (String) tagsIter.next();

                        result = provider.changeLog( repository, new ScmFileSet( basedir ), new ScmRevision( startTag ),
                                                     new ScmRevision( endTag ) );

                        checkResult( result );

                        changeSets.add( result.getChangeLog() );

                        startTag = endTag;
                    }
                }
                else
                {
                    result = provider.changeLog( repository, new ScmFileSet( basedir ), new ScmRevision( startTag ),
                                                 new ScmRevision( endTag ) );

                    checkResult( result );

                    changeSets.add( result.getChangeLog() );
                }
            }
            else if ( "date".equals( type ) )
            {
                Iterator dateIter = dates.iterator();

                String startDate = (String) dateIter.next();
                String endDate = null;

                if ( dateIter.hasNext() )
                {
                    while ( dateIter.hasNext() )
                    {
                        endDate = (String) dateIter.next();

                        result = provider.changeLog( repository, new ScmFileSet( basedir ), parseDate( startDate ),
                                                     parseDate( endDate ), 0, (ScmBranch) null );

                        checkResult( result );

                        changeSets.add( result.getChangeLog() );

                        startDate = endDate;
                    }
                }
                else
                {
                    result = provider.changeLog( repository, new ScmFileSet( basedir ), parseDate( startDate ),
                                                 parseDate( endDate ), 0, (ScmBranch) null );

                    checkResult( result );

                    changeSets.add( result.getChangeLog() );
View Full Code Here

        // ----------------------------------------------------------------------
        // Diff the project
        // ----------------------------------------------------------------------

        ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );
        DiffScmResult result = provider.diff( repository, fileSet, null, (ScmVersion) null );

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

        assertResultIsSuccess( result );
View Full Code Here

        String workingStream = accurevTckTestUtil.getWorkingStream();
        String subStream = accurevTckTestUtil.getDepotName() + "_sub_stream";
        accurev.mkstream( workingStream, subStream );

        ScmRepository mainRepository = getScmRepository();
        ScmProvider provider = getScmManager().getProviderByRepository( mainRepository );

        // Create a workspace at the updating copy location backed by the substream
        ScmBranch branch = new ScmBranch( "sub_stream" );
        provider.checkOut( mainRepository, new ScmFileSet( getUpdatingCopy() ), branch );

        Thread.sleep( 1000 );
        ScmFileSet fileSet = new ScmFileSet( getWorkingCopy() );

        // Make a timestamp that we know are after initial revision but before the second
        Date timeBeforeUpstreamCheckin = new Date(); // Current time

        // pause a couple seconds... [SCM-244]
        Thread.sleep( 2000 );

        // Make a change to the readme.txt and commit the change
        ScmTestCase.makeFile( getWorkingCopy(), "/readme.txt", "changed readme.txt" );
        ScmTestCase.makeFile( getWorkingCopy(), "/src/test/java/Test.java", "changed Test.java" );
        CheckInScmResult checkInResult = provider.checkIn( mainRepository, fileSet, "upstream workspace promote" );
        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );

        Thread.sleep( 2000 );

        Date timeBeforeDownstreamCheckin = new Date();

        Thread.sleep( 2000 );

        ScmFileSet updateFileSet = new ScmFileSet( getUpdatingCopy() );
        provider.update( mainRepository, updateFileSet );
        ScmTestCase.makeFile( getUpdatingCopy(), "/pom.xml", "changed pom.xml" );
        ScmTestCase.makeFile( getUpdatingCopy(), "/src/test/java/Test.java", "changed again Test.java" );
        checkInResult = provider.checkIn( mainRepository, updateFileSet, "downstream workspace promote" );
        assertTrue( "Unable to checkin changes to the repository", checkInResult.isSuccess() );

        Thread.sleep( 2000 );

        Date timeBeforeDownstreamPromote = new Date();

        List<File> promotedFiles = new ArrayList<File>();
        accurev.promoteStream( subStream, "stream promote", promotedFiles );

        Thread.sleep( 2000 );

        Date timeEnd = new Date();

        // Changelog beforeUpstreamCheckin to end should contain both upstream and downstream changes. upstream change
        // should NOT include Test.java

        ChangeLogScmResult result =
            provider.changeLog( mainRepository, fileSet, timeBeforeUpstreamCheckin, timeEnd, 0, branch );
        assertTrue( "changelog beforeUpstreamCheckin to end", result.isSuccess() );

        List<ChangeSet> changeSets = result.getChangeLog().getChangeSets();
        assertThat( changeSets.size(), is( 2 ) );
        assertThat( changeSets, hasItems( changeSet( "Upstream changes", "/readme.txt" ),
                                          changeSet( "downstream workspace promote", "/./pom.xml",
                                                     "/./src/test/java/Test.java" ) ) );

        // Changelog beforeUpstreamCheckin to beforeDownstreamCheckin should include just upstream change including
        // Test.java
        result =
            provider.changeLog( mainRepository, fileSet, timeBeforeUpstreamCheckin, timeBeforeDownstreamCheckin, 0,
                                branch );
        assertTrue( "changelog beforeUpstreamCheckin to beforeDownstreamCheckin", result.isSuccess() );

        changeSets = result.getChangeLog().getChangeSets();
        assertThat( changeSets.size(), is( 1 ) );
        assertThat( changeSets.get( 0 ), changeSet( "Upstream changes", "/readme.txt", "/src/test/java/Test.java" ) );

        // Changelog beforeDownstreamCheckin to end should include just downstream change
        result = provider.changeLog( mainRepository, fileSet, timeBeforeDownstreamCheckin, timeEnd, 0, branch );
        assertTrue( "changelog beforeDownstreamCheckin to end", result.isSuccess() );

        changeSets = result.getChangeLog().getChangeSets();
        assertThat( changeSets.size(), is( 1 ) );
        assertThat( changeSets.get( 0 ), changeSet( "downstream workspace promote", "/./pom.xml",
                                                    "/./src/test/java/Test.java" ) );

        // Changelog beforeDownstreamPromote to end should be empty
        result = provider.changeLog( mainRepository, fileSet, timeBeforeDownstreamPromote, timeEnd, 0, branch );
        assertTrue( "changelog beforeDownstreamPromote to end", result.isSuccess() );

        changeSets = result.getChangeLog().getChangeSets();
        assertThat( changeSets.size(), is( 0 ) );
View Full Code Here

    public void testInfoCommand()
        throws Exception
    {
        GitScmTestUtils.initRepo( "src/test/resources/git/info", getRepositoryRoot(), getWorkingCopy() );

        ScmProvider provider = getScmManager().getProviderByUrl( getScmUrl() );
        ScmProviderRepository repository = provider.makeProviderScmRepository( getRepositoryRoot() );
        assertNotNull( repository );
        InfoScmResult result =
            provider.info( repository, new ScmFileSet( getRepositoryRoot() ), new CommandParameters() );
        assertNotNull( result );
        assertEquals( "cd3c0dfacb65955e6fbb35c56cc5b1bf8ce4f767", result.getInfoItems().get( 0 ).getRevision() );
        //
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.provider.ScmProvider

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.