/** {@inheritDoc} */ public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { ScmVersion startRevision = parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); ScmVersion endRevision = parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); return executeDiffCommand( repository, fileSet, startRevision, endRevision ); } }
return new DiffScmResult( cl.toString(), "The cvs command failed.", logListener.getStderr().toString(), false ); return new DiffScmResult( cl.toString(), "The cvs command failed.", logListener.getStdout().toString(), false ); return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion ) throws ScmException { GitDiffConsumer consumer = new GitDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; Commandline clDiff2Index = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, false ); exitCode = GitCommandLineUtils.execute( clDiff2Index, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( clDiff2Index.toString(), "The git-diff command failed.", stderr.getOutput(), false ); } Commandline clDiff2Head = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, true ); exitCode = GitCommandLineUtils.execute( clDiff2Head, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( clDiff2Head.toString(), "The git-diff command failed.", stderr.getOutput(), false ); } return new DiffScmResult( clDiff2Index.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
/** {@inheritDoc} */ public ScmResult executeCommand( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) throws ScmException { ScmVersion startRevision = parameters.getScmVersion( CommandParameter.START_SCM_VERSION, null ); ScmVersion endRevision = parameters.getScmVersion( CommandParameter.END_SCM_VERSION, null ); return executeDiffCommand( repository, fileSet, startRevision, endRevision ); } }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion ) throws ScmException { GitDiffConsumer consumer = new GitDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); int exitCode; Commandline clDiff2Index = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, false ); exitCode = GitCommandLineUtils.execute( clDiff2Index, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( clDiff2Index.toString(), "The git-diff command failed.", stderr.getOutput(), false ); } Commandline clDiff2Head = createCommandLine( fileSet.getBasedir(), startVersion, endVersion, true ); exitCode = GitCommandLineUtils.execute( clDiff2Head, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( clDiff2Head.toString(), "The git-diff command failed.", stderr.getOutput(), false ); } return new DiffScmResult( clDiff2Index.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision ) throws ScmException { String[] diffCmd; if ( startRevision != null && !StringUtils.isEmpty( startRevision.getName() ) ) { String revArg = startRevision.getName(); if ( endRevision != null && !StringUtils.isEmpty( endRevision.getName() ) ) { revArg += ".." + endRevision; } diffCmd = new String[] { HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, revArg }; } else { diffCmd = new String[] { HgCommandConstants.DIFF_CMD }; } diffCmd = HgUtils.expandCommandLine( diffCmd, fileSet ); HgDiffConsumer consumer = new HgDiffConsumer( getLogger(), fileSet.getBasedir() ); ScmResult result = HgUtils.execute( consumer, getLogger(), fileSet.getBasedir(), diffCmd ); return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result ); } }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision ) throws ScmException { String[] diffCmd; if ( startRevision != null && !StringUtils.isEmpty( startRevision.getName() ) ) { String revArg = startRevision.getName(); if ( endRevision != null && !StringUtils.isEmpty( endRevision.getName() ) ) { revArg += ".." + endRevision; } diffCmd = new String[] { HgCommandConstants.DIFF_CMD, HgCommandConstants.REVISION_OPTION, revArg }; } else { diffCmd = new String[] { HgCommandConstants.DIFF_CMD }; } diffCmd = HgUtils.expandCommandLine( diffCmd, fileSet ); HgDiffConsumer consumer = new HgDiffConsumer( getLogger(), fileSet.getBasedir() ); ScmResult result = HgUtils.execute( consumer, getLogger(), fileSet.getBasedir(), diffCmd ); return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result ); } }
public DiffScmResult callDiff( Git git, ScmVersion startRevision, ScmVersion endRevision ) throws IOException, GitAPIException, ScmException { AbstractTreeIterator oldTree = null; if ( startRevision != null && StringUtils.isNotEmpty( startRevision.getName().trim() ) ) { String startRev = startRevision.getName().trim(); oldTree = getTreeIterator( git.getRepository(), startRev ); } AbstractTreeIterator newTree = null; if ( endRevision != null && StringUtils.isNotEmpty( endRevision.getName().trim() ) ) { String endRev = endRevision.getName().trim(); newTree = getTreeIterator( git.getRepository(), endRev ); } OutputStream out = new ByteArrayOutputStream(); git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( false ).call(); git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( true ).call(); out.flush(); GitDiffConsumer consumer = new GitDiffConsumer( getLogger(), null ); String fullDiff = out.toString(); out.close(); String[] lines = fullDiff.split( "\n" ); for ( String aLine : lines ) { consumer.consumeLine( aLine ); } return new DiffScmResult( "JGit diff", consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
public DiffScmResult callDiff( Git git, ScmVersion startRevision, ScmVersion endRevision ) throws IOException, GitAPIException, ScmException { AbstractTreeIterator oldTree = null; if ( startRevision != null && StringUtils.isNotEmpty( startRevision.getName().trim() ) ) { String startRev = startRevision.getName().trim(); oldTree = getTreeIterator( git.getRepository(), startRev ); } AbstractTreeIterator newTree = null; if ( endRevision != null && StringUtils.isNotEmpty( endRevision.getName().trim() ) ) { String endRev = endRevision.getName().trim(); newTree = getTreeIterator( git.getRepository(), endRev ); } OutputStream out = new ByteArrayOutputStream(); git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( false ).call(); git.diff().setOutputStream( out ).setOldTree( oldTree ).setNewTree( newTree ).setCached( true ).call(); out.flush(); GitDiffConsumer consumer = new GitDiffConsumer( getLogger(), null ); String fullDiff = out.toString(); out.close(); String[] lines = fullDiff.split( "\n" ); for ( String aLine : lines ) { consumer.consumeLine( aLine ); } return new DiffScmResult( "JGit diff", consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startRevision, ScmVersion endRevision ) throws ScmException { String[] diffCmd; if ( startRevision != null && StringUtils.isNotEmpty( startRevision.getName() ) ) { String revArg = startRevision.getName(); if ( endRevision != null && StringUtils.isNotEmpty( endRevision.getName() ) ) { revArg += ".." + endRevision.getName(); } diffCmd = new String[]{BazaarConstants.DIFF_CMD, BazaarConstants.REVISION_OPTION, revArg}; } else { diffCmd = new String[]{BazaarConstants.DIFF_CMD}; } diffCmd = BazaarUtils.expandCommandLine( diffCmd, fileSet ); BazaarDiffConsumer consumer = new BazaarDiffConsumer( getLogger(), fileSet.getBasedir() ); ScmResult result = BazaarUtils.execute( consumer, getLogger(), fileSet.getBasedir(), diffCmd ); return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch(), result ); } }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support diff command on a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamDiffConsumer consumer = new StarteamDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet, startVersion, endVersion ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
/** {@inheritDoc} */ protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion startVersion, ScmVersion endVersion ) throws ScmException { if ( getLogger().isInfoEnabled() ) { getLogger().info( "Working directory: " + fileSet.getBasedir().getAbsolutePath() ); } if ( fileSet.getFileList().isEmpty() ) { throw new ScmException( "This provider doesn't support diff command on a subsets of a directory" ); } StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo; StarteamDiffConsumer consumer = new StarteamDiffConsumer( getLogger(), fileSet.getBasedir() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); Commandline cl = createCommandLine( repository, fileSet, startVersion, endVersion ); int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() ); if ( exitCode != 0 ) { return new DiffScmResult( cl.toString(), "The starteam command failed.", stderr.getOutput(), false ); } return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); }
/** {@inheritDoc} */ protected DiffScmResult executeCvsCommand( Commandline cl ) throws ScmException { CvsDiffConsumer consumer = new CvsDiffConsumer( getLogger(), cl.getWorkingDirectory() ); CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer(); try { CommandLineUtils.executeCommandLine( cl, consumer, stderr ); } catch ( CommandLineException ex ) { throw new ScmException( "Error while executing command.", ex ); } // TODO: a difference returns a code of "1", as does errors. How to tell the difference? // if ( exitCode != 0 ) // { // return new DiffScmResult( cl.toString(), "The cvs command failed.", stderr.getOutput(), false ); // } return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() ); } }
return new DiffScmResult( command, "The diff2 command failed.", p4Result.getFileDiffOutput(), p4Result.isSuccess() ); return new DiffScmResult( command, p4Result.getChangedFiles(), p4Result.getDifferences(), p4Result.getPatch() );
return new DiffScmResult( cl.toString(), success ? "Diff successful" : "Unable to diff", consumer .getOutput(), success );
return new DiffScmResult( cl.toString(), success ? "Diff successful" : "Unable to diff", consumer .getOutput(), success );
return new DiffScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
return new DiffScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(), false ); return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );
return new DiffScmResult( cl.toString(), consumer.getChangedFiles(), consumer.getDifferences(), consumer.getPatch() );