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

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


    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
    {
        boolean result = false;
        AccuRev accurev = repository.getAccuRev();
        AccuRevInfo info = accurev.info( null );

        String providerMessage = "";
        if ( info == null )
        {
            providerMessage = "Unable to retrieve accurev info";
        }
        else if ( repository.getUser() != null )
        {
            // Check if we've already logged in as this user
            result = repository.getUser().equals( info.getUser() );
            if ( result )
            {
                providerMessage = "Skipping login - already logged in as " + repository.getUser();
            }
            else
            {
                result = accurev.login( repository.getUser(), repository.getPassword() );
                providerMessage = ( result ? "Success" : "Failure" ) + " logging in as " + repository.getUser();
            }
        }
        else
        {
            result = info.isLoggedIn();
            providerMessage = result ? ( "Logged in externally as " + info.getUser() ) : "Not logged in";
        }

        getLogger().debug( providerMessage );
        return new LoginScmResult( accurev.getCommandLines(), providerMessage, accurev.getErrorOutput(), result );

    }
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

    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();

        List<File> addedFiles = accuRev.add( basedir, relativeFiles, message );

        if ( addedFiles != null )
        {
            List<ScmFile> resultFiles = getScmFiles( addedFiles, ScmFileStatus.ADDED );
            return new AddScmResult( accuRev.getCommandLines(), resultFiles );
        }
        else
        {
            return new AddScmResult( 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

    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

    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

    @Override
    protected ScmResult getScmResult( AccuRevScmProviderRepository repository, List<ScmFile> scmFiles , ScmVersion version)
    {

        AccuRev accuRev = repository.getAccuRev();
        if ( scmFiles != null )
        {
            return new CheckOutScmResult( accuRev.getCommandLines(), scmFiles, repository.getProjectPath() );
        }
        else
        {
            return new CheckOutScmResult( 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 snapshotName = parameters.getString( CommandParameter.TAG_NAME );

        snapshotName = repository.getSnapshotName( snapshotName );

        File basedir = fileSet.getBasedir();
        boolean success = true;

        AccuRevInfo info = accuRev.info( basedir );
        List<File> taggedFiles = null;

        success = accuRev.mksnap( snapshotName, info.getBasis() );
        if ( success )
        {
            taggedFiles = accuRev.statTag( snapshotName );
        }

        if ( success && taggedFiles != null )
        {
            return new TagScmResult( accuRev.getCommandLines(), getScmFiles( taggedFiles, ScmFileStatus.TAGGED ) );
        }
        else
        {
            return new TagScmResult( 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();

        File basedir = fileSet.getBasedir();

        AccuRevInfo info = accuRev.info( basedir );

        if ( !info.isWorkSpace() )
        {
            throw new AccuRevException( "No workspace at " + basedir.getAbsolutePath() );
        }

        String startRevision = getStartRevision( repository, parameters, info );

        ScmVersion scmVersion = parameters.getScmVersion( CommandParameter.SCM_VERSION, null );

        String updateTransactionId = null;

        if ( scmVersion != null )
        {
            AccuRevVersion updateVersion = repository.getAccuRevVersion( scmVersion );

            // Reparent if necessary
            String newBasisStream = updateVersion.getBasisStream();
            if ( newBasisStream != null
                && ( !( newBasisStream.equals( info.getWorkSpace() ) || newBasisStream.equals( info.getBasis() ) ) ) )
            {
                getLogger().info( "Reparenting " + info.getWorkSpace() + " to " + newBasisStream );
                accuRev.chws( basedir, info.getWorkSpace(), newBasisStream );
            }

            if ( !updateVersion.isNow() )
            {
                updateTransactionId = updateVersion.getTimeSpec();
            }
        }

        if ( updateTransactionId == null )
        {
            updateTransactionId = repository.getDepotTransactionId( info.getWorkSpace(), "now" );
        }

        String endRevision = repository.getRevision( info.getWorkSpace(), updateTransactionId );

        List<File> updatedFiles = accuRev.update( basedir, updateTransactionId );

        if ( updatedFiles != null )
        {
            return new AccuRevUpdateScmResult( accuRev.getCommandLines(), getScmFiles( updatedFiles,
                                                                                       ScmFileStatus.UPDATED ),
                                               startRevision, endRevision );
        }
        else
        {
            return new AccuRevUpdateScmResult( accuRev.getCommandLines(), "AccuRev error", accuRev.getErrorOutput(),
                                               null, null, 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.