maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jvan...@apache.org
Subject svn commit: r653572 - in /maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/maven/ src/main/java/org/apache/maven/scm/ src/main/java/o...
Date Mon, 05 May 2008 19:49:58 GMT
Author: jvanzyl
Date: Mon May  5 12:49:57 2008
New Revision: 653572

URL: http://svn.apache.org/viewvc?rev=653572&view=rev
Log:
o adding an Accurev provider donated by the Accurev folks
Submitted by: Ivan Luzyanin
CCLA is now on file


Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java   (with props)
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/
    maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java   (with props)

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml Mon May  5 12:49:57 2008
@@ -0,0 +1,132 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <artifactId>maven-scm-providers</artifactId>
+    <groupId>org.apache.maven.scm</groupId>
+    <version>1.1-SNAPSHOT</version>
+  </parent>
+  <artifactId>maven-scm-provider-accurev</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>AccuRev Maven SCM Provider</name>
+  <url>http://maven.apache.org</url>
+  <properties>
+    <test.accurev.username>test</test.accurev.username>
+    <test.accurev.password></test.accurev.password>
+    <test.accurev.host>localhost</test.accurev.host>
+    <test.accurev.port>5050</test.accurev.port>
+    <test.accurev.depot>TestDepot</test.accurev.depot>
+    <test.accurev.stream>TestStream</test.accurev.stream>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+      <version>3.8.1</version>
+      <scope>test</scope>
+      <optional>true</optional>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-api</artifactId>
+      <version>1.0</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.maven.scm</groupId>
+      <artifactId>maven-scm-test</artifactId>
+      <version>1.0</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-cli</artifactId>
+      <version>1.4</version>
+    </dependency>
+    <dependency>
+      <groupId>org.codehaus.plexus</groupId>
+      <artifactId>plexus-utils</artifactId>
+      <version>1.4.7</version>
+    </dependency>
+    <dependency>
+      <groupId>commons-lang</groupId>
+      <artifactId>commons-lang</artifactId>
+      <version>2.4</version>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.plexus</groupId>
+        <artifactId>plexus-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>descriptor</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <excludes>
+            <exclude>**/*TckTest*.java</exclude>
+          </excludes>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+  <profiles>
+    <profile>
+      <id>TckTests</id>
+      <build>
+        <plugins>
+          <plugin>
+            <groupId>org.apache.maven.plugins</groupId>
+            <artifactId>maven-surefire-plugin</artifactId>
+            <configuration>
+              <excludes>
+                <exclude>none</exclude>
+                <!--Not yet finished-->
+                <!--<exclude>**/checkout/AccuRevScmTckTestCase.java</exclude>-->
+              </excludes>
+              <includes>
+                <include>**/*TckTest*.java</include>
+              </includes>
+              <systemProperties>
+                <property>
+                  <name>test.accurev.username</name>
+                  <value>${test.accurev.username}</value>
+                </property>
+                <property>
+                  <name>test.accurev.password</name>
+                  <value>${test.accurev.password}</value>
+                </property>
+                <property>
+                  <name>test.accurev.host</name>
+                  <value>${test.accurev.host}</value>
+                </property>
+                <property>
+                  <name>test.accurev.port</name>
+                  <value>${test.accurev.port}</value>
+                </property>
+                <property>
+                  <name>test.accurev.stream</name>
+                  <value>${test.accurev.stream}</value>
+                </property>
+                <property>
+                  <name>test.accurev.depot</name>
+                  <value>${test.accurev.depot}</value>
+                </property>
+              </systemProperties>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+    </profile>
+  </profiles>
+</project>

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/pom.xml
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java Mon May  5 12:49:57 2008
@@ -0,0 +1,321 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.login.LoginScmResult;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.provider.AbstractScmProvider;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.commands.add.AccuRevAddCommand;
+import org.apache.maven.scm.provider.accurev.commands.login.AccuRevLoginCommand;
+import org.apache.maven.scm.provider.accurev.commands.checkout.BaseAccuRevCheckOutCommand;
+import org.apache.maven.scm.provider.accurev.commands.checkout.AccuRevCheckOutWorkspaceCommand;
+import org.apache.maven.scm.provider.accurev.commands.checkout.AccuRevCheckOutUsingPopCommand;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Implementation of Accurev integration with Maven SCM
+ *
+ * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="accurev"
+ */
+public class AccuRevScmProvider extends AbstractScmProvider {
+	private final String accurevExecutable;
+
+	private AccuRevAddCommand addCommand;
+	private AccuRevLoginCommand loginCommand;
+	private BaseAccuRevCheckOutCommand[] checkOutCommands;
+	
+	private static final String CHECKOUT_METHOD_PARAM_NAME = "checkoutMethod";
+	private static final String CHECKOUT_METHOD_SYS_PROPERTY = "accurev.checkout.method";
+
+	public AccuRevScmProvider() {
+		boolean isWindows = System.getProperty("os.name").toLowerCase()
+				.indexOf("windows") != -1;
+		this.accurevExecutable = resolveAccurevExecutable(isWindows);
+	}
+
+	/**
+	 * @see AbstractScmProvider#getScmType()
+	 */
+	public String getScmType() {
+		return "accurev";
+	}
+
+	protected String getAccurevExecutable() {
+		return this.accurevExecutable;
+	}
+
+	/**
+	 * @see AbstractScmProvider#makeProviderScmRepository(String, char)
+	 */
+	public ScmProviderRepository makeProviderScmRepository(String scmSpecificUrl, char delimiter)
+			throws ScmRepositoryException {
+		AccuRevScmProviderRepository rep = new AccuRevScmProviderRepository();
+
+		int atSignIdx = scmSpecificUrl.indexOf('@');
+		if (atSignIdx != -1) {
+			//User, password, host and port are specified
+			String beforeAt = scmSpecificUrl.substring(0, atSignIdx);
+			String afterAt = scmSpecificUrl.substring(atSignIdx + 1);
+
+			LinkedList parts = splitString(beforeAt, delimiter, true);
+			if (parts.isEmpty()) {
+				throw new ScmRepositoryException("Username is required");
+			}
+			rep.setUser((String) parts.removeFirst());
+			if (!parts.isEmpty()) {
+				rep.setPassword((String) parts.removeFirst());
+			}
+			int hostEndIdx = afterAt.indexOf(delimiter);
+			if (hostEndIdx == -1) {
+				throw new ScmRepositoryException("Invalid SCM URL");
+			}
+			String host = afterAt.substring(0, hostEndIdx);
+			rep.setHost(host);
+
+			int idx = afterAt.indexOf(delimiter, hostEndIdx + 1);
+			if (idx == -1) {
+				throw new ScmRepositoryException("Invalid SCM URL");
+			}
+			String eitherPortOrNextToken = afterAt.substring(hostEndIdx + 1, idx);
+			try {
+				rep.setPort(Integer.parseInt(eitherPortOrNextToken));
+			} catch (NumberFormatException e) {
+				idx = hostEndIdx;
+			}
+			scmSpecificUrl = afterAt.substring(idx + 1);
+		}
+		int paramStartIdx = scmSpecificUrl.indexOf('?');
+		if (paramStartIdx != -1) {
+			String params = scmSpecificUrl.substring(paramStartIdx + 1);
+			scmSpecificUrl = scmSpecificUrl.substring(0, paramStartIdx);
+			processParams(params, rep);
+
+		}
+		processDepotStreamAndWorkspace(scmSpecificUrl, delimiter, rep);
+
+		String checkoutMethodParam = (String) rep.getParams().get(CHECKOUT_METHOD_PARAM_NAME);
+		if (StringUtils.isNotBlank(checkoutMethodParam)) {
+			//Set checkout method from the SCM URL parameter
+			rep.setCheckoutMethod(checkoutMethodParam.trim());
+		}
+		if (rep.getCheckoutMethod() == null) {
+			//Get from system property or use "pop" by default
+			rep.setCheckoutMethod(System.getProperty(CHECKOUT_METHOD_SYS_PROPERTY, "pop"));
+		}
+		if (getLogger().isDebugEnabled()) {
+			getLogger().debug("Repository created: " + rep.toString());
+		}
+		return rep;
+	}
+
+	private void processParams(String params, AccuRevScmProviderRepository rep) {
+		//Parse params
+		String[] paramKeyValuePairs = StringUtils.split(params, '&');
+		for (int i = 0; i < paramKeyValuePairs.length; i++) {
+			String keyValuePair = paramKeyValuePairs[i];
+			int delimiterIdx = keyValuePair.indexOf('=');
+			if (delimiterIdx == -1) {
+				getLogger().warn("Invalid parameter \"" + keyValuePair + "\" at position " + i);
+				continue;
+			}
+			String key = keyValuePair.substring(0, delimiterIdx);
+			String value = keyValuePair.substring(delimiterIdx + 1);
+			//Store parameter
+			rep.getParams().put(key, value);
+		}
+	}
+
+
+	/**
+	 * @see AbstractScmProvider#login(ScmProviderRepository, ScmFileSet, CommandParameters)
+	 */
+	protected LoginScmResult login(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters)
+			throws ScmException {
+		if (null == this.loginCommand) { //Lazy command instantiation
+			this.loginCommand = new AccuRevLoginCommand(this.accurevExecutable);
+			this.loginCommand.setLogger(getLogger());
+		}
+		return (LoginScmResult) this.loginCommand.execute(repository, fileSet, parameters);
+	}
+
+	/**
+	 * @see AbstractScmProvider#checkout(ScmProviderRepository, ScmFileSet, CommandParameters)
+	 */
+	protected CheckOutScmResult checkout(ScmProviderRepository repository, ScmFileSet fileSet,
+										 CommandParameters parameters) throws ScmException {
+
+		AccuRevScmProviderRepository rep = (AccuRevScmProviderRepository) repository;
+		getLogger().debug("accurev.checkout.method = " + rep.getCheckoutMethod());
+		BaseAccuRevCheckOutCommand[] checkOutCmds = getCheckoutCommands();
+		//Find check-out command that supports specified method
+		for (int i = 0; i < checkOutCmds.length; i++) {
+			BaseAccuRevCheckOutCommand checkOutCommand = checkOutCmds[i];
+			if (checkOutCommand.getMethodName().equalsIgnoreCase(rep.getCheckoutMethod())) {
+				return (CheckOutScmResult) checkOutCommand.execute(repository, fileSet, parameters);
+			}
+		}
+		throw new ScmRepositoryException("accurev.checkout.method=" + rep.getCheckoutMethod() + " is not supported");
+	}
+
+	protected AddScmResult add(ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters) throws ScmException {
+		//Lazy command creation
+		if (null == addCommand) {
+			addCommand = new AccuRevAddCommand(this.accurevExecutable);
+			addCommand.setLogger(getLogger());
+		}
+		return (AddScmResult) addCommand.execute(repository, fileSet, parameters);
+	}
+
+	private BaseAccuRevCheckOutCommand[] getCheckoutCommands() {
+		if (null == this.checkOutCommands) { //Lazy command instantiation
+			this.checkOutCommands = buildCheckOutCommands();
+		}
+		return this.checkOutCommands;
+	}
+
+	protected BaseAccuRevCheckOutCommand[] buildCheckOutCommands() {
+		BaseAccuRevCheckOutCommand[] commands = {
+				new AccuRevCheckOutUsingPopCommand(this.accurevExecutable),
+				new AccuRevCheckOutWorkspaceCommand(this.accurevExecutable)
+		};
+		for (int i = 0; i < commands.length; i++) {
+			BaseAccuRevCheckOutCommand command = commands[i];
+			command.setLogger(getLogger());
+		}
+		return commands;
+	}
+
+	/**
+	 * Append host (-H) parameter to the params list if the repository has this information
+	 *
+	 * @param repository AccuRevScmProviderRepository
+	 * @param params	 Parameters
+	 */
+	public static void appendHostToParamsIfNeeded(AccuRevScmProviderRepository repository, List params) {
+		if (repository.getHost() != null) {
+			params.add("-H");
+			params.add(repository.getHost() + ":" + String.valueOf(repository.getPort()));
+		}
+	}
+
+	/**
+	 * Resolves accurev executable
+	 *
+	 * @param windows Is OS is windows
+	 * @return AccuRev executable
+	 * @throws IllegalStateException If the executable cannot be resolved
+	 */
+	private static String resolveAccurevExecutable(boolean windows) {
+		String executable = "accurev";
+		//Append ".exe" suffix if the OS is Windows
+		if (windows) {
+			executable += ".exe";
+		}
+		//Grab exeucutable from system variable if specified
+		String accurevExecutable = System.getProperty("accurevExecutable");
+		if (accurevExecutable != null) {
+			executable = accurevExecutable;
+		}
+		return executable;
+	}
+
+	/**
+	 * Split the given string with separator char
+	 *
+	 * @param string		String to be splitted
+	 * @param separatorChar separator char
+	 * @param blankIsNull   If the parameter is true then if the substring is blank then it will be considered as null
+	 * @return Linked list which contains strings
+	 */
+	private static LinkedList splitString(String string, char separatorChar, boolean blankIsNull) {
+		LinkedList parts = new LinkedList();
+		int fromIdx = 0;
+		for (int idx; (idx = string.indexOf(separatorChar, fromIdx)) != -1; fromIdx = ++idx) {
+			parts.add(getSubstring(string, fromIdx, idx, blankIsNull));
+		}
+		//Add last token
+		parts.add(getSubstring(string, fromIdx, string.length(), blankIsNull));
+		return parts;
+	}
+
+	/**
+	 * Get substring from string
+	 *
+	 * @param string	  source string
+	 * @param fromIdx	 from index
+	 * @param toIdx	   to index
+	 * @param blankIsNull If the parameter is true then if the substring is blank then null will be returned
+	 * @return Substring or the null if the substring is empty and the blankIsNull parameter is true
+	 * @see String#substring(int,int)
+	 * @see StringUtils#isBlank(String)
+	 */
+	private static String getSubstring(String string, int fromIdx, int toIdx, boolean blankIsNull) {
+		String substring = string.substring(fromIdx, toIdx);
+		return (blankIsNull && StringUtils.isBlank(substring)) ? null : substring;
+	}
+
+	/**
+	 * Process depot, stream and workspace from the given string
+	 *
+	 * @param depotStreamWorkspace String that contains depot, stream and workspace name information
+	 * @param delimeter			Delimeter char
+	 * @param repRef			   AccuRevScmProviderRepository reference where the information will be stored
+	 * @throws ScmRepositoryException If there was a validation error while processing the URL
+	 */
+	private void processDepotStreamAndWorkspace(final String depotStreamWorkspace,
+												final char delimeter,
+												final AccuRevScmProviderRepository repRef)
+			throws ScmRepositoryException {
+		LinkedList parts = splitString(depotStreamWorkspace, delimeter, true);
+		if (parts.size() < 2) {
+			throw new ScmRepositoryException("Invalid scmUrl. Depot and stream names are required");
+		}
+		//Set depot
+		String depot = (String) parts.removeFirst();
+		if (null == depot) throw new ScmRepositoryException("Depot name is missing");
+		repRef.setDepot(depot);
+
+		//Set stream
+		String streamName = (String) parts.removeFirst();
+		if (null == streamName) throw new ScmRepositoryException("Stream name is missing");
+		repRef.setStreamName(streamName);
+
+		//Set workspace if specified
+		if (!parts.isEmpty()) {
+			repRef.setWorkspaceName((String) parts.removeFirst());
+		}
+
+		if (!parts.isEmpty()) {
+			throw new ScmRepositoryException("Invalid workspace assosiation path: " +
+					depotStreamWorkspace + ". Should be in format \"<depot>" + delimeter +
+					"<stream>" + delimeter + "<workspace>\"");
+		}
+		if (repRef.getWorkspaceName() == null) {
+			//TODO Use 'accurev show wspaces' to resolve the workspace name by the workspace path
+		}
+	}
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProvider.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java Mon May  5 12:49:57 2008
@@ -0,0 +1,109 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.commons.lang.builder.ToStringBuilder;
+
+import java.util.Map;
+import java.util.HashMap;
+
+public class AccuRevScmProviderRepository extends ScmProviderRepository {
+	public static final int DEFAULT_PORT = 5050;
+
+	private String depot;
+
+	private String streamName;
+
+	private String workspaceName;
+
+	private String host;
+
+	private int port = DEFAULT_PORT;
+
+	private String checkoutMethod;
+
+	private Map params = new HashMap();
+
+	public String getDepot() {
+		return depot;
+	}
+
+	public void setDepot(String depot) {
+		this.depot = depot;
+	}
+
+	public String getStreamName() {
+		return streamName;
+	}
+
+	public void setStreamName(String streamName) {
+		this.streamName = streamName;
+	}
+
+	public String getWorkspaceName() {
+		return workspaceName;
+	}
+
+	public void setWorkspaceName(String workspaceName) {
+		this.workspaceName = workspaceName;
+	}
+
+	public String getHost() {
+		return host;
+	}
+
+	public void setHost(String host) {
+		this.host = host;
+	}
+
+	public int getPort() {
+		return port;
+	}
+
+	public void setPort(int port) {
+		this.port = port;
+	}
+
+	public String getCheckoutMethod() {
+		return checkoutMethod;
+	}
+
+	public void setCheckoutMethod(String checkoutMethod) {
+		this.checkoutMethod = checkoutMethod;
+	}
+
+	public Map getParams() {
+		return params;
+	}
+
+	public void setParams(Map params) {
+		this.params = params;
+	}
+
+	public String toString() {
+		return new ToStringBuilder(this)
+				.append("host", this.host)
+				.append("port", this.port)
+				.append("depot", this.depot)
+				.append("streamName", this.streamName)
+				.append("workspaceName", this.workspaceName)
+				.append("checkoutMethod", this.checkoutMethod)
+				.append("params", this.params)
+				.toString();
+	}
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/AccuRevScmProviderRepository.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java Mon May  5 12:49:57 2008
@@ -0,0 +1,86 @@
+package org.apache.maven.scm.provider.accurev.commands.add;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.command.add.AbstractAddCommand;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.ScmResult;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.CommandLineException;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.io.File;
+
+public class AccuRevAddCommand extends AbstractAddCommand
+{
+    private final String _accurevExecutable;
+
+    public AccuRevAddCommand( String accurevExecutable )
+    {
+        _accurevExecutable = accurevExecutable;
+    }
+
+    protected ScmResult executeAddCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                           String message, boolean binary ) throws ScmException
+    {
+        Commandline cl = new Commandline();
+        cl.setExecutable( _accurevExecutable );
+        cl.setWorkingDirectory( fileSet.getBasedir().getPath() );
+        cl.addArguments( new String[]{"add"} );
+        ArrayList params = new ArrayList();
+        AccuRevScmProvider.appendHostToParamsIfNeeded( (AccuRevScmProviderRepository) repository, params );
+        cl.addArguments( (String[]) params.toArray( new String[params.size()] ) );
+
+        cl.addArguments( makeFileArgs( fileSet.getFileList() ) );
+
+        final List filesAdded = new ArrayList();
+        final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+        try
+        {
+            if ( 0 != CommandLineUtils.executeCommandLine( cl, new AddCommandStreamConsumer( stdout, filesAdded ),
+                stdout ) )
+            {
+                return new AddScmResult( cl.toString(), null, stdout.getOutput(), false );
+            }
+        }
+        catch ( CommandLineException e )
+        {
+            throw new ScmRepositoryException( "Cannot exeucute add command", e );
+        }
+        return new AddScmResult( cl.toString(), filesAdded );
+    }
+
+    private String[] makeFileArgs( List/*File*/ fileList )
+    {
+        ArrayList res = new ArrayList();
+        for ( int i = 0; i < fileList.size(); i++ )
+        {
+            File file = (File) fileList.get( i );
+            res.add( file.getAbsolutePath() );
+        }
+        return (String[]) res.toArray( new String[res.size()] );
+    }
+
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AccuRevAddCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java Mon May  5 12:49:57 2008
@@ -0,0 +1,54 @@
+package org.apache.maven.scm.provider.accurev.commands.add;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/** Stream consumer for collecting files that were added with the add command */
+class AddCommandStreamConsumer implements StreamConsumer
+{
+    private final static Pattern pattern = Pattern.compile( "Added and kept element\\s*(.*)" );
+
+    private final StreamConsumer stdout;
+    private final List filesAdded;
+
+    /**
+     * @param stdout     The delegating stream consumer
+     * @param filesAdded A collection in which added elements should be stored
+     */
+    public AddCommandStreamConsumer( StreamConsumer stdout, List filesAdded )
+    {
+        this.stdout = stdout;
+        this.filesAdded = filesAdded;
+    }
+
+    public void consumeLine( String line )
+    {
+        stdout.consumeLine( line );
+
+        Matcher m = pattern.matcher( line );
+        if ( m.matches() )
+        {
+            String element = m.group( 1 );
+            this.filesAdded.add( element );
+        }
+	}
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/add/AddCommandStreamConsumer.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java Mon May  5 12:49:57 2008
@@ -0,0 +1,142 @@
+package org.apache.maven.scm.provider.accurev.commands.checkout;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.apache.maven.scm.provider.accurev.commands.checkout.BaseAccuRevCheckOutCommand;
+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.cli.StreamConsumer;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.regex.Pattern;
+import java.util.regex.Matcher;
+
+public class AccuRevCheckOutUsingPopCommand extends AbstractCheckOutCommand implements BaseAccuRevCheckOutCommand
+{
+    private String accuRevExecutable;
+
+    public AccuRevCheckOutUsingPopCommand( String executable )
+    {
+        this.accuRevExecutable = executable;
+    }
+
+    public String getMethodName()
+    {
+        return "pop";
+    }
+
+    protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                                        ScmVersion version ) throws ScmException
+    {
+        try
+        {
+            AccuRevScmProviderRepository accurevRepository = (AccuRevScmProviderRepository) repository;
+
+            final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+            //Update the workspace
+            Commandline popCommandline = createPopStreamCommand( accurevRepository, fileSet, version );
+
+            //Create checkout folder if missing
+            if ( !fileSet.getBasedir().exists() )
+            {
+                fileSet.getBasedir().mkdirs();
+            }
+
+            final ArrayList checkedFiles = new ArrayList();
+            int exitCode = CommandLineUtils.executeCommandLine( popCommandline, new StreamConsumer()
+            {
+                Pattern pattern = Pattern.compile( "Populating element (.*)" );
+
+                public void consumeLine( String line )
+                {
+                    stdout.consumeLine( line );
+                    //Collect list of files poped from the stream
+                    Matcher m = pattern.matcher( line );
+                    if ( m.matches() )
+                    {
+                        checkedFiles.add( m.group( 1 ) );
+                    }
+                }
+            }, stdout );
+
+            //Check if the update command successeed
+            if ( exitCode != 0 )
+            {
+                return new CheckOutScmResult( popCommandline.toString(),
+                    "The AccuRev command failed", stdout.getOutput(), false );
+            }
+            if ( getLogger().isInfoEnabled() )
+            {
+                getLogger().info( "Checked out stream \"" + accurevRepository.getStreamName() +
+                    "\" contents to folder " + fileSet.getBasedir() );
+                //TODO notify user that the checked files are not in workspace and no changes can be propagated to SCM
+            }
+            return new CheckOutScmResult( popCommandline.toString(), checkedFiles );
+        }
+        catch ( CommandLineException e )
+        {
+            throw new ScmException( "internal error" );
+        }
+    }
+
+    protected Commandline createPopStreamCommand( AccuRevScmProviderRepository repository,
+                                                  ScmFileSet fileSet, ScmVersion version )
+    {
+        //TODO Implement support of fileSet, version if applyable
+        Commandline commandline = new Commandline();
+        commandline.setExecutable( this.accuRevExecutable );
+        ArrayList params = new ArrayList();
+        //Append command name
+        params.add( "pop" );
+        //Append host if needed
+        AccuRevScmProvider.appendHostToParamsIfNeeded( repository, params );
+        //Set command parameters
+        commandline.addArguments( (String[]) params.toArray( new String[params.size()] ) );
+        //Append command parameters
+        commandline.addArguments( new String[]{
+            "-v", repository.getStreamName(), //name of the stream
+            "-L", fileSet.getBasedir().getAbsolutePath(), //into folder
+            "-R" //get files recursively
+        } );
+        List fileSetArguments = new ArrayList();
+        String filelistParam = (String) repository.getParams().get( "include" );
+        if ( null == filelistParam )
+        {
+            //Add all by default
+            fileSetArguments.add( "." );
+        }
+        else
+        {
+            String[] elements = StringUtils.split( filelistParam, ',' );
+            fileSetArguments.addAll( Arrays.asList( elements ) );
+        }
+        commandline.addArguments( (String[]) fileSetArguments.toArray( new String[fileSetArguments.size()] ) );
+        return commandline;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutUsingPopCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java Mon May  5 12:49:57 2008
@@ -0,0 +1,150 @@
+package org.apache.maven.scm.provider.accurev.commands.checkout;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.apache.maven.scm.util.AbstractConsumer;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AccuRevCheckOutWorkspaceCommand extends AbstractCheckOutCommand implements BaseAccuRevCheckOutCommand
+{
+    private String accuRevExecutable;
+
+    public AccuRevCheckOutWorkspaceCommand( String executable )
+    {
+        this.accuRevExecutable = executable;
+    }
+
+    public String getMethodName()
+    {
+        return "mkws";
+    }
+
+    protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                                        ScmVersion version ) throws ScmException
+    {
+        try
+        {
+            final CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+
+            //Create checkout folder if missing
+            if ( !fileSet.getBasedir().exists() )
+            {
+                fileSet.getBasedir().mkdirs();
+            }
+
+            //Make new workspace
+            AccuRevScmProviderRepository accurevRepository = (AccuRevScmProviderRepository) repository;
+            Commandline makeCommandline = createMakeWorkspaceCommandLine( accurevRepository, fileSet, version );
+
+            int exitCode = CommandLineUtils.executeCommandLine( makeCommandline, stdout, stdout );
+
+            if ( exitCode != 0 )
+            {
+                return new CheckOutScmResult( makeCommandline.toString(),
+                    "The AccuRev command failed. Cannot create workspace: " +
+                        stdout.getOutput(), stdout.getOutput(), false );
+            }
+            //Update the workspace
+            Commandline updateCommandline = createUpdateWorkspaceCommand( accurevRepository, fileSet, version );
+
+            final ArrayList checkedFiles = new ArrayList();
+            exitCode = CommandLineUtils.executeCommandLine( updateCommandline, new AbstractConsumer( getLogger() )
+            {
+                private Pattern pattern = Pattern.compile( "Updating element (.*)" );
+
+                public void consumeLine( String line )
+                {
+                    //Consume line to stdout consumer
+                    stdout.consumeLine( line );
+                    //Check if the line is matching pattern
+                    Matcher m = pattern.matcher( line );
+                    if ( m.matches() )
+                    {
+                        checkedFiles.add( m.group( 1 ) );
+                    }
+                }
+            }, stdout );
+            //Check if the update command successeed
+            if ( exitCode != 0 )
+            {
+                return new CheckOutScmResult( updateCommandline.toString(),
+                    "The AccuRev command failed. Cannot update workspace", stdout.getOutput(), false );
+            }
+            return new CheckOutScmResult( makeCommandline.toString() + " & " + updateCommandline.toString(),
+                checkedFiles );
+        }
+        catch ( CommandLineException e )
+        {
+            throw new ScmException( "internal error" );
+        }
+    }
+
+    protected Commandline createUpdateWorkspaceCommand( AccuRevScmProviderRepository repository,
+                                                        ScmFileSet fileSet, ScmVersion version )
+    {
+        //TODO Implement support of fileSet, version if applyable
+        Commandline commandline = new Commandline();
+        commandline.setExecutable( this.accuRevExecutable );
+        ArrayList params = new ArrayList();
+        //Append command name
+        params.add( "update" );
+        //Append host if needed
+        AccuRevScmProvider.appendHostToParamsIfNeeded( repository, params );
+        //Append command parameters
+        params.add( "-r" );
+        params.add( repository.getWorkspaceName() );
+        //Set command parameters
+        commandline.addArguments( (String[]) params.toArray( new String[params.size()] ) );
+        return commandline;
+    }
+
+    protected Commandline createMakeWorkspaceCommandLine( AccuRevScmProviderRepository repository,
+                                                          ScmFileSet fileSet, ScmVersion version )
+    {
+        //TODO Implement support of fileSet, version if applyable
+        Commandline cmd = new Commandline();
+        cmd.setExecutable( this.accuRevExecutable );
+        //Append command name
+        cmd.addArguments( new String[]{"mkws"} );
+        //Append host param if needed
+        List params = new ArrayList();
+        AccuRevScmProvider.appendHostToParamsIfNeeded( repository, params );
+        cmd.addArguments( (String[]) params.toArray( new String[params.size()] ) );
+        //Append command arguments
+        cmd.addArguments( new String[]{
+            "-w", repository.getWorkspaceName(),
+            "-b", repository.getStreamName(),
+            "-l", fileSet.getBasedir().getAbsolutePath()
+        } );
+        return cmd;
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevCheckOutWorkspaceCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java Mon May  5 12:49:57 2008
@@ -0,0 +1,24 @@
+package org.apache.maven.scm.provider.accurev.commands.checkout;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.command.Command;
+
+public interface BaseAccuRevCheckOutCommand extends Command
+{
+    String getMethodName();
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/checkout/BaseAccuRevCheckOutCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java Mon May  5 12:49:57 2008
@@ -0,0 +1,100 @@
+package org.apache.maven.scm.provider.accurev.commands.login;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.maven.scm.command.login.AbstractLoginCommand;
+import org.apache.maven.scm.command.login.LoginScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.commons.lang.StringUtils;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.codehaus.plexus.util.cli.CommandLineException;
+
+import java.util.ArrayList;
+
+public class AccuRevLoginCommand extends AbstractLoginCommand
+{
+    private String executable;
+
+    public AccuRevLoginCommand( String executable )
+    {
+        this.executable = executable;
+    }
+
+    public LoginScmResult executeLoginCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+                                               CommandParameters parameters ) throws ScmException
+    {
+        CommandLineUtils.StringStreamConsumer stderr = new CommandLineUtils.StringStreamConsumer();
+
+        String username = repository.getUser();
+        if ( null == username )
+        {
+            //No need to login
+            return new LoginScmResult( null, null, null, true );
+        }
+        //Do the login
+        Commandline cl = createLoginCommandLine( (AccuRevScmProviderRepository) repository );
+        try
+        {
+            int exitCode = CommandLineUtils.executeCommandLine( cl, stderr, stderr );
+            //Create result based on exit code
+            LoginScmResult scmResult;
+            if ( exitCode != 0 )
+            {
+                scmResult = new LoginScmResult( cl.toString(), null, stderr.getOutput(), false );
+            }
+            else
+            {
+                scmResult = new LoginScmResult( cl.toString(), null, null, true );
+            }
+            return scmResult;
+        }
+        catch ( CommandLineException e )
+        {
+            throw new ScmException( e.getMessage(), e );
+        }
+    }
+
+    /**
+     * Creates the login command line
+     *
+     * @param repository AccuRevScmProviderRepository object
+     * @return Commadline object to perform login
+     */
+    protected Commandline createLoginCommandLine( AccuRevScmProviderRepository repository )
+    {
+        Commandline cl = new Commandline();
+        cl.setExecutable( this.executable );
+
+        ArrayList params = new ArrayList();
+        params.add( "login" );
+        //Append host info
+        AccuRevScmProvider.appendHostToParamsIfNeeded( repository, params );
+        //Append command params
+        params.add( repository.getUser() );
+        String password = repository.getPassword();
+        params.add( StringUtils.isBlank( password ) ? "\"\"" : password );
+        //Set arguments to command line
+        cl.addArguments( (String[]) params.toArray( new String[params.size()] ) );
+        return cl;
+	}
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/main/java/org/apache/maven/scm/provider/accurev/commands/login/AccuRevLoginCommand.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java Mon May  5 12:49:57 2008
@@ -0,0 +1,138 @@
+package org.apache.maven.scm.provider.accurev;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import junit.framework.TestCase;
+import org.apache.maven.scm.repository.ScmRepositoryException;
+
+public class AccurevScmProviderTest extends TestCase
+{
+    public void testMakeProviderScmRepository() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "user|passwd@testhost.com|5060|TestDepot|TestStream|TestWorkspace", '|' );
+        assertEquals( "user", repository.getUser() );
+        assertEquals( "passwd", repository.getPassword() );
+        assertEquals( "testhost.com", repository.getHost() );
+        assertEquals( 5060, repository.getPort() );
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( "TestWorkspace", repository.getWorkspaceName() );
+
+    }
+
+    public void testMakeProviderScmRepositoryColumnDelimeter() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "user:passwd@testhost.com:5060:TestDepot:TestStream:TestWorkspace", ':' );
+        assertEquals( "user", repository.getUser() );
+        assertEquals( "passwd", repository.getPassword() );
+        assertEquals( "testhost.com", repository.getHost() );
+        assertEquals( 5060, repository.getPort() );
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( "TestWorkspace", repository.getWorkspaceName() );
+
+    }
+
+    public void testMakeProviderScmRepositoryNoPassword() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "user@testhost.com:5060:TestDepot:TestStream:TestWorkspace", ':' );
+        assertEquals( "user", repository.getUser() );
+        assertNull( repository.getPassword() );
+        assertEquals( "testhost.com", repository.getHost() );
+        assertEquals( 5060, repository.getPort() );
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( "TestWorkspace", repository.getWorkspaceName() );
+
+    }
+
+    public void testDefaultCheckoutMethod() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "TestDepot:TestStream:TestWorkspace", ':' );
+        assertEquals( "pop", repository.getCheckoutMethod() );
+
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( "TestWorkspace", repository.getWorkspaceName() );
+
+    }
+
+    public void testMakeProviderScmRepositoryWithoutAccountInfo() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "TestDepot:TestStream:TestWorkspace", ':' );
+        assertEquals( null, repository.getHost() );
+        assertEquals( AccuRevScmProviderRepository.DEFAULT_PORT, repository.getPort() );
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( "TestWorkspace", repository.getWorkspaceName() );
+
+    }
+
+    public void testMakeProviderScmRepositoryWithoutWorkspace() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository repository = (AccuRevScmProviderRepository) provider.makeProviderScmRepository(
+            "TestDepot:TestStream", ':' );
+        assertEquals( null, repository.getHost() );
+        assertEquals( AccuRevScmProviderRepository.DEFAULT_PORT, repository.getPort() );
+        assertEquals( "TestDepot", repository.getDepot() );
+        assertEquals( "TestStream", repository.getStreamName() );
+        assertEquals( null, repository.getWorkspaceName() );
+    }
+
+    public void testMakeProviderScmRepositoryWithoutStream()
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        try
+        {
+            provider.makeProviderScmRepository( "TestDepot", ':' );
+            assertFalse( "Stream name should be required", true );
+        }
+        catch ( ScmRepositoryException e )
+        {
+            //good
+        }
+    }
+
+    public void testMakeProviderScmRepositoryWithParams() throws ScmRepositoryException
+    {
+        AccuRevScmProvider provider = new AccuRevScmProvider();
+
+        AccuRevScmProviderRepository rep = (AccuRevScmProviderRepository) provider
+            .makeProviderScmRepository( "TestDepot:Stream?param=value&param2=value2&param3=", ':' );
+        assertEquals( "value", rep.getParams().get( "param" ) );
+        assertEquals( "value2", rep.getParams().get( "param2" ) );
+        assertEquals( "", rep.getParams().get( "param3" ) );
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/AccurevScmProviderTest.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"

Added: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java?rev=653572&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java Mon May  5 12:49:57 2008
@@ -0,0 +1,292 @@
+package org.apache.maven.scm.provider.accurev.commands.checkout;
+
+/*
+ * Copyright 2008 AccuRev Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ *
+ * You may obtain a copy of the License at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.maven.scm.CommandParameters;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.command.login.LoginScmResult;
+import org.apache.maven.scm.manager.BasicScmManager;
+import org.apache.maven.scm.manager.ScmManager;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.accurev.AccuRevScmProvider;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.apache.maven.scm.tck.command.checkout.CheckOutCommandTckTest;
+import org.codehaus.plexus.util.cli.CommandLineException;
+import org.codehaus.plexus.util.cli.CommandLineUtils;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+public class AccuRevScmTckTestCase extends CheckOutCommandTckTest
+{
+    private String username;
+    private String password;
+    private String host;
+    private Integer port;
+    private String depot;
+    private String stream;
+
+    private String initWorkspaceName;
+    private String workspaceName;
+
+    private MyAccuRevScmProvider scmProvider = new MyAccuRevScmProvider();
+
+    private BasicScmManager scmManager;
+
+    protected ScmManager getScmManager() throws Exception
+    {
+        if ( null == scmManager )
+        {
+            scmManager = new BasicScmManager();
+            scmManager.setScmProvider( "accurev", scmProvider );
+        }
+        return scmManager;
+    }
+
+    protected void setUp() throws Exception
+    {
+        username = System.getProperty( "test.accurev.username", "test" );
+        password = System.getProperty( "test.accurev.password", "" );
+        host = System.getProperty( "test.accurev.host", "localhost" );
+        port = Integer.getInteger( "test.accurev.port", 5050 );
+        depot = System.getProperty( "test.accurev.depot", "Test" );
+        stream = System.getProperty( "test.accurev.stream", "Test" );
+
+        initWorkspaceName = "workspace." + System.currentTimeMillis() + "_" + username;
+        workspaceName = "workspace." + ( System.currentTimeMillis() + 1 ) + "_" + username;
+
+        super.setUp();
+    }
+
+    public String getScmUrl( String workspaceName, String checkoutMethod ) throws Exception
+    {
+        return StringUtils.join( new String[]{
+            "scm", "accurev", username, password + "@" + host, String.valueOf( port ), depot, stream, workspaceName
+        }, ':' ) + "?checkoutMethod=" + checkoutMethod;
+    }
+
+    public String getScmUrl() throws Exception
+    {
+        return getScmUrl( this.workspaceName, "pop" );
+    }
+
+    public void initRepo() throws Exception
+    {
+        String scmUrl = getScmUrl( initWorkspaceName, "mkws" );
+        //Login
+        ScmRepository scmRepository = getScmManager().makeScmRepository( scmUrl );
+        scmProvider.login( scmRepository.getProviderRepository(), getScmFileSet(), new CommandParameters() );
+
+        File basedir = getScmFileSet().getBasedir();
+        if ( !basedir.exists() )
+        {
+            basedir.mkdir();
+            basedir.mkdirs();
+        }
+        else
+        {
+            cleanDir( basedir );
+        }
+        //Check if the base folder is not assosiated with workspace
+        Commandline cl = makeCommandLine( basedir, "info" );
+
+        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+        InfoCommandStreamConsumer infoCommandStreamConsumer = new InfoCommandStreamConsumer();
+        executeCommandLine( cl, infoCommandStreamConsumer, stdout );
+
+        String workspace = infoCommandStreamConsumer.getWorkspace();
+        if ( null != workspace )
+        {
+            //Pop everything
+            cl = makeCommandLine( basedir, "pop" );
+            cl.addArguments( new String[]{"-R", "."} );
+            executeCommandLine( cl, stdout, stdout );
+        }
+        else
+        {
+            workspace = initWorkspaceName;
+            //Checkout the test stream
+            CheckOutScmResult result = getScmManager().checkOut( scmRepository, getScmFileSet() );
+            if ( !result.isSuccess() )
+            {
+                throw new IllegalStateException( "Cannot checkout the stream" );
+            }
+        }
+        File[] files = basedir.listFiles();
+        List filesToDefunct = new ArrayList( files.length );
+        for ( int i = 0; i < files.length; i++ )
+        {
+            File file = files[i];
+            filesToDefunct.add( file.getAbsolutePath() );
+        }
+        //Clean the test stream
+        if ( filesToDefunct.size() > 0 )
+        {
+            //Defunct all elements in stream
+            cl = makeCommandLine( basedir, "defunct" );
+            cl.addArguments( (String[]) filesToDefunct.toArray( new String[filesToDefunct.size()] ) );
+            stdout = new CommandLineUtils.StringStreamConsumer();
+            executeCommandLine( cl, stdout, stdout );
+            //Promote defuncted files
+            promote( filesToDefunct, basedir );
+        }
+        //Add files expected by the tests to the repository
+        String[] filesToCreate = {
+            "/pom.xml", "/readme.txt", "/src/main/java/Application.java", "/src/test/java/Test.java"
+        };
+        List filesToPromote = new ArrayList();
+        for ( int i = 0; i < filesToCreate.length; i++ )
+        {
+            String fileToCreate = filesToCreate[i];
+            File file = new File( basedir.getAbsolutePath() + fileToCreate.replace( '/', File.separatorChar ) );
+            file.getParentFile().mkdirs();
+
+            writeContentsToFile( file, fileToCreate );
+            addToWorkingTree( basedir, file, scmRepository );
+            filesToPromote.add( file.getAbsolutePath() );
+        }
+        promote( filesToPromote, basedir );
+
+        //remove the workspace
+        removeWorkspace( basedir, workspace );
+        cleanDir( basedir );
+    }
+
+    private void promote( List files, File basedir ) throws CommandLineException
+    {
+        Commandline cl = makeCommandLine( basedir, "promote" );
+        cl.addArguments( (String[]) files.toArray( new String[files.size()] ) );
+        CommandLineUtils.StringStreamConsumer stdout = new CommandLineUtils.StringStreamConsumer();
+        executeCommandLine( cl, stdout, stdout );
+    }
+
+    private void writeContentsToFile( File file, String contents ) throws IOException
+    {
+        FileWriter fileWriter = new FileWriter( file, false );
+        fileWriter.write( contents );
+        fileWriter.close();
+    }
+
+    private void removeWorkspace( File commandBasedir, String workspace ) throws CommandLineException
+    {
+        CommandLineUtils.StringStreamConsumer stdout;
+        Commandline cl;
+        stdout = new CommandLineUtils.StringStreamConsumer();
+
+        cl = makeCommandLine( commandBasedir, "rmws" );
+        cl.addArguments( new String[]{"-s", workspace} );
+
+        executeCommandLine( cl, stdout, stdout );
+    }
+
+    private void cleanDir( File basedir )
+    {
+        if ( !removeFilesInDir( basedir ) )
+        {
+            throw new IllegalStateException( "Files in checkout directory cannot be deleted" );
+        }
+    }
+
+    private boolean removeFilesInDir( File dir )
+    {
+        if ( !dir.isDirectory() )
+        {
+            throw new IllegalArgumentException( "\"" + dir + "\" not a directory" );
+        }
+        boolean res = true;
+        File[] files = dir.listFiles();
+        for ( int i = 0; i < files.length; i++ )
+        {
+            File file = files[i];
+            if ( file.isDirectory() )
+            {
+                res &= removeFilesInDir( file );
+                continue;
+            }
+            res &= file.delete();
+        }
+        return res;
+    }
+
+    private Commandline makeCommandLine( File basedir, String command )
+    {
+        Commandline cl;
+        cl = new Commandline();
+        cl.setWorkingDirectory( basedir.getAbsolutePath() );
+        cl.setExecutable( "accurev" );
+        cl.addArguments( new String[]{command, "-H", host + ":" + port} );
+        return cl;
+    }
+
+    private static void executeCommandLine( Commandline cl, CommandLineUtils.StringStreamConsumer stdOutConsumer,
+                                            CommandLineUtils.StringStreamConsumer errOutConsumer )
+        throws CommandLineException
+    {
+        int exitCode = CommandLineUtils.executeCommandLine( cl, stdOutConsumer, errOutConsumer );
+        if ( exitCode != 0 )
+        {
+            throw new IllegalStateException( "Cannot execute command: \"" + cl.toString() + "\"." +
+                "\nOutput: \n" + stdOutConsumer.getOutput() +
+                "\nError output: \n" + errOutConsumer.getOutput() +
+                "" );
+        }
+    }
+
+    public class MyAccuRevScmProvider extends AccuRevScmProvider
+    {
+        public LoginScmResult login( ScmProviderRepository repository, ScmFileSet fileSet,
+                                     CommandParameters parameters ) throws ScmException
+        {
+            return super.login( repository, fileSet, parameters );
+        }
+    }
+
+    private class InfoCommandStreamConsumer extends CommandLineUtils.StringStreamConsumer
+    {
+        private String workspace;
+        private final Pattern pattern = Pattern.compile( "Workspace/ref:\\s*(.*)" );
+
+        public InfoCommandStreamConsumer()
+        {
+        }
+
+        public void consumeLine( String line )
+        {
+            super.consumeLine( line );
+            Matcher m = pattern.matcher( line );
+
+            if ( m.matches() )
+            {
+                workspace = m.group( 1 );
+            }
+        }
+
+        public String getWorkspace()
+        {
+            return workspace;
+        }
+    }
+}

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-providers-accurev/src/test/java/org/apache/maven/scm/provider/accurev/commands/checkout/AccuRevScmTckTestCase.java
------------------------------------------------------------------------------
    svn:keywords = "Author Date Id Revision"



Mime
View raw message