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 ev...@apache.org on 2006/01/22 18:00:38 UTC
svn commit: r371334 - in
/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src:
main/java/org/apache/maven/scm/provider/clearcase/command/changelog/
main/java/org/apache/maven/scm/provider/clearcase/command/checkout/
main/mdo/ test/java...
Author: evenisse
Date: Sun Jan 22 09:00:28 2006
New Revision: 371334
URL: http://svn.apache.org/viewcvs?rev=371334&view=rev
Log:
[SCM-135] Add Clearcase LT support
Submitted by: Frederic Mura
Modified:
maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/mdo/clearcase-settings.mdo
maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommandTest.java
maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommandTest.java
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java?rev=371334&r1=371333&r2=371334&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommand.java Sun Jan 22 09:00:28 2006
@@ -22,11 +22,17 @@
import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
import org.apache.maven.scm.provider.ScmProviderRepository;
import org.apache.maven.scm.provider.clearcase.command.ClearCaseCommand;
+import org.apache.maven.scm.providers.clearcase.settings.Settings;
+import org.apache.maven.scm.providers.clearcase.settings.io.xpp3.ClearcaseXpp3Reader;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
@@ -34,12 +40,38 @@
/**
* @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
* @author <a href="mailto:trygvis@inamo.no">Trygve Laugstøl</a>
+ * @author <a href="mailto:frederic.mura@laposte.net">Frederic Mura</a>
* @version $Id$
*/
public class ClearCaseChangeLogCommand
extends AbstractChangeLogCommand
implements ClearCaseCommand
{
+ private static Settings settings;
+
+ static
+ {
+ File scmUserDir = new File( System.getProperty( "user.dir" ), ".scm" );
+ File settingsFile = new File( scmUserDir, "clearcase-settings.xml" );
+ if ( settingsFile.exists() )
+ {
+ ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
+ try
+ {
+ settings = reader.read( new FileReader( settingsFile ) );
+ }
+ catch ( FileNotFoundException e )
+ {
+ }
+ catch ( IOException e )
+ {
+ }
+ catch ( XmlPullParserException e )
+ {
+ }
+ }
+ }
+
// ----------------------------------------------------------------------
// AbstractChangeLogCommand Implementation
// ----------------------------------------------------------------------
@@ -79,6 +111,14 @@
//
// ----------------------------------------------------------------------
+ /**
+ * ClearCase LT version doesn't support the attribut -fmt and -since for command lhistory.
+ *
+ * @param workingDirectory
+ * @param branch
+ * @param startDate
+ * @return The command line
+ */
public static Commandline createCommandLine( File workingDirectory, String branch, Date startDate )
{
Commandline command = new Commandline();
@@ -93,12 +133,15 @@
format.append( "COMM:%-12.12o - %o - %c - Activity: %[activity]p\\n" );
format.append( "USER:%-8.8u\\n" );
- command.createArgument().setValue( "-fmt" );
- command.createArgument().setValue( format.toString() );
+ if ( !isClearCaseLT() )
+ {
+ command.createArgument().setValue( "-fmt" );
+ command.createArgument().setValue( format.toString() );
+ }
command.createArgument().setValue( "-recurse" );
command.createArgument().setValue( "-nco" );
- if ( startDate != null )
+ if ( startDate != null && !isClearCaseLT() )
{
SimpleDateFormat sdf = new SimpleDateFormat( "dd-MMM-yyyy", Locale.ENGLISH );
@@ -119,5 +162,35 @@
}
return command;
+ }
+
+ /**
+ * @return the value of the setting property 'clearcaseLT'
+ */
+ protected static boolean isClearCaseLT()
+ {
+ boolean result = false;
+
+ if ( settings != null )
+ {
+ result = settings.isClearcaseLT();
+ }
+ return result;
+ }
+
+ /**
+ * Frederic Mura
+ * Only use for test case
+ *
+ * @param isClearCaseLT
+ * @deprecated
+ */
+ protected static void setIsClearCaseLT( boolean isClearCaseLT )
+ {
+ if ( settings == null )
+ {
+ settings = new Settings();
+ }
+ settings.setClearcaseLT( isClearCaseLT );
}
}
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java?rev=371334&r1=371333&r2=371334&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommand.java Sun Jan 22 09:00:28 2006
@@ -32,6 +32,7 @@
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
import java.io.File;
+import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.net.InetAddress;
@@ -39,11 +40,38 @@
/**
* @author <a href="mailto:wim.deblauwe@gmail.com">Wim Deblauwe</a>
+ * @author <a href="mailto:frederic.mura@laposte.net">Frederic Mura</a>
*/
public class ClearCaseCheckOutCommand
extends AbstractCheckOutCommand
implements ClearCaseCommand
{
+
+ private static Settings settings;
+
+ static
+ {
+ File scmUserHome = new File( System.getProperty( "user.home" ), ".scm" );
+ File settingsFile = new File( scmUserHome, "clearcase-settings.xml" );
+ if ( settingsFile.exists() )
+ {
+ ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
+ try
+ {
+ settings = reader.read( new FileReader( settingsFile ) );
+ }
+ catch ( FileNotFoundException e )
+ {
+ }
+ catch ( IOException e )
+ {
+ }
+ catch ( XmlPullParserException e )
+ {
+ }
+ }
+ }
+
// ----------------------------------------------------------------------
// AbstractCheckOutCommand Implementation
// ----------------------------------------------------------------------
@@ -56,7 +84,15 @@
ClearCaseScmProviderRepository repo = (ClearCaseScmProviderRepository) repository;
File workingDirectory = fileSet.getBasedir();
getLogger().debug( "tag: " + tag );
- //Commandline cl = createCommandLine( fileSet.getBasedir(), tag );
+ if ( isClearCaseLT() )
+ {
+ getLogger().debug( "Running with CLEARCASE LT" );
+ }
+ else
+ {
+ getLogger().debug( "Running with CLEARCASE" );
+ }
+ // Commandline cl = createCommandLine( fileSet.getBasedir(), tag );
ClearCaseCheckOutConsumer consumer = new ClearCaseCheckOutConsumer( getLogger() );
@@ -87,14 +123,14 @@
{
// TODO We are building on a label
throw new UnsupportedOperationException( "Building on a label not supported yet" );
-// configSpecLocation = new File( "configspec.txt" );
-// FileWriter writer = new FileWriter( configSpecLocation );
-// writer.append( "ELEMENT * " + tag );
-// // If we did not tag the directories leading to the root directory
-// // of this module, then we need the following line also (otherwise, we will
-// // not be able to access our module in the given view
-// writer.append( "element * /main/LATEST" );
-// writer.close();
+ // configSpecLocation = new File( "configspec.txt" );
+ // FileWriter writer = new FileWriter( configSpecLocation );
+ // writer.append( "ELEMENT * " + tag );
+ // // If we did not tag the directories leading to the root directory
+ // // of this module, then we need the following line also (otherwise, we will
+ // // not be able to access our module in the given view
+ // writer.append( "element * /main/LATEST" );
+ // writer.close();
}
cl = createUpdateConfigSpecCommandLine( workingDirectory, configSpecLocation, viewName );
@@ -135,7 +171,14 @@
command.createArgument().setValue( "rmview" );
command.createArgument().setValue( "-force" );
command.createArgument().setValue( "-tag" );
- command.createArgument().setValue( getUniqueViewName( repository, workingDirectory.getAbsolutePath() ) );
+ if ( isClearCaseLT() )
+ {
+ command.createArgument().setValue( getViewStore() );
+ }
+ else
+ {
+ command.createArgument().setValue( getUniqueViewName( repository, workingDirectory.getAbsolutePath() ) );
+ }
return command;
}
@@ -155,8 +198,11 @@
command.createArgument().setValue( "-tag" );
command.createArgument().setValue( viewName );
- command.createArgument().setValue( "-vws" );
- command.createArgument().setValue( getViewStore() + viewName + ".vws" );
+ if ( !isClearCaseLT() )
+ {
+ command.createArgument().setValue( "-vws" );
+ command.createArgument().setValue( getViewStore() + viewName + ".vws" );
+ }
command.createArgument().setValue( workingDirectory.getCanonicalPath() );
@@ -201,33 +247,56 @@
{
String result = null;
- File scmUserHome = new File( System.getProperty( "user.home" ), ".scm" );
- File settingsFile = new File( scmUserHome, "clearcase-settings.xml" );
- if ( settingsFile.exists() )
+ if ( settings != null )
{
- try
- {
- ClearcaseXpp3Reader reader = new ClearcaseXpp3Reader();
- Settings settings = reader.read( new FileReader( settingsFile ) );
- result = settings.getViewstore();
- }
- catch ( IOException e )
- {
- result = null;
- }
- catch ( XmlPullParserException e )
+ result = settings.getViewstore();
+ }
+ if ( result == null )
+ {
+ result = "\\\\" + getHostName() + "\\viewstore\\";
+ }
+ else
+ {
+ // If ClearCase LT are use, the View store is identify by the
+ // username.
+ if ( isClearCaseLT() )
{
- result = null;
+ result = result + getUserName() + "\\";
}
}
+ return result;
+ }
- if ( result == null )
+ /**
+ * @return the value of the setting property 'clearcaseLT'
+ */
+ protected static boolean isClearCaseLT()
+ {
+ boolean result = false;
+
+ if ( settings != null )
{
- result = "\\\\" + getHostName() + "\\viewstore\\";
+ result = settings.isClearcaseLT();
}
return result;
}
+ /**
+ * Frederic Mura
+ * + * Only use for test case
+ * + * @param isClearCaseLT
+ * + * @deprecated
+ * +
+ */
+ protected static void setIsClearCaseLT( boolean isClearCaseLT )
+ {
+ if ( settings == null )
+ {
+ settings = new Settings();
+ }
+ settings.setClearcaseLT( isClearCaseLT );
+ }
+
private static String getHostName()
{
String hostname;
@@ -243,4 +312,10 @@
return hostname;
}
+ private static String getUserName()
+ {
+ String username;
+ username = System.getProperty( "user.name" );
+ return username;
+ }
}
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/mdo/clearcase-settings.mdo
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/mdo/clearcase-settings.mdo?rev=371334&r1=371333&r2=371334&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/mdo/clearcase-settings.mdo (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/main/mdo/clearcase-settings.mdo Sun Jan 22 09:00:28 2006
@@ -20,6 +20,12 @@
<type>String</type>
<description>Clearcase viewstore path</description>
</field>
+ <field>
+ <name>clearcaseLT</name>
+ <version>1.0.0+</version>
+ <type>boolean</type>
+ <description>Are you using ClearCase LT version ?</description>
+ </field>
</fields>
</class>
</classes>
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommandTest.java?rev=371334&r1=371333&r2=371334&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommandTest.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/changelog/ClearCaseChangeLogCommandTest.java Sun Jan 22 09:00:28 2006
@@ -41,6 +41,8 @@
testCommandLine( tag, startDate, endDate,
"cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\n\" -recurse -nco" );
+
+ testClearCaseLTCommandLine( tag, startDate, endDate, "cleartool lshistory -recurse -nco" );
}
public void testGetCommandLineWithTag()
@@ -54,6 +56,8 @@
testCommandLine( tag, startDate, endDate,
"cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\n\" -recurse -nco -branch myBranch" );
+
+ testClearCaseLTCommandLine( tag, startDate, endDate, "cleartool lshistory -recurse -nco -branch myBranch" );
}
public void testGetCommandLineWithStartDate()
@@ -67,6 +71,8 @@
testCommandLine( tag, startDate, endDate,
"cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\n\" -recurse -nco -since 10-Sep-2003" );
+
+ testClearCaseLTCommandLine( tag, startDate, endDate, "cleartool lshistory -recurse -nco" );
}
public void testGetCommandLineWithTagAndStartDate()
@@ -80,6 +86,8 @@
testCommandLine( tag, startDate, endDate,
"cleartool lshistory -fmt \"NAME:%En\\nDATE:%Nd\\nCOMM:%-12.12o - %o - %c - Activity: %[activity]p\\nUSER:%-8.8u\\n\" -recurse -nco -since 10-Sep-2003 -branch myBranch" );
+
+ testClearCaseLTCommandLine( tag, startDate, endDate, "cleartool lshistory -recurse -nco -branch myBranch" );
}
// ----------------------------------------------------------------------
@@ -90,6 +98,21 @@
throws Exception
{
File workingDirectory = getTestFile( "target/clearcare-changelog-command-test" );
+
+ ClearCaseChangeLogCommand.setIsClearCaseLT( false );
+
+ Commandline cl = ClearCaseChangeLogCommand.createCommandLine( workingDirectory, tag, startDate );
+
+ assertEquals( commandLine, cl.toString() );
+ }
+
+ private void testClearCaseLTCommandLine( String tag, Date startDate, Date endDate, String commandLine )
+ throws Exception
+ {
+
+ File workingDirectory = getTestFile( "target/clearcare-changelog-command-test" );
+
+ ClearCaseChangeLogCommand.setIsClearCaseLT( true );
Commandline cl = ClearCaseChangeLogCommand.createCommandLine( workingDirectory, tag, startDate );
Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommandTest.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommandTest.java?rev=371334&r1=371333&r2=371334&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommandTest.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-clearcase/src/test/java/org/apache/maven/scm/provider/clearcase/command/checkout/ClearCaseCheckOutCommandTest.java Sun Jan 22 09:00:28 2006
@@ -24,6 +24,7 @@
/**
* @author <a href="mailto:wim.deblauwe@gmail.com">Wim Deblauwe</a>
+ * @author <a href="mailto:frederic.mura@laposte.net">Frederic Mura</a>
*/
public class ClearCaseCheckOutCommandTest
extends ScmTestCase
@@ -31,18 +32,29 @@
public void testCreateViewCommandLine()
throws IOException
{
+ ClearCaseCheckOutCommand.setIsClearCaseLT( false );
Commandline commandLine =
ClearCaseCheckOutCommand.createCreateViewCommandLine( getWorkingDirectory(), "testView" );
assertEquals( "cleartool mkview -snapshot -tag testView -vws " + ClearCaseCheckOutCommand.getViewStore() +
"testView.vws " + getWorkingDirectory(), commandLine.toString() );
+
+ ClearCaseCheckOutCommand.setIsClearCaseLT( true );
+ commandLine = ClearCaseCheckOutCommand.createCreateViewCommandLine( getWorkingDirectory(), "testView" );
+ assertEquals( "cleartool mkview -snapshot -tag testView " + getWorkingDirectory(), commandLine.toString() );
}
public void testUpdateConfigSpec()
{
+ ClearCaseCheckOutCommand.setIsClearCaseLT( false );
File configSpecLocation = new File( "\\\\myserver\\configspecs\\testconfigspec.txt" );
Commandline commandLine = ClearCaseCheckOutCommand.createUpdateConfigSpecCommandLine( getWorkingDirectory(),
configSpecLocation,
"testView" );
+ assertEquals( "cleartool setcs -tag testView " + configSpecLocation, commandLine.toString() );
+
+ ClearCaseCheckOutCommand.setIsClearCaseLT( true );
+ commandLine = ClearCaseCheckOutCommand.createUpdateConfigSpecCommandLine( getWorkingDirectory(),
+ configSpecLocation, "testView" );
assertEquals( "cleartool setcs -tag testView " + configSpecLocation, commandLine.toString() );
}
}