maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r527433 - in /maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src: main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/ test/java/org/apache/maven/scm/provider/svn/svnexe/command/change...
Date Wed, 11 Apr 2007 09:36:10 GMT
Author: evenisse
Date: Wed Apr 11 02:36:08 2007
New Revision: 527433

URL: http://svn.apache.org/viewvc?view=rev&rev=527433
Log:
Implement changelog command between two revisions

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java?view=diff&rev=527433&r1=527432&r2=527433
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/main/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommand.java
Wed Apr 11 02:36:08 2007
@@ -23,6 +23,7 @@
 import org.apache.maven.scm.ScmException;
 import org.apache.maven.scm.ScmFileSet;
 import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.ScmVersion;
 import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
 import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
 import org.apache.maven.scm.command.changelog.ChangeLogSet;
@@ -52,12 +53,29 @@
     private final static String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss Z";
 
     protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet
fileSet,
+                                                          ScmVersion startVersion, ScmVersion
endVersion,
+                                                          String datePattern )
+        throws ScmException
+    {
+        return executeChangeLogCommand( repo, fileSet, null, null, null, datePattern, startVersion,
endVersion );
+    }
+
+    protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet
fileSet,
                                                           Date startDate, Date endDate, ScmBranch
branch,
                                                           String datePattern )
         throws ScmException
     {
-        Commandline cl =
-            createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(), branch,
startDate, endDate );
+        return executeChangeLogCommand( repo, fileSet, startDate, endDate, branch, datePattern,
null, null );
+    }
+
+    protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet
fileSet,
+                                                          Date startDate, Date endDate, ScmBranch
branch,
+                                                          String datePattern, ScmVersion
startVersion,
+                                                          ScmVersion endVersion )
+        throws ScmException
+    {
+        Commandline cl = createCommandLine( (SvnScmProviderRepository) repo, fileSet.getBasedir(),
branch, startDate,
+                                            endDate, startVersion, endVersion );
 
         SvnChangeLogConsumer consumer = new SvnChangeLogConsumer( getLogger(), datePattern
);
 
@@ -81,9 +99,11 @@
         {
             return new ChangeLogScmResult( cl.toString(), "The svn command failed.", stderr.getOutput(),
false );
         }
+        ChangeLogSet changeLogSet = new ChangeLogSet( consumer.getModifications(), startDate,
endDate );
+        changeLogSet.setStartVersion( startVersion );
+        changeLogSet.setEndVersion( endVersion );
 
-        return new ChangeLogScmResult( cl.toString(),
-                                       new ChangeLogSet( consumer.getModifications(), startDate,
endDate ) );
+        return new ChangeLogScmResult( cl.toString(), changeLogSet );
     }
 
     // ----------------------------------------------------------------------
@@ -91,7 +111,8 @@
     // ----------------------------------------------------------------------
 
     public static Commandline createCommandLine( SvnScmProviderRepository repository, File
workingDirectory,
-                                                 ScmBranch branch, Date startDate, Date endDate
)
+                                                 ScmBranch branch, Date startDate, Date endDate,
+                                                 ScmVersion startVersion, ScmVersion endVersion
)
     {
         SimpleDateFormat dateFormat = new SimpleDateFormat( DATE_FORMAT );
 
@@ -117,6 +138,27 @@
             else
             {
                 cl.createArgument().setValue( "{" + dateFormat.format( startDate ) + "}:HEAD"
);
+            }
+        }
+
+        if ( startVersion != null )
+        {
+            cl.createArgument().setValue( "-r" );
+
+            if ( endVersion != null )
+            {
+                if ( startVersion.getName().equals( endVersion.getName() ) )
+                {
+                    cl.createArgument().setValue( startVersion.getName() );
+                }
+                else
+                {
+                    cl.createArgument().setValue( startVersion.getName() + ":" + endVersion.getName()
);
+                }
+            }
+            else
+            {
+                cl.createArgument().setValue( startVersion.getName() + ":HEAD" );
             }
         }
 

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java?view=diff&rev=527433&r1=527432&r2=527433
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-svn/maven-scm-provider-svnexe/src/test/java/org/apache/maven/scm/provider/svn/svnexe/command/changelog/SvnChangeLogCommandTest.java
Wed Apr 11 02:36:08 2007
@@ -21,6 +21,8 @@
 
 import org.apache.maven.scm.ScmBranch;
 import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.ScmRevision;
 import org.apache.maven.scm.provider.svn.repository.SvnScmProviderRepository;
 import org.apache.maven.scm.repository.ScmRepository;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -118,6 +120,27 @@
                          "svn --non-interactive log -v -r \"{2003-09-10 00:00:00 +0000}:{2003-10-10
00:00:00 +0000}\" http://foo.com/svn/branches/my-test-branch http://foo.com/svn/trunk" );
     }
 
+    public void testCommandLineWithStartVersion()
+        throws Exception
+    {
+        testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision("1"), null,
+                         "svn --non-interactive log -v -r 1:HEAD http://foo.com/svn/branches/my-test-branch
http://foo.com/svn/trunk" );
+    }
+
+    public void testCommandLineWithStartVersionAndEndVersion()
+        throws Exception
+    {
+        testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision("1"), new ScmRevision("10"),
+                         "svn --non-interactive log -v -r 1:10 http://foo.com/svn/branches/my-test-branch
http://foo.com/svn/trunk" );
+    }
+
+    public void testCommandLineWithStartVersionAndEndVersionEquals()
+        throws Exception
+    {
+        testCommandLine( "scm:svn:http://foo.com/svn/trunk", new ScmRevision("1"), new ScmRevision("1"),
+                         "svn --non-interactive log -v -r 1 http://foo.com/svn/branches/my-test-branch
http://foo.com/svn/trunk" );
+    }
+
     // ----------------------------------------------------------------------
     //
     // ----------------------------------------------------------------------
@@ -131,8 +154,23 @@
 
         SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
 
-        Commandline cl =
-            SvnChangeLogCommand.createCommandLine( svnRepository, workingDirectory, branch,
startDate, endDate );
+        Commandline cl = SvnChangeLogCommand.createCommandLine( svnRepository, workingDirectory,
branch, startDate,
+                                                                endDate, null, null );
+
+        assertEquals( commandLine, cl.toString() );
+    }
+
+    private void testCommandLine( String scmUrl, ScmVersion startVersion, ScmVersion endVersion,
String commandLine )
+        throws Exception
+    {
+        File workingDirectory = getTestFile( "target/svn-update-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+
+        SvnScmProviderRepository svnRepository = (SvnScmProviderRepository) repository.getProviderRepository();
+
+        Commandline cl = SvnChangeLogCommand.createCommandLine( svnRepository, workingDirectory,
null, null, null,
+                                                                startVersion, endVersion
);
 
         assertEquals( commandLine, cl.toString() );
     }



Mime
View raw message