maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject cvs commit: maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff CvsDiffCommand.java CvsDiffConsumer.java
Date Wed, 12 Jan 2005 11:56:53 GMT
brett       2005/01/12 03:56:52

  Modified:    maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff
                        SvnDiffCommand.java SvnDiffConsumer.java
               maven-scm-api/src/main/java/org/apache/maven/scm/command/diff
                        DiffScmResult.java
               maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff
                        CvsDiffCommand.java CvsDiffConsumer.java
  Log:
  generate a full patch as well
  
  Revision  Changes    Path
  1.3       +8 -5      maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommand.java
  
  Index: SvnDiffCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffCommand.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- SvnDiffCommand.java	12 Jan 2005 10:30:53 -0000	1.2
  +++ SvnDiffCommand.java	12 Jan 2005 11:56:52 -0000	1.3
  @@ -37,10 +37,12 @@
       extends AbstractDiffCommand
       implements SvnCommand
   {
  -    protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet
fileSet, String startRevision, String endRevision )
  +    protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet
fileSet, String startRevision,
  +                                                String endRevision )
           throws ScmException
       {
  -        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(),
startRevision, endRevision );
  +        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(),
startRevision,
  +                                            endRevision );
   
           SvnDiffConsumer consumer = new SvnDiffConsumer( getLogger(), fileSet.getBasedir()
);
   
  @@ -65,14 +67,15 @@
               return new DiffScmResult( "The svn command failed.", stderr.getOutput(), false
);
           }
   
  -        return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences()
);
  +        return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(),
