public UpdateScmResult executeUpdateCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag ) throws ScmException Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.setWorkingDirectory( fileSet.getBasedir().getAbsolutePath() ); cl.createArgument().setValue( "-f" ); // don't use ~/.cvsrc CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); throw new ScmException( "Error while executing command.", ex ); return new UpdateScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false );
public void consumeLine( String line ) { logger.debug( "ErrorConsumer.consumeLine: " + line ); fFed = true; super.consumeLine( line ); }
/** {@inheritDoc} */ protected ScmResult executeTagCommand( ScmProviderRepository repo, ScmFileSet fileSet, String tag, ScmTagParameters scmTagParameters ) throws ScmException { if ( !fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support tagging subsets of a directory" ); } if ( tag == null || tag.trim().length() == 0 ) { throw new ScmException( "tag must be specified" ); } if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamTagConsumer consumer = new StarteamTagConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet.getBasedir(), tag ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new TagScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new TagScmResult( cl.toString(), consumer.getTaggedFiles() ); }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "executing blame command..." ); } Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); ClearCaseBlameConsumer consumer = new ClearCaseBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( "Executing: " + cl.getWorkingDirectory().getAbsolutePath() + ">>" + cl.toString() ); } exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing cvs command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The cleartool command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
throws ScmException Commandline shell = new Commandline(); shell.setWorkingDirectory( workingDirectory.getBasedir() ); shell.setExecutable( "si" ); shell.createArg().setValue( "connect" ); shell.createArg().setValue( "--hostname=" + iRepo.getHost() ); shell.createArg().setValue( "--batch" ); shell.createArg().setValue( "--password=" + iRepo.getPassword() ); CommandLineUtils.StringStreamConsumer shellConsumer = new CommandLineUtils.StringStreamConsumer(); getLogger().debug( "Executing: " + CommandLineUtils.toString( shell.getCommandline() ) ); int exitCode = CommandLineUtils.executeCommandLine( shell, shellConsumer, shellConsumer ); if ( exitCode != 0 ) throw new ScmException( "Can't login to integrity. Message : " + shellConsumer.toString() ); getLogger().error( "Command Line Connect Exception: " + cle.getMessage() ); throw new ScmException( "Can't login to integrity. Message : " + cle.getMessage() );
/** {@inheritDoc} */ protected AddScmResult executeCvsCommand( Commandline cl, List<ScmFile> addedFiles ) throws ScmException { CommandLineUtils.StringStreamConsumer consumer = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } // TODO: actually it may have partially succeeded - should we cvs update the files and parse "A " responses? if ( exitCode != 0 ) { return new AddScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new AddScmResult( cl.toString(), addedFiles ); } }
public static boolean isCvsNT() throws ScmException { Commandline cl = new Commandline(); cl.setExecutable( "cvs" ); cl.createArg().setValue( "-v" ); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException e ) { throw new ScmException( "Error while executing command.", e ); } return stdout.getOutput().indexOf( "CVSNT" ) >= 0; }
private void syncLabel( ScmProviderRepository repo, ScmFileSet files, String tag, PerforceTagConsumer consumer ) { Commandline cl = createLabelsyncCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files, tag ); try { if ( getLogger().isDebugEnabled() ) { getLogger().debug( PerforceScmProvider.clean( "Executing: " + cl.toString() ) ); } CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "CommandLineException " + e.getMessage(), e ); } } }
protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { Commandline cl = createCommandLine( fileSet ); CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); int exitCode; getLogger().debug( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); getLogger().debug( "Command line: " + cl ); try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
throws ScmException Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir() ); PerforceLoginConsumer consumer = new PerforceLoginConsumer(); boolean isSuccess = false; if ( StringUtils.isEmpty( password ) ) if ( getLogger().isInfoEnabled() ) getLogger().info( "No password found, proceeding without it." ); CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, new ByteArrayInputStream( password.getBytes() ), consumer, err ); isSuccess = consumer.isSuccess(); String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new ScmException( e.getMessage(), e ); return new LoginScmResult( cl.toString(), isSuccess ? "Login successful" : "Login failed", consumer.getOutput(), isSuccess );
&& ( getLogger().isWarnEnabled() ) ) getLogger().warn( "This provider doesn't support changelog with on a given branch." ); new StarteamChangeLogConsumer( fileSet.getBasedir(), getLogger(), startDate, endDate, datePattern ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); throw new ScmException( "Error while executing command.", ex ); return new ChangeLogScmResult( cl.toString(), "The 'stcmd' command failed.", stderr.getOutput(), false ); return new ChangeLogScmResult( cl.toString(), new ChangeLogSet( consumer.getModifications(), startDate, endDate ) );
/** * {@inheritDoc} */ protected ScmResult executeRemoveCommand( ScmProviderRepository repo, ScmFileSet files, String message ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceRemoveConsumer consumer = new PerforceRemoveConsumer(); try { CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { throw new ScmException( "CommandLineException " + e.getMessage(), e ); } return new RemoveScmResult( cl.toString(), consumer.getRemovals() ); }
throws ScmException Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), version ); SvnUpdateConsumer consumer = new SvnUpdateConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) getLogger().info( "Executing: " + SvnCommandLineUtils.cryptPassword( cl ) ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); throw new ScmException( "Error while executing command.", ex ); return new UpdateScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); UpdateScmResultWithRevision result = new UpdateScmResultWithRevision( cl.toString(), consumer.getUpdatedFiles(), String.valueOf( consumer.getRevision() ) );
/** {@inheritDoc} */ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet files, String message, boolean binary ) throws ScmException { Commandline cl = createCommandLine( (PerforceScmProviderRepository) repo, files.getBasedir(), files ); PerforceAddConsumer consumer = new PerforceAddConsumer(); try { CommandLineUtils.StringStreamConsumer err = new CommandLineUtils.StringStreamConsumer(); int exitCode = CommandLineUtils.executeCommandLine( cl, consumer, err ); if ( exitCode != 0 ) { String cmdLine = CommandLineUtils.toString( cl.getCommandline() ); StringBuilder msg = new StringBuilder( "Exit code: " + exitCode + " - " + err.getOutput() ); msg.append( '\n' ); msg.append( "Command line was:" + cmdLine ); throw new CommandLineException( msg.toString() ); } } catch ( CommandLineException e ) { if ( getLogger().isErrorEnabled() ) { getLogger().error( "CommandLineException " + e.getMessage(), e ); } } return new AddScmResult( cl.toString(), consumer.getAdditions() ); }
public BlameScmResult executeBlameCommand( ScmProviderRepository repo, ScmFileSet workingDirectory, String filename ) throws ScmException { Commandline cl = createCommandLine( workingDirectory.getBasedir(), filename ); TfsBlameConsumer consumer = new TfsBlameConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new BlameScmResult( cl.toString(), "The tfs command failed.", stderr.getOutput(), false ); } return new BlameScmResult( cl.toString(), consumer.getLines() ); }
/** {@inheritDoc} */ protected StatusScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsStatusConsumer consumer = new CvsStatusConsumer( getLogger(), cl.getWorkingDirectory() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); } }
/** {@inheritDoc} */ protected ScmResult executeAddCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message, boolean binary ) throws ScmException { //work around until maven-scm-api allow this String issue = System.getProperty( "maven.scm.issue" ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamAddConsumer consumer = new StarteamAddConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); for ( File fileToBeAdded : fileSet.getFileList() ) { ScmFileSet scmFile = new ScmFileSet( fileSet.getBasedir(), fileToBeAdded ); Commandline cl = createCommandLine( repository, scmFile, issue ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new AddScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } } return new AddScmResult( null, consumer.getAddedFiles() ); }
@Override protected ScmResult executeRemoveCommand(ScmProviderRepository repo, ScmFileSet fileSet, String message) throws ScmException { if (fileSet.getFileList().isEmpty()) { throw new ScmException("You must provide at least one file/directory to remove"); } Commandline cl = createCommandLine(fileSet.getBasedir(), fileSet.getFileList()); GitRemoveConsumer consumer = new GitRemoveConsumer(getLogger()); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; exitCode = GitCommandLineUtils.execute(cl, consumer, stderr, getLogger()); if (exitCode != 0) { return new RemoveScmResult(cl.toString(), "The git command failed.", stderr.getOutput(), false); } return new RemoveScmResult(cl.toString(), consumer.getRemovedFiles()); }
@Override protected StatusScmResult executeStatusCommand(ScmProviderRepository repo, ScmFileSet fileSet) throws ScmException { Commandline cl = createCommandLine( (GitScmProviderRepository) repo, fileSet ); File repoRootDirectory = ScmSyncGitUtils.getRepositoryRootDirectory(fileSet.getBasedir(), getLogger()); FixedGitStatusConsumer consumer = new FixedGitStatusConsumer(getLogger(), fileSet.getBasedir(), repoRootDirectory); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode = GitCommandLineUtils.execute( cl, consumer, stderr, getLogger() ); if (exitCode != 0) { if (getLogger().isInfoEnabled()) { getLogger().info( "nothing added to commit but untracked files present (use \"git add\" to track)" ); } } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
private static int checkIfCleanUpIsNeeded( int exitCode, Commandline cl, StreamConsumer consumer, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws CommandLineException { if ( exitCode != 0 && stderr.getOutput() != null && stderr.getOutput().indexOf( "'svn cleanup'" ) > 0 && stderr.getOutput().indexOf( "'svn help cleanup'" ) > 0 ) { if ( logger.isInfoEnabled() ) { logger.info( "Svn command failed due to some locks in working copy. We try to run a 'svn cleanup'." ); } if ( executeCleanUp( cl.getWorkingDirectory(), consumer, stderr, logger ) == 0 ) { exitCode = CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } } return exitCode; }