Package org.apache.maven.scm.provider.accurev

Examples of org.apache.maven.scm.provider.accurev.AccuRev


    @Override
    protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, AccuRevVersion version )
        throws AccuRevException
    {
        AccuRev accuRev = repository.getAccuRev();
        AccuRevInfo info = accuRev.info( basedir );
        String basisStream = version.getBasisStream();
        String transactionId = version.getTimeSpec();

        if ( !AccuRevVersion.isNow( transactionId )
            && !AccuRevCapability.POPULATE_TO_TRANSACTION.isSupported( accuRev.getClientVersion() ) )
        {
            getLogger().warn(
                              String.format( "Ignoring transaction id %s, Export can only extract current sources",
                                             transactionId ) );
            transactionId = "now";
        } else {
            //We might be heading to a transaction id that is not yet available on a replica
            accuRev.syncReplica();           
        }

        boolean removedWorkspace = false;

        // We'll do a pop -V.

        if ( info.isWorkSpace() )
        {

            String stat = accuRev.stat( basedir );

            if ( stat != null )
            {
                throw new AccuRevException(
                                            String.format(
                                                           "Cannot populate %s, as it is a non-ignored subdirectory of workspace %s rooted at %s.",
                                                           basedir.getAbsolutePath(), info.getWorkSpace(),
                                                           info.getTop() ) );
            }

            // ok, the subdirectory must be ignored. temporarily remove the workspace.
            removedWorkspace = accuRev.rmws( info.getWorkSpace() );

        }

        try
        {
            return accuRev.popExternal(
                                        basedir,
                                        basisStream,
                                        transactionId,
                                        Collections.singletonList( new File( repository.getDepotRelativeProjectPath() ) ) );

        }
        finally
        {
            if ( removedWorkspace )
            {
                accuRev.reactivate( info.getWorkSpace() );
            }
        }
    }
View Full Code Here


        List<Transaction> workspaceHistory = Collections.emptyList();
        List<FileDifference> streamDifferences = Collections.emptyList();

        StringBuilder errorMessage = new StringBuilder();

        AccuRev accurev = repository.getAccuRev();

        Stream changelogStream = accurev.showStream( stream );
        if ( changelogStream == null )
        {
            errorMessage.append( "Unknown accurev stream -" ).append( stream ).append( "." );
        }
        else
        {

            String message =
                "Changelog on stream " + stream + "(" + changelogStream.getStreamType() + ") from " + fromTranId + " ("
                    + startDate + "), to " + toTranId + " (" + endDate + ")";

            if ( startDate != null && startDate.after( endDate ) || fromTranId >= toTranId )
            {
                getLogger().warn( "Skipping out of range " + message );
            }
            else
            {

                getLogger().info( message );

                // In 4.7.2 and higher we have a diff command that will list all the file differences in a stream
                // and thus can be used to detect upstream changes
                // Unfortunately diff -v -V -t does not work in workspaces.
                Stream diffStream = changelogStream;
                if ( changelogStream.isWorkspace() )
                {

                    workspaceHistory =
                        accurev.history( stream, Long.toString( fromTranId + 1 ), Long.toString( toTranId ), 0, false,
                                         false );

                    if ( workspaceHistory == null )
                    {
                        errorMessage.append( "history on workspace " + stream + " from " + fromTranId + 1 + " to "
                            + toTranId + " failed." );

                    }

                    // do the diff/hist on the basis stream instead.
                    stream = changelogStream.getBasis();
                    diffStream = accurev.showStream( stream );

                }

                if ( AccuRevCapability.DIFF_BETWEEN_STREAMS.isSupported( accurev.getClientVersion() ) )
                {
                    if ( startDate.before( diffStream.getStartDate() ) )
                    {
                        getLogger().warn( "Skipping diff of " + stream + " due to start date out of range" );
                    }
                    else
                    {
                        streamDifferences =
                            accurev.diff( stream, Long.toString( fromTranId ), Long.toString( toTranId ) );
                        if ( streamDifferences == null )
                        {
                            errorMessage.append( "Diff " + stream + "- " + fromTranId + " to " + toTranId + "failed." );
                        }
                    }
                }

                // History needs to start from the transaction after our starting transaction

                streamHistory =
                    accurev.history( stream, Long.toString( fromTranId + 1 ), Long.toString( toTranId ), 0, false,
                                     false );
                if ( streamHistory == null )
                {
                    errorMessage.append( "history on stream " + stream + " from " + fromTranId + 1 + " to " + toTranId
                        + " failed." );
                }

            }
        }

        String errorString = errorMessage.toString();
        if ( StringUtils.isBlank( errorString ) )
        {
            ChangeLogSet changeLog =
                getChangeLog( changelogStream, streamDifferences, streamHistory, workspaceHistory, startDate, endDate );

            changeLog.setEndVersion( endVersion );
            changeLog.setStartVersion( startVersion );

            return new ChangeLogScmResult( accurev.getCommandLines(), changeLog );
        }
        else
        {
            return new ChangeLogScmResult( accurev.getCommandLines(), "AccuRev errors: " + errorMessage,
                                           accurev.getErrorOutput(), false );
        }

    }
