You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm-commits@maven.apache.org by da...@apache.org on 2006/11/17 10:06:23 UTC
svn commit: r476085 - in
/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src:
main/java/org/apache/maven/scm/provider/starteam/command/
main/java/org/apache/maven/scm/provider/starteam/command/add/
main/java/org/apache/maven/scm/provid...
Author: dantran
Date: Fri Nov 17 01:06:22 2006
New Revision: 476085
URL: http://svn.apache.org/viewvc?view=rev&rev=476085
Log:
fix invalid stcmd's argument when ci/add files in ScmFileSet with basedir is not working directory
Modified:
maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/StarteamCommandLineUtils.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommand.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommand.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommandTest.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommandTest.java
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/StarteamCommandLineUtils.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/StarteamCommandLineUtils.java?view=diff&rev=476085&r1=476084&r2=476085
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/StarteamCommandLineUtils.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/StarteamCommandLineUtils.java Fri Nov 17 01:06:22 2006
@@ -17,6 +17,7 @@
*/
import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.log.ScmLogger;
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
import org.apache.maven.scm.provider.starteam.util.StarteamUtil;
@@ -118,8 +119,56 @@
return cl;
}
+
+ public static Commandline createStarteamBaseCommandLine( String action, ScmFileSet scmFileSet,
+ StarteamScmProviderRepository repo )
+ {
+ Commandline cl = StarteamCommandLineUtils.createStarteamBaseCommandLine( action, repo );
+
+ if ( scmFileSet.getFileList().size() == 0 )
+ {
+ //perform an action on directory
+ cl.createArgument().setValue( "-p" );
+ cl.createArgument().setValue( repo.getFullUrl() );
+ cl.createArgument().setValue( "-fp" );
+ cl.createArgument().setValue( scmFileSet.getBasedir().getAbsolutePath().replace( '\\', '/' ) );
+
+ addCompressionOption( cl );
+
+ return cl;
+ }
+
+ File file = (File) scmFileSet.getFileList().get( 0 );
+
+ String newUrl = repo.getFullUrl();
+
+ if ( file.getParent() != null )
+ {
+ newUrl += "/" + file.getParent().replace( '\\', '/' );
+ }
+
+ cl.createArgument().setValue( "-p" );
+
+ cl.createArgument().setValue( newUrl );
+
+ File newWorkingDirectory = scmFileSet.getBasedir();
+ if ( file.getParent() != null )
+ {
+ newWorkingDirectory = new File( newWorkingDirectory, file.getParent() );
+ }
+
+ cl.setWorkingDirectory( newWorkingDirectory.getAbsolutePath() );
+
+ cl.createArgument().setValue( "-fp" );
+
+ cl.createArgument().setValue( newWorkingDirectory.getAbsolutePath().replace( '\\', '/' ) );
+
+ StarteamCommandLineUtils.addCompressionOption( cl );
+
+ return cl;
+ }
- private static void addCompressionOption( Commandline cl )
+ public static void addCompressionOption( Commandline cl )
{
if ( settings.isCompressionEnable() )
{
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommand.java?view=diff&rev=476085&r1=476084&r2=476085
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommand.java Fri Nov 17 01:06:22 2006
@@ -29,6 +29,7 @@
import org.codehaus.plexus.util.cli.Commandline;
import java.io.File;
+import java.util.List;
/**
* @author <a href="mailto:dantran@gmail.com">Dan T. Tran</a>
@@ -54,11 +55,16 @@
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
- File[] files = fileSet.getFiles();
+ //File basedir = fileSet.getBasedir();
+
+ List files = fileSet.getFileList();
- for ( int i = 0; i < files.length; ++i )
+ for ( int i = 0; i < files.size(); ++i )
{
- Commandline cl = createCommandLine( repository, files[i], issue );
+ File fileToBeAdded = (File) fileSet.getFileList().get( i );
+ ScmFileSet scmFile = new ScmFileSet( fileSet.getBasedir(), fileToBeAdded );
+
+ Commandline cl = createCommandLine( repository, scmFile, issue );
int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() );
@@ -71,10 +77,10 @@
return new AddScmResult( null, consumer.getAddedFiles() );
}
- static Commandline createCommandLine( StarteamScmProviderRepository repo, File toBeAddedFile, String issue )
+ static Commandline createCommandLine( StarteamScmProviderRepository repo, ScmFileSet scmFileSet, String issue )
{
- Commandline cl = StarteamCommandLineUtils.createStarteamBaseCommandLine( "add", toBeAddedFile, repo );
-
+ Commandline cl = StarteamCommandLineUtils.createStarteamBaseCommandLine( "add", scmFileSet, repo );
+
if ( issue != null && issue.length() > 0 )
{
cl.createArgument().setValue( "-cr" );
@@ -82,7 +88,8 @@
cl.createArgument().setValue( issue );
}
- cl.createArgument().setValue( toBeAddedFile.getName() );
+ File fileToBeAdded = (File) scmFileSet.getFileList().get(0);
+ cl.createArgument().setValue( fileToBeAdded.getName() );
return cl;
}
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommand.java?view=diff&rev=476085&r1=476084&r2=476085
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/main/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommand.java Fri Nov 17 01:06:22 2006
@@ -17,6 +17,7 @@
*/
import java.io.File;
+import java.util.List;
import org.apache.maven.scm.ScmException;
import org.apache.maven.scm.ScmFileSet;
@@ -65,11 +66,11 @@
CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
- File[] checkInFiles = fileSet.getFiles();
+ List checkInFiles = fileSet.getFileList();
- if ( checkInFiles.length == 0 )
+ if ( checkInFiles.size() == 0 )
{
- Commandline cl = createCommandLine( repository, fileSet.getBasedir(), message, tag, issueType, issueValue );
+ Commandline cl = createCommandLine( repository, fileSet, message, tag, issueType, issueValue );
int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() );
@@ -81,9 +82,11 @@
else
{
//update only interested files already on the local disk
- for ( int i = 0; i < checkInFiles.length; ++i )
+ for ( int i = 0; i < checkInFiles.size(); ++i )
{
- Commandline cl = createCommandLine( repository, checkInFiles[i], message, tag, issueType, issueValue );
+ ScmFileSet checkInFile = new ScmFileSet( fileSet.getBasedir(), (File) checkInFiles.get( i ) );
+
+ Commandline cl = createCommandLine( repository, checkInFile, message, tag, issueType, issueValue );
int exitCode = StarteamCommandLineUtils.executeCommandline( cl, consumer, stderr, getLogger() );
@@ -99,10 +102,11 @@
}
- public static Commandline createCommandLine( StarteamScmProviderRepository repo, File dirOrFile, String message,
+
+ public static Commandline createCommandLine( StarteamScmProviderRepository repo, ScmFileSet fileSet, String message,
String tag, String issueType, String issueValue )
{
- Commandline cl = StarteamCommandLineUtils.createStarteamBaseCommandLine( "ci", dirOrFile, repo );
+ Commandline cl = StarteamCommandLineUtils.createStarteamBaseCommandLine( "ci", fileSet, repo );
if ( message != null && message.length() > 0 )
{
@@ -127,7 +131,7 @@
}
}
- if ( dirOrFile.isDirectory() )
+ if ( fileSet.getFileList().size() == 0 )
{
cl.createArgument().setValue( "-f" );
@@ -137,7 +141,8 @@
}
else
{
- cl.createArgument().setValue( dirOrFile.getName() );
+ File checkinFile = (File) fileSet.getFileList().get( 0 ) ;
+ cl.createArgument().setValue( checkinFile.getName() );
}
return cl;
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommandTest.java?view=diff&rev=476085&r1=476084&r2=476085
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommandTest.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/add/StarteamAddCommandTest.java Fri Nov 17 01:06:22 2006
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils;
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
@@ -44,7 +45,8 @@
String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl" + " -fp " +
testFileDirAbsolutePath + " testfile";
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, "", expectedCmd );
+ ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "", expectedCmd );
}
public void testGetCommandLineWithCR()
@@ -59,7 +61,8 @@
String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl" + " -fp " +
testFileDirAbsolutePath + " -cr view_root/dummycr" + " testfile";
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, "view_root/dummycr",
+ ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "view_root/dummycr",
expectedCmd );
}
@@ -72,12 +75,13 @@
File testFileDir = testFile.getAbsoluteFile().getParentFile();
- String testFileDirAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFileDir.getAbsolutePath() );
+ String testFileDirAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFileDir.getAbsolutePath() ) + "/target";
String expectedCmd = "stcmd add -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl/target" +
" -fp " + testFileDirAbsolutePath + " testfile";
-
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, null, expectedCmd );
+
+ ScmFileSet fileSet = new ScmFileSet( testFileDir, testFile );
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, null, expectedCmd );
}
@@ -85,14 +89,14 @@
//
// ----------------------------------------------------------------------
- private void testCommandLine( String scmUrl, File fileName, String crPath, String commandLine )
+ private void testCommandLine( String scmUrl, ScmFileSet fileSet, String crPath, String commandLine )
throws Exception
{
ScmRepository repo = getScmManager().makeScmRepository( scmUrl );
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
- Commandline cl = StarteamAddCommand.createCommandLine( repository, fileName, crPath );
+ Commandline cl = StarteamAddCommand.createCommandLine( repository, fileSet, crPath );
assertEquals( commandLine, cl.toString() );
}
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommandTest.java?view=diff&rev=476085&r1=476084&r2=476085
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommandTest.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-starteam/src/test/java/org/apache/maven/scm/provider/starteam/command/checkin/StarteamCheckInCommandTest.java Fri Nov 17 01:06:22 2006
@@ -16,6 +16,7 @@
* limitations under the License.
*/
+import org.apache.maven.scm.ScmFileSet;
import org.apache.maven.scm.ScmTestCase;
import org.apache.maven.scm.provider.starteam.command.StarteamCommandLineUtils;
import org.apache.maven.scm.provider.starteam.repository.StarteamScmProviderRepository;
@@ -38,7 +39,9 @@
String workDirAbsolutePath = StarteamCommandLineUtils.toJavaPath( workDir.getAbsolutePath() );
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", workDir, "", "", "", "",
+ ScmFileSet fileSet = new ScmFileSet( workDir );
+
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "", "", "", "",
"stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl " + "-fp " +
workDirAbsolutePath + " -f NCI -is" );
}
@@ -50,7 +53,9 @@
String testFileAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFile.getAbsoluteFile().getParent() );
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, "myMessage", "myTag",
+ ScmFileSet fileSet = new ScmFileSet( testFile.getAbsoluteFile().getParentFile(), testFile );
+
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, "myMessage", "myTag",
"", "", "stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl " + "-fp " +
testFileAbsolutePath + " -r myMessage -vl myTag " + "testfile" );
@@ -59,13 +64,16 @@
public void testGetCommandLineWithFileInSubDir()
throws Exception
{
- File testFile = new File( "src/testfile" );
+ File testFile = new File( "src/testfile.txt" );
- String testFileAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFile.getAbsoluteFile().getParent() );
+ File workingDir = testFile.getAbsoluteFile().getParentFile().getParentFile();
+ ScmFileSet fileSet = new ScmFileSet( workingDir, testFile );
+
+ String testFileDirectory = StarteamCommandLineUtils.toJavaPath( testFile.getAbsoluteFile().getParent() );
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, null, "", "cr" ,"myCr",
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, null, "", "cr" ,"myCr",
"stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl/src " + "-fp " +
- testFileAbsolutePath + " -cr myCr " + "testfile" );
+ testFileDirectory + " -cr myCr " + "testfile.txt" );
}
public void testGetCommandLineWithEmptyIssueValue()
@@ -73,9 +81,12 @@
{
File testFile = new File( "src/testfile" );
+ File workingDir = testFile.getAbsoluteFile().getParentFile().getParentFile();
+ ScmFileSet fileSet = new ScmFileSet( workingDir, testFile );
+
String testFileAbsolutePath = StarteamCommandLineUtils.toJavaPath( testFile.getAbsoluteFile().getParent() );
- testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", testFile, null, "", "active", " ",
+ testCommandLine( "scm:starteam:myusername:mypassword@myhost:1234/projecturl", fileSet, null, "", "active", " ",
"stcmd ci -x -nologo -stop -p myusername:mypassword@myhost:1234/projecturl/src " + "-fp "
+ testFileAbsolutePath + " -active " + "testfile" );
}
@@ -83,7 +94,7 @@
//
// ----------------------------------------------------------------------
- private void testCommandLine( String scmUrl, File testFileOrDir, String message, String tag, String issueType,
+ private void testCommandLine( String scmUrl, ScmFileSet fileSet, String message, String tag, String issueType,
String issueValue, String commandLine )
throws Exception
{
@@ -91,7 +102,7 @@
StarteamScmProviderRepository repository = (StarteamScmProviderRepository) repo.getProviderRepository();
- Commandline cl = StarteamCheckInCommand.createCommandLine( repository, testFileOrDir, message, tag, issueType, issueValue );
+ Commandline cl = StarteamCheckInCommand.createCommandLine( repository, fileSet, message, tag, issueType, issueValue );
assertEquals( commandLine, cl.toString() );
}