protected void text( List<String> tagPath, String text ) { if ( logger.isDebugEnabled() ) { logger.debug( "TEXT: " + text ); } }
public static int execute( Commandline cl, CommandLineUtils.StringStreamConsumer stdout, CommandLineUtils.StringStreamConsumer stderr, ScmLogger logger ) throws ScmException { if ( logger.isInfoEnabled() ) { logger.info( "Executing: " + cl ); logger.info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode; try { exitCode = CommandLineUtils.executeCommandLine( cl, stdout, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } return exitCode; }
/** {@inheritDoc} */ public void warn( String content ) { for ( ScmLogger logger : listeners ) { logger.warn( content ); } }
/** {@inheritDoc} */ public void info( String content ) { for ( ScmLogger logger : listeners ) { if ( logger.isInfoEnabled() ) { logger.info( content ); } } }
/** {@inheritDoc} */ public void consumeLine( String line ) { if ( logger.isDebugEnabled() ) { logger.debug( "line " + line ); } checkedOutFiles.add( new ScmFile( line, ScmFileStatus.CHECKED_OUT ) ); }
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 StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().size() != 0 ) { throw new ScmException( "This provider doesn't support checking status of a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamStatusConsumer consumer = new StarteamStatusConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new StatusScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new StatusScmResult( cl.toString(), consumer.getChangedFiles() ); }
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() ); }
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 ); } } }
throws ScmException Commandline cl = createCommandLine( fileSet.getBasedir(), startRevision, endRevision ); CvsDiffConsumer consumer = new CvsDiffConsumer( getLogger(), fileSet.getBasedir() ); 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 DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
&& ( 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 executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet, String message, boolean binary ) throws ScmException { VssScmProviderRepository repo = (VssScmProviderRepository) repository; if ( fileSet.getFileList().isEmpty() ) { throw new ScmException( "You must provide at least one file/directory to add" ); } Commandline cl = buildCmdLine( repo, fileSet ); VssAddConsumer consumer = new VssAddConsumer( getLogger() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } int exitCode = VssCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new ChangeLogScmResult( cl.toString(), "The vss command failed.", stderr.getOutput(), false ); } return new AddScmResult( cl.toString(), consumer.getAddedFiles() ); }
private void processCheckedOutFile( String line, int pos ) { String checkedOutFilePath = this.currentDir + "/" + line.substring( 0, pos ); this.files.add( new ScmFile( checkedOutFilePath, ScmFileStatus.CHECKED_OUT ) ); if ( logger.isInfoEnabled() ) { logger.info( "Checked out: " + checkedOutFilePath ); } }
/** {@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() ); }
@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() ); }
/** {@inheritDoc} */ protected StatusScmResult executeStatusCommand( ScmProviderRepository repo, ScmFileSet fileSet ) throws ScmException { CvsScmProviderRepository repository = (CvsScmProviderRepository) repo; Commandline cl = CvsCommandUtils.getBaseCommand( "update", repository, fileSet, "-n" ); cl.createArg().setValue( "-d" ); if ( getLogger().isInfoEnabled() ) { getLogger().info( "Executing: " + cl ); getLogger().info( "Working directory: " + cl.getWorkingDirectory().getAbsolutePath() ); } return executeCvsCommand( cl ); }
/** {@inheritDoc} */ public void consumeLine( String line ) { if ( logger.isDebugEnabled() ) { logger.debug( line ); } String[] params = line.split( "/" ); if ( params.length < 2 ) { if ( StringUtils.isNotEmpty( line ) ) { if ( logger.isWarnEnabled() ) { logger.warn( "Unable to parse it as CVS/Entries format: " + line + "." ); } } } else { String dirSuf = params[0].indexOf( 'D' ) == -1 ? "" : "/"; entries.add( new ScmFile( params[1] + dirSuf, ScmFileStatus.UNKNOWN ) ); } }
/** {@inheritDoc} */ public void doConsume( ScmFileStatus status, String trimmedLine ) { if ( status != null && status == ScmFileStatus.ADDED ) { //Only include real files (not directories) File tmpFile = new File( workingDir, trimmedLine ); if ( !tmpFile.exists() ) { if ( getLogger().isWarnEnabled() ) { getLogger().warn( "Not a file: " + tmpFile + ". Ignored" ); } } else { ScmFile scmFile = new ScmFile( trimmedLine, ScmFileStatus.ADDED ); if ( getLogger().isInfoEnabled() ) { getLogger().info( scmFile.toString() ); } addedFiles.add( scmFile ); } } }
private AddScmResult executeAddFiles(File workingDirectory, List<File> files) throws ScmException { Commandline cl = createCommandLine(workingDirectory, files); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer(); int exitCode = -1; try { exitCode = GitCommandLineUtils.execute(cl, stdout, stderr, getLogger()); } catch (Throwable t) { getLogger().error("Failed:", t); } if (exitCode != 0) { String msg = stderr.getOutput(); getLogger().info("Add failed:" + msg); return new AddScmResult(cl.toString(), "The git-add command failed.", msg, false); } return null; }
protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { if ( getLogger().isWarnEnabled() ) { getLogger().warn( "Provider " + this.getScmType() + " does not support unedit operation." ); } return new UnEditScmResult( "", null, null, true ); }