consumer.getPatch() );
       }
   
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
   
  -    public static Commandline createCommandLine( SvnScmProviderRepository repository, File
workingDirectory, String startRevision, String endRevision )
  +    public static Commandline createCommandLine( SvnScmProviderRepository repository, File
workingDirectory,
  +                                                 String startRevision, String endRevision
)
       {
           Commandline cl = new Commandline();
   
  
  
  
  1.4       +19 -2     maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java
  
  Index: SvnDiffConsumer.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-svn/src/main/java/org/apache/maven/scm/provider/svn/command/diff/SvnDiffConsumer.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- SvnDiffConsumer.java	12 Jan 2005 11:16:59 -0000	1.3
  +++ SvnDiffConsumer.java	12 Jan 2005 11:56:52 -0000	1.4
  @@ -31,7 +31,8 @@
    * @author <a href="mailto:brett@apache.org">Brett Porter</a>
    * @version $Id$
    */
  -public class SvnDiffConsumer implements StreamConsumer
  +public class SvnDiffConsumer
  +    implements StreamConsumer
   {
   //
   // Index: plugin.jelly
  @@ -74,6 +75,8 @@
   
       private Map differences = new HashMap();
   
  +    private StringBuffer patch = new StringBuffer();
  +
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
  @@ -102,26 +105,32 @@
   
               differences.put( currentFile, currentDifference );
   
  +            patch.append( line ).append( "\n" );
  +
               return;
           }
   
           if ( currentFile == null )
           {
               logger.warn( "Unparseable line: '" + line + "'" );
  +            patch.append( line ).append( "\n" );
               return;
           }
   
           if ( line.startsWith( FILE_SEPARATOR_TOKEN ) )
           {
               // skip
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( START_REVISION_TOKEN ) )
           {
               // skip, though could parse to verify filename, start revision
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( END_REVISION_TOKEN ) )
           {
               // skip, though could parse to verify filename, end revision
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( ADDED_LINE_TOKEN ) || line.startsWith( REMOVED_LINE_TOKEN
) ||
               line.startsWith( UNCHANGED_LINE_TOKEN ) || line.startsWith( CHANGE_SEPARATOR_TOKEN
) ||
  @@ -129,12 +138,14 @@
           {
               // add to buffer
               currentDifference.append( line ).append( "\n" );
  +            patch.append( line ).append( "\n" );
           }
           else
           {
               // TODO: handle property differences
   
               logger.warn( "Unparseable line: '" + line + "'" );
  +            patch.append( line ).append( "\n" );
               // skip to next file
               currentFile = null;
               currentDifference = null;
  @@ -150,4 +161,10 @@
       {
           return differences;
       }
  +
  +    public String getPatch()
  +    {
  +        return patch.toString();
  +    }
  +
   }
  
  
  
  1.3       +11 -5     maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java
  
  Index: DiffScmResult.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DiffScmResult.java	12 Jan 2005 10:30:53 -0000	1.2
  +++ DiffScmResult.java	12 Jan 2005 11:56:52 -0000	1.3
  @@ -22,8 +22,6 @@
   import java.util.Map;
   
   /**
  - * @todo allow different formats, currently assumes unified diff, include new files
  - * @todo probably need to parse command output into individual diffs instead
    * @author <a href="mailto:brett@apache.org">Brett Porter</a>
    * @version $Id$
    */
  @@ -34,11 +32,14 @@
   
       private Map differences;
   
  -    public DiffScmResult( List changedFiles, Map differences )
  +    private String patch;
  +
  +    public DiffScmResult( List changedFiles, Map differences, String patch )
       {
  -        super();
  +        this( null, null, true );
           this.changedFiles = changedFiles;
           this.differences = differences;
  +        this.patch = patch;
       }
   
       public DiffScmResult( String providerMessage, String commandOutput, boolean success
)
  @@ -54,5 +55,10 @@
       public Map getDifferences()
       {
           return differences;
  +    }
  +
  +    public String getPatch()
  +    {
  +        return patch;
       }
   }
  
  
  
  1.2       +5 -3      maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffCommand.java
  
  Index: CvsDiffCommand.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffCommand.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CvsDiffCommand.java	12 Jan 2005 11:17:00 -0000	1.1
  +++ CvsDiffCommand.java	12 Jan 2005 11:56:52 -0000	1.2
  @@ -32,7 +32,9 @@
    * @author <a href="mailto:brett@apache.org">Brett Porter</a>
    * @version $Id$
    */
  -public class CvsDiffCommand extends AbstractDiffCommand implements CvsCommand
  +public class CvsDiffCommand
  +    extends AbstractDiffCommand
  +    implements CvsCommand
   {
       protected DiffScmResult executeDiffCommand( ScmProviderRepository repo, ScmFileSet
fileSet, String startRevision,
                                                   String endRevision )
  @@ -64,7 +66,7 @@
   //            return new DiffScmResult( "The cvs command failed.", stderr.getOutput(),
false );
   //        }
   
  -        return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences()
);
  +        return new DiffScmResult( consumer.getChangedFiles(), consumer.getDifferences(),
consumer.getPatch() );
       }
   
       // ----------------------------------------------------------------------
  
  
  
  1.2       +19 -2     maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffConsumer.java
  
  Index: CvsDiffConsumer.java
  ===================================================================
  RCS file: /home/cvs/maven-scm/maven-scm-providers/maven-scm-provider-cvs/src/test/java/org/apache/maven/scm/provider/cvslib/command/diff/CvsDiffConsumer.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- CvsDiffConsumer.java	12 Jan 2005 11:17:00 -0000	1.1
  +++ CvsDiffConsumer.java	12 Jan 2005 11:56:52 -0000	1.2
  @@ -32,7 +32,8 @@
    * @version $Id$
    * @todo share with SVN (3 extra lines can be ignored)
    */
  -public class CvsDiffConsumer implements StreamConsumer
  +public class CvsDiffConsumer
  +    implements StreamConsumer
   {
   //
   // Index: plugin.jelly
  @@ -80,6 +81,8 @@
   
       private Map differences = new HashMap();
   
  +    private StringBuffer patch = new StringBuffer();
  +
       // ----------------------------------------------------------------------
       //
       // ----------------------------------------------------------------------
  @@ -108,26 +111,32 @@
   
               differences.put( currentFile, currentDifference );
   
  +            patch.append( line ).append( "\n" );
  +
               return;
           }
   
           if ( currentFile == null )
           {
               logger.warn( "Unparseable line: '" + line + "'" );
  +            patch.append( line ).append( "\n" );
               return;
           }
   
           if ( line.startsWith( FILE_SEPARATOR_TOKEN ) )
           {
               // skip
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( START_REVISION_TOKEN ) )
           {
               // skip, though could parse to verify filename, start revision
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( END_REVISION_TOKEN ) )
           {
               // skip, though could parse to verify filename, end revision
  +            patch.append( line ).append( "\n" );
           }
           else if ( line.startsWith( RCS_TOKEN ) )
           {
  @@ -147,10 +156,12 @@
           {
               // add to buffer
               currentDifference.append( line ).append( "\n" );
  +            patch.append( line ).append( "\n" );
           }
           else
           {
               logger.warn( "Unparseable line: '" + line + "'" );
  +            patch.append( line ).append( "\n" );
               // skip to next file
               currentFile = null;
               currentDifference = null;
  @@ -166,4 +177,10 @@
       {
           return differences;
       }
  +
  +    public String getPatch()
  +    {
  +        return patch.toString();
  +    }
  +
   }
  
  
  

Mime
View raw message