View Full Code Here

    @Override
    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles,
                                      ScmVersion scmVersion )
    {
        AccuRev accuRev = repository.getAccuRev();
        if ( scmFiles != null )
        {
            if ( scmVersion == null )
            {
                return new ExportScmResult( accuRev.getCommandLines(), scmFiles );
            }
            else
            {
                return new ExportScmResultWithRevision( accuRev.getCommandLines(), scmFiles, scmVersion.toString() );
            }
        }
        else
        {
            return new ExportScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

    protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                               CommandParameters parameters )
        throws ScmException, AccuRevException
    {

        AccuRev accuRev = repository.getAccuRev();

        String message = parameters.getString( CommandParameter.MESSAGE );
        List<File> promotedFiles = null;

        File basedir = fileSet.getBasedir();
        List<File> fileList = fileSet.getFileList();

        if ( fileList.isEmpty() )
        {
            // TODO the above test will be matched by a fileset where excludes and includes produce a set with no files.
            // This is
            // NOT the same as a fileset created with only a base directory. Raise maven-scm JIRA for this.
            AccuRevInfo info = accuRev.info( basedir );

            if ( repository.isWorkSpaceRoot( info ) )
            {
                promotedFiles = accuRev.promoteAll( basedir, message );
            }
            else
            {
                throw new ScmException( String.format( "Unsupported recursive checkin for %s. Not the workspace root",
                                                       basedir.getAbsolutePath() ) );
            }
        }
        else
        {
            promotedFiles = accuRev.promote( basedir, fileList, message );
        }


        if ( promotedFiles != null )
        {
            Iterator<File> iter = promotedFiles.iterator();
            while ( iter.hasNext() )
            {
                if ( new File( basedir, iter.next().getPath() ).isDirectory() )
                {
                    iter.remove();
                }
            }
            // TODO capture the transaction id from the promote
            return new CheckInScmResult( accuRev.getCommandLines(), getScmFiles( promotedFiles,
                                                                                 ScmFileStatus.CHECKED_IN ) );
        }
        else
        {
            return new CheckInScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

    protected BlameScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                                    CommandParameters parameters )
        throws ScmException, AccuRevException
    {

        AccuRev accuRev = repository.getAccuRev();

        File file = new File( parameters.getString( CommandParameter.FILE ) );

        List<BlameLine> lines = accuRev.annotate( fileSet.getBasedir(), file );

        if ( lines != null )
        {
            return new BlameScmResult( accuRev.getCommandLines(), lines );
        }
        else
        {
            return new BlameScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }

    }
View Full Code Here

    protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                               CommandParameters parameters )
        throws ScmException, AccuRevException
    {

        AccuRev accuRev = repository.getAccuRev();

        String message = parameters.getString( CommandParameter.MESSAGE, "" );

        File basedir = fileSet.getBasedir();

        List<File> relativeFiles = fileSet.getFileList();

        final List<File> removedFiles = accuRev.defunct( basedir, relativeFiles, message );

        if ( removedFiles != null )
        {
            List<ScmFile> resultFiles = getScmFiles( removedFiles, ScmFileStatus.DELETED );
            return new RemoveScmResult( accuRev.getCommandLines(), resultFiles );
        }
        else
        {
            return new RemoveScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

    @Override
    protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, AccuRevVersion version )
        throws AccuRevException
    {
        AccuRev accuRev = repository.getAccuRev();

        AccuRevInfo info = accuRev.info( basedir );

        List<File> extractedFiles = new ArrayList<File>();
       
        String basisStream = version.getBasisStream();
        String transactionId = version.getTimeSpec();

        boolean success = true;
        if ( info.isWorkSpace() )
        {

            if ( !repository.isWorkSpaceTop( info ) )
            {
                throw new AccuRevException( String.format( "Can't checkout to %s, "
                    + "a subdirectory of existing workspace %s", basedir, info.getWorkSpace() ) );
            }
            // workspace exists at this basedir already.
            if ( !basisStream.equals( info.getBasis() ) )
            {
                // different basis, reparent.
                success = accuRev.chws( basedir, info.getWorkSpace(), basisStream );
            }

            if ( success )
            {
                // repopulate everything in the workspace.
                // note we do NOT want -t here, we just fill in any missing files
                // to the current transaction watermark...
                // the update later on will get the extra files
                List<File> poppedFiles = accuRev.pop( basedir, null );
                if ( poppedFiles != null )
                {
                    extractedFiles.addAll( poppedFiles );
                }
                else
                {
                    success = false;
                }
            }

        }
        else
        {
            // not a workspace, make one...
            // TODO set incl rules to only include the projectPath
            // TODO somehow set provider message (via throw exception?
            // if basisStream is null
            String workSpaceName = getWorkSpaceName( basedir, basisStream );

            success = accuRev.mkws( basisStream, workSpaceName, basedir );
           
            //Even though a new workspace starts with "0" as the high water mark
            //it can't be updated to anything less than its own mkstream transaction
            //now is close enough since even if something does sneak inbetween we
            //were just lucky that it didn't happen before...
            transactionId = "now";

            if ( success )
            {
                getLogger().info( "Created workspace " + workSpaceName );
            }
        }

        if ( success )
        {
            List<File> updatedFiles = accuRev.update( basedir, transactionId );
            if ( updatedFiles != null )
            {
                extractedFiles.addAll( updatedFiles );
            }
            else
View Full Code Here

    @Override
    protected List<File> extractSource( AccuRevScmProviderRepository repository, File basedir, AccuRevVersion version )
        throws AccuRevException
    {
        AccuRev accuRev = repository.getAccuRev();
        AccuRevInfo info = accuRev.info( basedir );
        String basisStream = version.getBasisStream();
        String transactionId = version.getTimeSpec();

        if ( !AccuRevVersion.isNow( transactionId )
            && !AccuRevCapability.POPULATE_TO_TRANSACTION.isSupported( accuRev.getClientVersion() ) )
        {
            getLogger().warn(
                              String.format( "Ignoring transaction id %s, Export can only extract current sources",
                                             transactionId ) );
            transactionId = "now";
        }
        else
        {
            //We might be heading to a transaction id that is not yet available on a replica
            accuRev.syncReplica();           
        }

        boolean removedWorkspace = false;

        // We'll do a pop -V.

        if ( info.isWorkSpace() )
        {

            String stat = accuRev.stat( basedir );

            if ( stat != null )
            {
                throw new AccuRevException( String.format( "Cannot populate %s, as it is a non-ignored "
                                                               + "subdirectory of workspace %s rooted at %s.",
                                                           basedir.getAbsolutePath(), info.getWorkSpace(),
                                                           info.getTop() ) );
            }

            // ok, the subdirectory must be ignored. temporarily remove the workspace.
            removedWorkspace = accuRev.rmws( info.getWorkSpace() );

        }

        try
        {
            File path = new File( repository.getDepotRelativeProjectPath() );
            return accuRev.popExternal( basedir, basisStream, transactionId, Collections.singletonList( path ) );
        }
        finally
        {
            if ( removedWorkspace )
            {
                accuRev.reactivate( info.getWorkSpace() );
            }
        }
    }
View Full Code Here

    protected ScmResult executeAccurevCommand( AccuRevScmProviderRepository repository, ScmFileSet fileSet,
                                               CommandParameters parameters )
        throws ScmException, AccuRevException
    {

        AccuRev accuRev = repository.getAccuRev();

        File basedir = fileSet.getBasedir();
        List<File> elements = fileSet.getFileList();

        List<File> defunctElements = accuRev.stat( basedir, elements, AccuRevStat.DEFUNCT );

        if ( defunctElements == null )
        {
            return error( accuRev, "Failed retrieving defunct elements" );
        }

        List<File> keptElements = accuRev.stat( basedir, elements, AccuRevStat.KEPT );

        // Defunct elements are also listed as kept (AccuRev 4.7.1), exclude those here.
        if ( keptElements == null )
        {
            return error( accuRev, "Failed retrieving kept elements" );
        }

        List<File> modOrAddedElements = new ArrayList<File>();

        for ( File file : keptElements )
        {
            if ( !defunctElements.contains( file ) )
            {
                modOrAddedElements.add( file );
            }
        }

        List<File> modifiedElements = accuRev.stat( basedir, elements, AccuRevStat.MODIFIED );

        if ( modifiedElements == null )
        {
            return error( accuRev, "Failed retrieving modified elements" );
        }

        modOrAddedElements.addAll( modifiedElements );

        CategorisedElements catElems = accuRev.statBackingStream( basedir, modOrAddedElements );

        if ( catElems == null )
        {
            return error( accuRev, "Failed stat backing stream to split modified and added elements" );
        }

        modifiedElements = catElems.getMemberElements();

        List<File> addedElements;
        if ( AccuRevCapability.STAT_ADDED_NOT_PROMOTED_BUG.isSupported( accuRev.getClientVersion() ) )
        {
            modOrAddedElements.removeAll( modifiedElements );
            addedElements = modOrAddedElements;
        }
        else
        {
            addedElements = catElems.getNonMemberElements();
        }

        List<File> missingElements = accuRev.stat( basedir, elements, AccuRevStat.MISSING );

        if ( missingElements == null )
        {
            return error( accuRev, "Failed retrieving missing elements" );
        }

        List<File> externalElements = accuRev.stat( basedir, elements, AccuRevStat.EXTERNAL );

        if ( externalElements == null )
        {
            return error( accuRev, "Failed retrieving external elements" );
        }

        List<ScmFile> resultFiles = getScmFiles( defunctElements, ScmFileStatus.DELETED );
        resultFiles.addAll( getScmFiles( modifiedElements, ScmFileStatus.MODIFIED ) );
        resultFiles.addAll( getScmFiles( addedElements, ScmFileStatus.ADDED ) );
        resultFiles.addAll( getScmFiles( missingElements, ScmFileStatus.MISSING ) );
        resultFiles.addAll( getScmFiles( externalElements, ScmFileStatus.UNKNOWN ) );

        return new StatusScmResult( accuRev.getCommandLines(), resultFiles );

    }
View Full Code Here

    @Override
    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles,
                                      ScmVersion scmVersion )
    {
        AccuRev accuRev = repository.getAccuRev();
        if ( scmFiles != null )
        {
            if ( scmVersion == null )
            {
                return new ExportScmResult( accuRev.getCommandLines(), scmFiles );
            }
            else
            {
                return new ExportScmResultWithRevision( accuRev.getCommandLines(), scmFiles, scmVersion.toString() );
            }
        }
        else
        {
            return new ExportScmResult( accuRev.getCommandLines(), "AccuRev Error", accuRev.getErrorOutput(), false );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.scm.provider.accurev.AccuRev

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.