You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/04/23 09:45:38 UTC
svn commit: r1329106 [2/6] - in /maven/scm/trunk: ./ maven-scm-client/
maven-scm-client/src/main/resources/META-INF/plexus/ maven-scm-providers/
maven-scm-providers/maven-scm-provider-accurev/src/test/java/org/apache/maven/scm/provider/accurev/command/...
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,109 @@
+package org.apache.maven.scm.provider.jazz.command.blame;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.TimeZone;
+
+import org.apache.maven.scm.command.blame.BlameLine;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+//STATUS: NOT DONE
+
+/**
+ * Consume the output of the scm command for the "blame" operation.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzBlameConsumer
+ extends AbstractRepositoryConsumer
+{
+ private static final String JAZZ_TIMESTAMP_PATTERN = "yyyy-MM-dd";
+
+// 1 Deb (1008) 2011-12-14 Test.txt
+// 2 Deb (1005) 2011-12-14 59 My commit comment.
+
+ private static final String LINE_PATTERN = "(\\d+) (.*) \\((\\d+)\\) (\\d+-\\d+-\\d+) (.*)";
+
+ /**
+ * @see #LINE_PATTERN
+ */
+ private RE lineRegexp;
+
+ private List<BlameLine> fLines = new ArrayList<BlameLine>();
+
+ private SimpleDateFormat dateFormat;
+
+ /**
+ * Construct the JazzBlameCommand consumer.
+ * @param repository The repository we are working with.
+ * @param logger The logger to use.
+ */
+ public JazzBlameConsumer( ScmProviderRepository repository, ScmLogger logger )
+ {
+ super( repository, logger );
+
+ dateFormat = new SimpleDateFormat( JAZZ_TIMESTAMP_PATTERN );
+ dateFormat.setTimeZone( TimeZone.getTimeZone( "UTC" ) );
+
+ try
+ {
+ lineRegexp = new RE( LINE_PATTERN );
+ }
+ catch ( RESyntaxException ex )
+ {
+ throw new RuntimeException(
+ "INTERNAL ERROR: Could not create regexp to parse jazz scm blame output. This shouldn't happen. Something is probably wrong with the oro installation.",
+ ex );
+ }
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm annotate" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ super.consumeLine( line );
+
+ if ( lineRegexp.match( line ) )
+ {
+ String lineNumberStr = lineRegexp.getParen( 1 );
+ String owner = lineRegexp.getParen( 2 );
+ String changeSetNumberStr = lineRegexp.getParen( 3 );
+ String dateStr = lineRegexp.getParen( 4 );
+ Date date = parseDate( dateStr, JAZZ_TIMESTAMP_PATTERN, null );
+ fLines.add( new BlameLine(date, changeSetNumberStr, owner) );
+ }
+ }
+
+ public List<BlameLine> getLines()
+ {
+ return fLines;
+ }
+}
\ No newline at end of file
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/blame/JazzBlameConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,64 @@
+package org.apache.maven.scm.provider.jazz.command.branch;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.ScmResult;
+import org.apache.maven.scm.command.branch.AbstractBranchCommand;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+
+// STATUS: NOT DONE
+//
+// The current scm command does not have the functionality to create streams.
+//
+// Once it does, we will need to figure out how users intend this goal to work in RTC.
+//
+// There is no direct equivalent of the "branch" command in RTC.
+// A branch in RTC is roughly equivalent to a Stream or even a Repository Workspace, depending on how
+// the flow targets have been defined, thus the branch command could be used to create a new Stream or
+// Repository Workspace. The RTC command "create" can be used to create new Repository Workspaces.
+// Note however the creation of a new stream from the command line is not supported.
+//
+// See the following links for additional information on the RTC "create" command:
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_create.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_create.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_create.html
+//
+
+/**
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzBranchCommand
+ extends AbstractBranchCommand
+{
+ /**
+ * {@inheritDoc}
+ */
+ protected ScmResult executeBranchCommand( ScmProviderRepository repo, ScmFileSet fileSet, String branch,
+ String message )
+ throws ScmException
+ {
+ throw new ScmException( "This provider does not support the branch command." );
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/branch/JazzBranchCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,145 @@
+package org.apache.maven.scm.provider.jazz.command.changelog;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmBranch;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.command.changelog.AbstractChangeLogCommand;
+import org.apache.maven.scm.command.changelog.ChangeLogScmResult;
+import org.apache.maven.scm.command.changelog.ChangeLogSet;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.JazzConstants;
+import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
+import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
+import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+
+// To get a changelog, we need to get a list of changesets (scm history), and then for each changeset listed,
+// get the details of each changeset (scm list changesets X, Y, Z).
+//
+// We do not appear to be able to get a list of changes between a range of dates, so all of them are returned.
+//
+// See the following links for additional information on the RTC "history" command:
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_history.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_history.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_history.html
+//
+//
+// See the following links for additional information on the RTC "list changesets" command:
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_list.html
+//
+
+/**
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzChangeLogCommand
+ extends AbstractChangeLogCommand
+{
+ /**
+ * {@inheritDoc}
+ */
+ protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository repo, ScmFileSet fileSet,
+ Date startDate, Date endDate, ScmBranch branch,
+ String datePattern )
+ throws ScmException
+ {
+ if ( branch != null && StringUtils.isNotEmpty( branch.getName() ) )
+ {
+ throw new ScmException( "This SCM provider doesn't support branches." );
+ }
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "Executing changelog command..." );
+ }
+
+ // This acts as a two phase operation.
+ // The first pass is to call the "scm history" command to get a list
+ // of the changeSets from Jazz SCM. It is stored in the revision of the
+ // changeSets array.
+ List<ChangeSet> changeSets = new ArrayList<ChangeSet>();
+ JazzScmCommand historyCommand = createHistoryCommand( repo, fileSet );
+ JazzHistoryConsumer changeLogConsumer = new JazzHistoryConsumer( repo, getLogger(), changeSets );
+ ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
+ int status = historyCommand.execute( changeLogConsumer, errConsumer );
+ if ( status != 0 || errConsumer.hasBeenFed() )
+ {
+ return new ChangeLogScmResult( historyCommand.getCommandString(),
+ "Error code for Jazz SCM history command - " + status,
+ errConsumer.getOutput(), false );
+ }
+
+ // Now, call the "scm list changesets" command, passing in the list of changesets from the first pass.
+ JazzScmCommand listChangesetsCommand = createListChangesetCommand( repo, fileSet, changeSets );
+ JazzListChangesetConsumer listChangesetConsumer = new JazzListChangesetConsumer( repo, getLogger(), changeSets, datePattern );
+ errConsumer = new ErrorConsumer( getLogger() );
+ status = listChangesetsCommand.execute( listChangesetConsumer, errConsumer );
+ if ( status != 0 || errConsumer.hasBeenFed() )
+ {
+ return new ChangeLogScmResult( listChangesetsCommand.getCommandString(),
+ "Error code for Jazz SCM list changesets command - " + status,
+ errConsumer.getOutput(), false );
+ }
+
+ // Build the result and return it.
+ ChangeLogSet changeLogSet = new ChangeLogSet( changeSets, startDate, endDate );
+
+ // Return the "main" command used, namely "scm history"
+ return new ChangeLogScmResult( historyCommand.getCommandString(), changeLogSet );
+ }
+
+ protected JazzScmCommand createHistoryCommand( ScmProviderRepository repo, ScmFileSet fileSet )
+ {
+ JazzScmCommand command = new JazzScmCommand( JazzConstants.CMD_HISTORY, repo, fileSet, getLogger() );
+ command.addArgument( JazzConstants.ARG_MAXIMUM );
+ command.addArgument( "10000000" ); // Beyond me as to why they didn't make 0 = all.
+ // And just to really annoy us, it defaults to 10.
+ // So we put something stupidly large in there instead.
+
+ return command;
+ }
+
+ protected JazzScmCommand createListChangesetCommand( ScmProviderRepository repo, ScmFileSet fileSet, List<ChangeSet> changeSets )
+ {
+ JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
+ JazzScmCommand command = new JazzScmCommand( JazzConstants.CMD_LIST, JazzConstants.CMD_SUB_CHANGESETS, repo, fileSet, getLogger() );
+ command.addArgument( JazzConstants.ARG_WORKSPACE );
+ command.addArgument( jazzRepo.getWorkspace() );
+ for (int i=0; i<changeSets.size(); i++)
+ {
+ command.addArgument( changeSets.get( i ).getRevision() );
+ }
+ return command;
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzChangeLogCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,100 @@
+package org.apache.maven.scm.provider.jazz.command.changelog;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.util.List;
+
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+/**
+ * Consume the output of the scm command for the "history" operation.
+ *
+ * It is passed in a List of ChangeSet entries. All we do is to parse
+ * the Jazz change set aliases, and save as the revision into the list.
+ *
+ * NOTE: We do not set the command or date or anything other than the revision
+ * here, as we pick that information up from the "scm list changeset" command.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzHistoryConsumer
+ extends AbstractRepositoryConsumer
+{
+//Change sets:
+// (1589) ---$ Deb "[maven-release-plugin] prepare for next development itera..."
+// (1585) ---$ Deb "[maven-release-plugin] prepare release GPDB-1.0.21"
+// (1584) ---$ Deb "This is my first changeset (2)"
+// (1583) ---$ Deb "This is my first changeset (1)"
+
+ private static final String CHANGESET_PATTERN = "\\((\\d+)\\) (.*)";
+
+ /**
+ * @see #CHANGESET_PATTERN
+ */
+ private RE changeSetRegExp;
+
+ private List<ChangeSet> entries;
+
+ /**
+ * Constructor for our "scm history" consumer.
+ * @param repo The JazzScmProviderRepository being used.
+ * @param logger The ScmLogger to use.
+ * @param entries The List of ChangeSet entries that we will populate.
+ */
+ public JazzHistoryConsumer( ScmProviderRepository repo, ScmLogger logger, List<ChangeSet> entries )
+ {
+ super( repo, logger );
+ this.entries = entries;
+
+ try
+ {
+ changeSetRegExp = new RE( CHANGESET_PATTERN );
+ }
+ catch ( RESyntaxException ex )
+ {
+ throw new RuntimeException(
+ "INTERNAL ERROR: Could not create regexp to parse jazz scm history output. This shouldn't happen. Something is probably wrong with the oro installation.",
+ ex );
+ }
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm xxxx" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ super.consumeLine( line );
+ if ( changeSetRegExp.match( line ) )
+ {
+ String changesetAlias = changeSetRegExp.getParen( 1 );
+ ChangeSet changeSet = new ChangeSet();
+ changeSet.setRevision( changesetAlias );
+
+ entries.add( changeSet );
+ }
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzHistoryConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,534 @@
+package org.apache.maven.scm.provider.jazz.command.changelog;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.List;
+
+import org.apache.maven.scm.ChangeFile;
+import org.apache.maven.scm.ChangeSet;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+/**
+ * Consume the output of the scm command for the "list changesets" operation.
+ *
+ * This parses the contents of the output and uses it to fill in the remaining
+ * information in the <code>entries</code> list.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzListChangesetConsumer
+ extends AbstractRepositoryConsumer
+{
+//Change sets:
+// (1589) ---$ Deb "[maven-release-plugin] prepare for next development iteration"
+// Component: (1158) "GPDB"
+// Modified: Feb 25, 2012 10:15 PM (Yesterday)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// ---c- (1165) \GPDB\pom.xml
+// (1585) ---$ Deb "[maven-release-plugin] prepare release GPDB-1.0.21"
+// Component: (1158) "GPDB"
+// Modified: Feb 25, 2012 10:13 PM (Yesterday)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// ---c- (1165) \GPDB\pom.xml
+// (1584) ---$ Deb "This is my first changeset (2)"
+// Component: (1158) "GPDB"
+// Modified: Feb 25, 2012 10:13 PM (Yesterday)
+// (1583) ---$ Deb "This is my first changeset (1)"
+// Component: (1158) "GPDB"
+// Modified: Feb 25, 2012 10:13 PM (Yesterday)
+// (1323) ---$ Deb <No comment>
+// Component: (1158) "GPDB"
+// Modified: Feb 24, 2012 11:04 PM (Last Week)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// ---c- (1165) \GPDB\pom.xml
+// (1319) ---$ Deb <No comment>
+// Component: (1158) "GPDB"
+// Modified: Feb 24, 2012 11:03 PM (Last Week)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// ---c- (1165) \GPDB\pom.xml
+//
+// NOTE: If the change sets originate on the current date, the date is not
+// displayed, only the time is.
+// EG:
+//Change sets:
+// (1809) ---$ Deb "[maven-release-plugin] prepare for next development iteration"
+// Component: (1158) "GPDB"
+// Modified: 6:20 PM (5 minutes ago)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// ---c- (1165) \GPDB\pom.xml
+// (1801) ---$ Deb "[maven-release-plugin] prepare release GPDB-1.0.26"
+// Component: (1158) "GPDB"
+// Modified: 6:18 PM (10 minutes ago)
+// Changes:
+// ---c- (1170) \GPDB\GPDBEAR\pom.xml
+// ---c- (1171) \GPDB\GPDBResources\pom.xml
+// ---c- (1167) \GPDB\GPDBWeb\pom.xml
+// (1799) ---$ Deb <No comment>
+// Component: (1158) "GPDB"
+// Modified: 6:18 PM (10 minutes ago)
+// Changes:
+// ---c- (1165) \GPDB\pom.xml
+// (1764) ---$ Deb <No comment>
+// Component: (1158) "GPDB"
+// Modified: Mar 1, 2012 2:34 PM
+// Changes:
+// ---c- (1165) \GPDB\pom.xml
+
+
+ // State Machine Definitions
+ private static final int STATE_CHANGE_SETS = 0;
+ private static final int STATE_CHANGE_SET = 1;
+ private static final int STATE_COMPONENT = 2;
+ private static final int STATE_MODIFIED = 3;
+ private static final int STATE_CHANGES = 4;
+
+ // Header definitions.
+ private static final String HEADER_CHANGE_SETS = "Change sets:";
+
+ private static final String HEADER_CHANGE_SET = "(";
+
+ private static final String HEADER_COMPONENT = "Component:";
+
+ private static final String HEADER_MODIFIED = "Modified:";
+
+ private static final String HEADER_CHANGES = "Changes:";
+
+ private static final String JAZZ_TIMESTAMP_PATTERN = "MMM d, yyyy h:mm a"; // Actually: DateFormat.getDateTimeInstance( DateFormat.MEDIUM, DateFormat.SHORT );
+
+ private static final String JAZZ_TIMESTAMP_PATTERN_TIME = "h:mm a"; // Only seen when the data = today. Only the time is displayed.
+
+ // (1589) ---$ Deb "[maven-release-plugin] prepare for next development iteration"
+ // (1585) ---$ Deb "[maven-release-plugin] prepare release GPDB-1.0.21"
+ private static final String CHANGESET_PATTERN = "\\((\\d+)\\) (....) (\\w+) (.*)";
+
+ /**
+ * @see #CHANGESET_PATTERN
+ */
+ private RE changeSetRegExp;
+
+ // ---c- (1170) \GPDB\GPDBEAR\pom.xml
+ // ---c- (1171) \GPDB\GPDBResources\pom.xml
+ // ---c- (1167) \GPDB\GPDBWeb\pom.xml
+ // ---c- (1165) \GPDB\pom.xml
+ private static final String CHANGES_PATTERN = "(.....) \\((\\d+)\\) (.*)";
+
+ /**
+ * @see #CHANGES_PATTERN
+ */
+ private RE changesRegExp;
+
+
+ private List<ChangeSet> entries;
+
+ private final String userDateFormat;
+
+ // This is incremented at the beginning of every change set line. So we start at -1 (to get zero on first processing)
+ private int currentChangeSetIndex = -1;
+
+ private int currentState = STATE_CHANGE_SETS;
+
+ /**
+ * Constructor for our "scm list changeset" consumer.
+ * @param repo The JazzScmProviderRepository being used.
+ * @param logger The ScmLogger to use.
+ * @param entries The List of ChangeSet entries that we will populate.
+ */
+ public JazzListChangesetConsumer( ScmProviderRepository repo, ScmLogger logger, List<ChangeSet> entries, String userDateFormat )
+ {
+ super( repo, logger );
+ this.entries = entries;
+ this.userDateFormat = userDateFormat;
+
+ try
+ {
+ changeSetRegExp = new RE( CHANGESET_PATTERN );
+ changesRegExp = new RE( CHANGES_PATTERN );
+ }
+ catch ( RESyntaxException ex )
+ {
+ throw new RuntimeException(
+ "INTERNAL ERROR: Could not create regexp to parse jazz scm history output. This shouldn't happen. Something is probably wrong with the oro installation.",
+ ex );
+ }
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm list changeset" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ super.consumeLine( line );
+
+ // Process the "Change sets:" line - do nothing
+ if ( line.trim().startsWith( HEADER_CHANGE_SETS ) )
+ {
+ currentState = STATE_CHANGE_SETS;
+ }
+ else
+ {
+ if ( line.trim().startsWith( HEADER_CHANGE_SET ) )
+ {
+ currentState = STATE_CHANGE_SET;
+ }
+ else
+ {
+ if ( line.trim().startsWith( HEADER_COMPONENT ) )
+ {
+ currentState = STATE_COMPONENT;
+ }
+ else
+ {
+ if ( line.trim().startsWith( HEADER_MODIFIED ) )
+ {
+ currentState = STATE_MODIFIED;
+ }
+ else
+ {
+ if ( line.trim().startsWith( HEADER_CHANGES ) )
+ {
+ // Note: processChangesLine() will also be passed the "Changes:" line
+ // So, it needs to be able to deal with that.
+ // Changes:
+ // ---c- (1170) \GPDB\GPDBEAR\pom.xml
+ // ---c- (1171) \GPDB\GPDBResources\pom.xml
+ // ---c- (1167) \GPDB\GPDBWeb\pom.xml
+ // ---c- (1165) \GPDB\pom.xml
+ currentState = STATE_CHANGES;
+ }
+ }
+ }
+ }
+ }
+
+ switch (currentState)
+ {
+ case STATE_CHANGE_SETS:
+ // Nothing to do.
+ break;
+
+ case STATE_CHANGE_SET:
+ processChangeSetLine( line );
+ break;
+
+ case STATE_COMPONENT:
+ // Nothing to do. Not used (Yet?)
+ break;
+
+ case STATE_MODIFIED:
+ processModifiedLine( line );
+ break;
+
+ case STATE_CHANGES:
+ processChangesLine( line );
+ break;
+ }
+
+ }
+
+ private void processChangeSetLine(String line)
+ {
+ // Process the headerless change set line - starts with a '(', eg:
+ // (1589) ---$ Deb "[maven-release-plugin] prepare for next development iteration"
+ // (1585) ---$ Deb "[maven-release-plugin] prepare release GPDB-1.0.21"
+ if ( changeSetRegExp.match( line ) )
+ {
+ // This is the only place this gets incremented.
+ // It starts at -1, and on first execution is incremented to 0 - which is correct.
+ currentChangeSetIndex++;
+ ChangeSet currentChangeSet = entries.get( currentChangeSetIndex );
+
+ // Init the file of files, so it is not null, but it can be empty!
+ List<ChangeFile> files = new ArrayList<ChangeFile>();
+ currentChangeSet.setFiles( files );
+
+ String changesetAlias = changeSetRegExp.getParen( 1 );
+ String changeFlags = changeSetRegExp.getParen( 2 ); // Not used.
+ String author = changeSetRegExp.getParen( 3 );
+ String comment = changeSetRegExp.getParen( 4 );
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( " Parsing ChangeSet Line : " + line );
+ getLogger().debug( " changesetAlias : " + changesetAlias );
+ getLogger().debug( " changeFlags : " + changeFlags );
+ getLogger().debug( " author : " + author );
+ getLogger().debug( " comment : " + comment );
+ }
+
+ // Sanity check.
+ if ( currentChangeSet.getRevision() != null && !currentChangeSet.getRevision().equals( changesetAlias ) )
+ {
+ getLogger().warn( "Warning! The indexes appear to be out of sequence! " +
+ "For currentChangeSetIndex = " + currentChangeSetIndex + ", we got '" +
+ changesetAlias + "' and not '" + currentChangeSet.getRevision() + "' as expected." );
+ }
+
+ comment = stripDelimiters( comment );
+ currentChangeSet.setAuthor( author );
+ currentChangeSet.setComment( comment );
+ }
+ }
+
+ private void processModifiedLine(String line)
+ {
+ // Process the "Modified: ..." line, eg:
+ // Modified: Feb 25, 2012 10:15 PM (Yesterday)
+ // Modified: Feb 25, 2012 10:13 PM (Yesterday)
+ // Modified: Feb 24, 2012 11:03 PM (Last Week)
+ // Modified: Mar 1, 2012 2:34 PM
+ // Modified: 6:20 PM (5 minutes ago)
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( " Parsing Modified Line : " + line );
+ }
+
+ int colonPos = line.indexOf( ":" );
+ int parenPos = line.indexOf( "(" );
+
+ String date = null;
+
+ if ( colonPos != -1 && parenPos != -1 )
+ {
+ date = line.substring( colonPos + 2, parenPos - 1 );
+ }
+ else
+ {
+ if ( colonPos != -1 && parenPos == -1 )
+ {
+ // No trailing bracket
+ date = line.substring( colonPos + 2 );
+ }
+ }
+
+ if ( date != null)
+ {
+ Date changesetDate = null;
+
+ changesetDate = parseDate( date.toString(), userDateFormat, JAZZ_TIMESTAMP_PATTERN );
+ if ( changesetDate == null )
+ {
+ // changesetDate will be null when the date is not given, it only has just the time. The date is today.
+ changesetDate = parseDate( date.toString(), userDateFormat, JAZZ_TIMESTAMP_PATTERN_TIME );
+ // Get today's time/date. Used to get the date.
+ Calendar today = Calendar.getInstance();
+ // Get a working one.
+ Calendar changesetCal = Calendar.getInstance();
+ // Set the date/time. Used to set the time.
+ changesetCal.setTimeInMillis( changesetDate.getTime() );
+ // Now set the date (today).
+ changesetCal.set( today.get( Calendar.YEAR ), today.get( Calendar.MONTH ), today.get( Calendar.DAY_OF_MONTH) );
+ // Now get the date of the combined results.
+ changesetDate = changesetCal.getTime();
+ }
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( " date : " + date );
+ getLogger().debug( " changesetDate : " + changesetDate );
+ }
+
+ ChangeSet currentChangeSet = entries.get( currentChangeSetIndex );
+ currentChangeSet.setDate( changesetDate );
+ }
+ }
+
+ private void processChangesLine(String line)
+ {
+ // Process the changes line, eg:
+ // ---c- (1170) \GPDB\GPDBEAR\pom.xml
+ // ---c- (1171) \GPDB\GPDBResources\pom.xml
+ // ---c- (1167) \GPDB\GPDBWeb\pom.xml
+ // ---c- (1165) \GPDB\pom.xml
+ if ( changesRegExp.match( line ) )
+ {
+ ChangeSet currentChangeSet = entries.get( currentChangeSetIndex );
+
+ String changeFlags = changesRegExp.getParen( 1 ); // Not used.
+ String fileAlias = changesRegExp.getParen( 2 );
+ String file = changesRegExp.getParen( 3 );
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( " Parsing Changes Line : " + line );
+ getLogger().debug( " changeFlags : " + changeFlags + " Translated to : " + parseFileChangeState( changeFlags ) );
+ getLogger().debug( " filetAlias : " + fileAlias );
+ getLogger().debug( " file : " + file );
+ }
+
+ ChangeFile changeFile = new ChangeFile( file );
+ ScmFileStatus status = parseFileChangeState( changeFlags );
+ changeFile.setAction( status );
+ currentChangeSet.getFiles().add( changeFile );
+ }
+ }
+
+ /**
+ * String the leading/trailing ", < and > from the text.
+ * @param text The text to process.
+ * @return The striped text.
+ */
+ protected String stripDelimiters(String text)
+ {
+ if (text == null)
+ {
+ return null;
+ }
+ String workingText = text;
+ if ( workingText.startsWith( "\"" ) || workingText.startsWith( "<" ) )
+ {
+ workingText = workingText.substring( 1 );
+ }
+ if ( workingText.endsWith( "\"" ) || workingText.endsWith( ">" ) )
+ {
+ workingText = workingText.substring( 0, workingText.length() - 1 );
+ }
+
+ return workingText;
+ }
+
+ /**
+ * Parse the change state file flags from Jazz and map them to the maven SCM ones.
+ *
+ * "----" Character positions 0-3.
+ *
+ * [0] is '*' or '-' Indicates that this is the current change set ('*') or not ('-'). STATE_CHANGESET_CURRENT
+ * [1] is '!' or '-' Indicates a Potential Conflict ('!') or not ('-'). STATE_POTENTIAL_CONFLICT
+ * [2] is '#' or '-' Indicates a Conflict ('#') or not ('-'). STATE_CONFLICT
+ * [3] is '@' or '$' Indicates whether the changeset is active ('@') or not ('$'). STATE_CHANGESET_ACTIVE
+ *
+ * @param state The 5 character long state string
+ * @return The ScmFileStatus value.
+ */
+ private ScmFileStatus parseChangeSetChangeState(String state)
+ {
+ if ( state.length() != 4 )
+ {
+ throw new IllegalArgumentException( "Change State string must be 4 chars long!" );
+ }
+
+ // This is not used, but is here for potential future usage and for documentation purposes.
+ return ScmFileStatus.UNKNOWN;
+ }
+
+ /**
+ * Parse the change state file flags from Jazz and map them to the maven SCM ones.
+ *
+ * "-----" Character positions 0-4. The default is '-'.
+ *
+ * [0] is '-' or '!' Indicates a Potential Conflict. STATE_POTENTIAL_CONFLICT
+ * [1] is '-' or '#' Indicates a Conflict. STATE_CONFLICT
+ * [2] is '-' or 'a' Indicates an addition. STATE_ADD
+ * or 'd' Indicates a deletion. STATE_DELETE
+ * or 'm' Indicates a move. STATE_MOVE
+ * [3] is '-' or 'c' Indicates a content change. STATE_CONTENT_CHANGE
+ * [4] is '-' or 'p' Indicates a property change. STATE_PROPERTY_CHANGE
+ *
+ * NOTE: [3] and [4] can only be set it [2] is NOT 'a' or 'd'.
+ *
+ * @param state The 5 character long state string
+ * @return The SCMxxx value.
+ */
+ private ScmFileStatus parseFileChangeState(String state)
+ {
+ if ( state.length() != 5 )
+ {
+ throw new IllegalArgumentException( "Change State string must be 5 chars long!" );
+ }
+
+ // NOTE: We have an impedance mismatch here. The Jazz file change flags represent
+ // many different states. However, we can only return *ONE* ScmFileStatus value,
+ // so we need to be careful as to the precedence that we give to them.
+
+ ScmFileStatus status = ScmFileStatus.UNKNOWN; // Probably not a valid initial default value.
+
+ // [0] is '-' or '!' Indicates a Potential Conflict. STATE_POTENTIAL_CONFLICT
+ if ( state.charAt( 0 ) == '!' )
+ {
+ status = ScmFileStatus.CONFLICT;
+ }
+ // [1] is '-' or '#' Indicates a Conflict. STATE_CONFLICT
+ if ( state.charAt( 1 ) == '#' )
+ {
+ status = ScmFileStatus.CONFLICT;
+ }
+
+ // [2] is '-' or 'a' Indicates an addition. STATE_ADD
+ // or 'd' Indicates a deletion. STATE_DELETE
+ // or 'm' Indicates a move. STATE_MOVE
+ if ( state.charAt( 2 ) == 'a' )
+ {
+ status = ScmFileStatus.ADDED;
+ }
+ else
+ {
+ if ( state.charAt( 2 ) == 'd' )
+ {
+ status = ScmFileStatus.DELETED;
+ }
+ else
+ {
+ if ( state.charAt( 2 ) == 'm' )
+ {
+ status = ScmFileStatus.RENAMED; // Has been renamed or moved.
+ }
+
+ // [3] is '-' or 'c' Indicates a content change. STATE_CONTENT_CHANGE
+ if ( state.charAt( 3 ) == 'c' )
+ {
+ status = ScmFileStatus.MODIFIED; // The file has been modified in the working tree.
+ }
+
+ // [4] is '-' or 'p' Indicates a property change. STATE_PROPERTY_CHANGE
+ if ( state.charAt( 4 ) == 'p' )
+ {
+ status = ScmFileStatus.MODIFIED; // ScmFileStatus has no concept of property or meta data changes.
+ }
+ }
+ }
+
+ return status;
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/changelog/JazzListChangesetConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,231 @@
+package org.apache.maven.scm.provider.jazz.command.checkin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.add.AddScmResult;
+import org.apache.maven.scm.command.checkin.AbstractCheckInCommand;
+import org.apache.maven.scm.command.checkin.CheckInScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.JazzConstants;
+import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
+import org.apache.maven.scm.provider.jazz.command.add.JazzAddCommand;
+import org.apache.maven.scm.provider.jazz.command.consumer.DebugLoggerConsumer;
+import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
+import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+import org.codehaus.plexus.util.cli.StreamConsumer;
+
+// The Maven SCM Plugin "checkin" goal is equivalent to the RTC "checkin" command.
+//
+// This implementation of the Maven SCM Plugin "checkin" goal creates a change set with the message provided.
+// It then uses the Jazz "scm "checkin" command to check the files into a remote workspace.
+// If there is a flow target defined and the pushChanges flag is true (the default), then the remote workspace
+// will be delivered ("scm deliver") to the flow target (a stream or other workspace).
+//
+// Set the pushChanges flag to false, if you do not want the repository workspace delivered.
+//
+// NOTE: At this point, only a SINGLE flow target is supported. Jazz itself, allows for more than one.
+//
+// The differences between this and the "add" goal, are:
+// - The add goal will only checkin into the remote repository workspace.
+// - The add goal will never deliver.
+// - The add goal does not create a change set.
+//
+// This is the best we can do to mimic the implementations of the other providers, that provide a working
+// "add" function (eg "svn add").
+//
+// Add may have had been able to use the "scm share" command, but that is recusive and only takes directory
+// names; we are not able to specify specific or single files.
+//
+// See the following links for additional information on the RTC "checkin" command.
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_checkin.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_checkin.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_checkin.html
+//
+// See the following links for additional information on the RTC "deliver" command.
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_deliver.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_deliver.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_deliver.html
+//
+
+/**
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzCheckInCommand
+ extends AbstractCheckInCommand
+{
+
+ /**
+ * {@inheritDoc}
+ */
+ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repository, ScmFileSet fileSet,
+ String message, ScmVersion scmVersion )
+ throws ScmException
+ {
+ if ( scmVersion != null && StringUtils.isNotEmpty( scmVersion.getName() ) )
+ {
+ throw new ScmException( "This provider command can't handle tags." );
+ }
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "Executing checkin command..." );
+ }
+
+ // Create a changeset. We need to do this, as otherwise the information contained in the message
+ // will be lost forever.
+ JazzScmCommand createChangesetCmd = createCreateChangesetCommand( repository, fileSet, message );
+ DebugLoggerConsumer outputConsumer = new DebugLoggerConsumer( getLogger() );
+ ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
+
+ int status = createChangesetCmd.execute( outputConsumer, errConsumer );
+ if ( status != 0 || errConsumer.hasBeenFed() )
+ {
+ return new CheckInScmResult( createChangesetCmd.getCommandString(),
+ "Error code for Jazz SCM create changeset command - " + status,
+ errConsumer.getOutput(), false );
+ }
+
+ // Now check in the files themselves.
+ return executeCheckInCommand( repository, fileSet, scmVersion );
+ }
+
+ protected CheckInScmResult executeCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet, ScmVersion scmVersion )
+ throws ScmException
+ {
+ // Call the Add command to perform the checkin into the repository workspace.
+ JazzAddCommand addCommand = new JazzAddCommand();
+ addCommand.setLogger( getLogger() );
+ AddScmResult addResult = addCommand.executeAddCommand( repo, fileSet );
+
+ // Now, if it has a flow target, deliver it.
+ JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
+ if ( jazzRepo.isPushChangesAndHaveFlowTargets() )
+ {
+ // Push if we need too
+ JazzScmCommand deliverCmd = createDeliverCommand( (JazzScmProviderRepository) repo, fileSet );
+ StreamConsumer deliverConsumer = new DebugLoggerConsumer( getLogger() ); // No need for a dedicated consumer for this
+ ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
+
+ int status = deliverCmd.execute( deliverConsumer, errConsumer );
+ if ( status != 0 || errConsumer.hasBeenFed() )
+ {
+ return new CheckInScmResult( deliverCmd.getCommandString(),
+ "Error code for Jazz SCM deliver command - " + status,
+ errConsumer.getOutput(), false );
+ }
+ }
+
+ // Return what was added.
+ return new CheckInScmResult( addResult.getCommandLine(), addResult.getAddedFiles() );
+ }
+
+ public JazzScmCommand createCreateChangesetCommand( ScmProviderRepository repo, ScmFileSet fileSet, String message )
+ {
+ JazzScmCommand command =
+ new JazzScmCommand( JazzConstants.CMD_CREATE, JazzConstants.CMD_SUB_CHANGESET, repo, false, fileSet, getLogger() );
+ command.addArgument( message );
+
+ return command;
+ }
+
+ public JazzScmCommand createCheckInCommand( ScmProviderRepository repo, ScmFileSet fileSet )
+ {
+ JazzScmCommand command =
+ new JazzScmCommand( JazzConstants.CMD_CHECKIN, null, repo, false, fileSet, getLogger() );
+
+ // TODO, this was taken out to quickly test how the release plugin works.
+ // The release plugin has the fileSet.getbaseDir() as the project it is checking in
+ // This happens to be a folder under the sandbox root, and so the checkin would fail because it needs
+ // to check in at the sandbox root level (not sub folders)
+ // The SCM Plugin has a basedir parameter that you can pass it, so everythig works ok from the scm-plugin alone
+ // but the release-plugin doesn't look like it lets you do that. (or I didn't have enough time
+ // to figure out how to do it properly).
+
+ // if (fileSet != null) {
+ // command.addArgument(JazzConstants.LOAD_ROOT_DIRECTORY_ARG);
+ // command.addArgument(fileSet.getBasedir().getAbsolutePath());
+ // }
+
+ List<File> files = fileSet.getFileList();
+ if ( files != null && !files.isEmpty() )
+ {
+ Iterator<File> it = files.iterator();
+ while ( it.hasNext() )
+ {
+ File file = (File) it.next();
+ command.addArgument( file.getPath() ); // Check in only the files specified
+ }
+ }
+ else
+ {
+ command.addArgument( "." ); // This will check in all local changes
+ }
+
+ return command;
+ }
+
+ // Create the JazzScmCommand to execute the "scm deliver ..." command
+ // This will deliver the changes to the flow target (stream or other workspace).
+ public JazzScmCommand createDeliverCommand( JazzScmProviderRepository repo, ScmFileSet fileSet )
+ {
+ JazzScmCommand command =
+ new JazzScmCommand( JazzConstants.CMD_DELIVER, repo, fileSet, getLogger() );
+
+ if ( repo.getWorkspace() != null && !repo.getWorkspace().equals( "" ))
+ {
+ command.addArgument( JazzConstants.ARG_DELIVER_SOURCE );
+ command.addArgument( repo.getWorkspace() );
+ }
+
+ if ( repo.getFlowTarget() != null && !repo.getFlowTarget().equals( "" ))
+ {
+ command.addArgument( JazzConstants.ARG_DELIVER_TARGET );
+ command.addArgument( repo.getFlowTarget() );
+ }
+
+ // This command is needed so that the deliver operation will work.
+ // Files that are not under source control (a--) [temp files etc]
+ // will cause the deliver operation to fail with the error:
+ // "Cannot deliver because there are one or more items that are not checked in.
+ // Check in the changes or rerun with --overwrite-uncommitted."
+ // However, from the maven perspective, we only need files that are
+ // under source control to be delivered. Maven has already checked
+ // for this (via the status command).
+ //
+ // So we add this argument to allow the deliver to work.
+ command.addArgument( JazzConstants.ARG_OVERWRITE_UNCOMMITTED );
+
+ return command;
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,120 @@
+package org.apache.maven.scm.provider.jazz.command.checkin;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer;
+
+/**
+ * Consume the output of the scm command for the "checkin" operation.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzCheckInConsumer
+ extends AbstractRepositoryConsumer
+{
+ // A flag to indicate that we have seen the "Changes:" line in the output.
+ // After that, we have the files themselves.
+ private boolean haveSeenChanges = false;
+
+ protected String currentDir = "";
+
+ // The list of files that we have checked in.
+ private List<ScmFile> fCheckedInFiles = new ArrayList<ScmFile>();
+
+ /**
+ * Construct the JazzCheckInCommand consumer.
+ * @param repository The repository we are working with.
+ * @param logger The logger to use.
+ */
+ public JazzCheckInConsumer( ScmProviderRepository repository, ScmLogger logger )
+ {
+ super( repository, logger );
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm checkin" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ super.consumeLine( line );
+ // The Jazz SCM "checkin" command does not output a list of each file that was checked in.
+ // An example output is shown below, perhaps in the future we may need to
+ // consume the "Workspace", "Component", Stream or "Change sets"
+
+ /*
+ Committing...
+ Workspace: (1004) "Release Repository Workspace" <-> (1005) "Maven Release Plugin Stream"
+ Component: (1006) "Release Component"
+ Outgoing:
+ Change sets:
+ (1008) --@ <No comment>
+
+ Or:
+
+ Committing...
+ Workspace: (1903) "MavenSCMTestWorkspace_1332908068770" <-> (1903) "MavenSCMTestWorkspace_1332908068770"
+ Component: (1768) "MavenSCMTestComponent"
+ Outgoing:
+ Change sets:
+ (1907) *--@ "Commit message"
+ Changes:
+ --a-- \src\main\java\Me.java
+ --a-- \src\main\java\Me1.java
+ --a-- \src\main\java\Me2.java
+ */
+
+ if ( haveSeenChanges )
+ {
+ // We have already seen the "Changes:" line, so we must now be processing files.
+ String trimmed = line.trim();
+ int spacePos = trimmed.indexOf( " " );
+ // NOTE: The second + 1 is to remove the leading slash
+ String path = trimmed.substring( spacePos + 1 + 1 );
+ fCheckedInFiles.add( new ScmFile( path, ScmFileStatus.CHECKED_OUT ) );
+ }
+ else
+ {
+ if ( "Changes:".equals(line.trim()) )
+ {
+ haveSeenChanges = true;
+ }
+ }
+ }
+
+ protected ScmFile getScmFile( String filename )
+ {
+ return new ScmFile( new File( currentDir, filename ).getAbsolutePath(), ScmFileStatus.CHECKED_IN );
+ }
+
+ public List<ScmFile> getFiles()
+ {
+ return fCheckedInFiles;
+ }
+}
\ No newline at end of file
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkin/JazzCheckInConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,120 @@
+package org.apache.maven.scm.provider.jazz.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.ScmBranch;
+import org.apache.maven.scm.ScmException;
+import org.apache.maven.scm.ScmFileSet;
+import org.apache.maven.scm.ScmTag;
+import org.apache.maven.scm.ScmVersion;
+import org.apache.maven.scm.command.checkout.AbstractCheckOutCommand;
+import org.apache.maven.scm.command.checkout.CheckOutScmResult;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.JazzConstants;
+import org.apache.maven.scm.provider.jazz.command.JazzScmCommand;
+import org.apache.maven.scm.provider.jazz.command.consumer.ErrorConsumer;
+import org.apache.maven.scm.provider.jazz.repository.JazzScmProviderRepository;
+import org.codehaus.plexus.util.StringUtils;
+
+//
+// The Maven SCM plugin "checkout" goal is equivalent to the RTC "load" command.
+//
+// See the following links for additional information on the RTC "load" command:
+// RTC 2.0.0.2:
+// http://publib.boulder.ibm.com/infocenter/rtc/v2r0m0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_load.html
+// RTC 3.0:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0/topic/com.ibm.team.scm.doc/topics/r_scm_cli_load.html
+// RTC 3.0.1:
+// http://publib.boulder.ibm.com/infocenter/clmhelp/v3r0m1/topic/com.ibm.team.scm.doc/topics/r_scm_cli_load.html
+//
+
+/**
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzCheckOutCommand
+ extends AbstractCheckOutCommand
+{
+ /**
+ * {@inheritDoc}
+ */
+ protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository repo, ScmFileSet fileSet,
+ ScmVersion scmVersion, boolean recursive )
+ throws ScmException
+ {
+ // TODO - Figure out how this recursive boolean impacts Jazz SCM "checkout" (load).
+
+ if ( getLogger().isDebugEnabled() )
+ {
+ getLogger().debug( "Executing checkout command..." );
+ }
+
+ JazzScmProviderRepository jazzRepo = (JazzScmProviderRepository) repo;
+
+ JazzScmCommand checkoutCmd = createJazzLoadCommand( jazzRepo, fileSet, scmVersion );
+ JazzCheckOutConsumer checkoutConsumer = new JazzCheckOutConsumer( repo, getLogger() );
+ ErrorConsumer errConsumer = new ErrorConsumer( getLogger() );
+
+ int status = checkoutCmd.execute( checkoutConsumer, errConsumer );
+ if ( status != 0 || errConsumer.hasBeenFed() )
+ {
+ return new CheckOutScmResult( checkoutCmd.getCommandString(),
+ "Error code for Jazz SCM checkout (load) command - " + status,
+ errConsumer.getOutput(), false );
+ }
+
+ return new CheckOutScmResult( checkoutCmd.getCommandString(), checkoutConsumer.getCheckedOutFiles() );
+ }
+
+ public JazzScmCommand createJazzLoadCommand( JazzScmProviderRepository repo, ScmFileSet fileSet,
+ ScmVersion scmVersion )
+ {
+ JazzScmCommand command = new JazzScmCommand( JazzConstants.CMD_LOAD, JazzConstants.ARG_FORCE, repo, fileSet, getLogger() );
+
+ if ( fileSet != null )
+ {
+ command.addArgument( JazzConstants.ARG_LOCAL_WORKSPACE_PATH );
+ command.addArgument( fileSet.getBasedir().getAbsolutePath() );
+ }
+
+ // This works in tandem with the Tag Command.
+ // Currently, RTC can not check out directly from a snapshot.
+ // So, as a work around, the Tag Command creates a workspace name of the same name as the snapshot.
+ // The functionality here (in using the ScmTag or ScmBranch) assumes that the workspace has been
+ // created as a part of the Tag Command.
+
+ String workspace = repo.getRepositoryWorkspace();
+ if ( scmVersion != null && StringUtils.isNotEmpty( scmVersion.getName() ) )
+ {
+ // Just in case we ever do something different for Tags (snapshots) and Branches (streams)
+ if ( scmVersion instanceof ScmTag )
+ {
+ workspace = scmVersion.getName();
+ }
+ else if ( scmVersion instanceof ScmBranch )
+ {
+ workspace = scmVersion.getName();
+ }
+ }
+
+ command.addArgument( workspace );
+
+ return command;
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutCommand.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,94 @@
+package org.apache.maven.scm.provider.jazz.command.checkout;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.util.ArrayList;
+import java.util.List;
+
+import org.apache.maven.scm.ScmFile;
+import org.apache.maven.scm.ScmFileStatus;
+import org.apache.maven.scm.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.provider.jazz.command.consumer.AbstractRepositoryConsumer;
+import org.apache.regexp.RE;
+import org.apache.regexp.RESyntaxException;
+
+/**
+ * Consume the output of the scm command for the "load" operation.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class JazzCheckOutConsumer
+ extends AbstractRepositoryConsumer
+{
+ private static final String DOWNLOAD_PATTERN = "^Downloading\\s(.*)\\s\\s\\(\\d.*B\\)$";
+
+ /**
+ * @see #DOWNLOAD_PATTERN
+ */
+ private RE downloadRegexp;
+
+ protected String fCurrentDir = "";
+
+ private ArrayList<ScmFile> fCheckedOutFiles = new ArrayList<ScmFile>();
+
+ /**
+ * Construct the JazzCheckOutCommand consumer.
+ * @param repository The repository we are working with.
+ * @param logger The logger to use.
+ */
+ public JazzCheckOutConsumer( ScmProviderRepository repository, ScmLogger logger )
+ {
+ super( repository, logger );
+
+ try
+ {
+ downloadRegexp = new RE( DOWNLOAD_PATTERN );
+ }
+ catch ( RESyntaxException ex )
+ {
+ throw new RuntimeException(
+ "INTERNAL ERROR: Could not create regexp to parse jazz scm checkout output. This shouldn't happen. Something is probably wrong with the oro installation.",
+ ex );
+ }
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm load" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ // Examples:
+ // Downloading /checkout-test/src/emptyFile.txt (0 B)
+ // Downloading /checkout-test/src/folder with spaces/file with spaces.java (24.0 KB)
+ if ( downloadRegexp.match( line ) )
+ {
+ fCheckedOutFiles.add( new ScmFile( downloadRegexp.getParen( 1 ), ScmFileStatus.CHECKED_OUT ) );
+ }
+ }
+
+ public List<ScmFile> getCheckedOutFiles()
+ {
+ return fCheckedOutFiles;
+ }
+
+}
\ No newline at end of file
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/checkout/JazzCheckOutConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,91 @@
+package org.apache.maven.scm.provider.jazz.command.consumer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.log.ScmLogger;
+import org.apache.maven.scm.provider.ScmProviderRepository;
+import org.apache.maven.scm.util.AbstractConsumer;
+
+/**
+ * An extension of the AbstractConsumer class that also holds our Repository.
+ */
+public abstract class AbstractRepositoryConsumer
+ extends AbstractConsumer
+{
+ // The repository that we are working with.
+ private ScmProviderRepository repository = null;
+
+ // Have we processed input?
+ protected boolean fed = false;
+
+ /**
+ * AbstractRepositoryConsumer constructor.
+ *
+ * @param logger The logger to use in the consumer
+ */
+ public AbstractRepositoryConsumer( ScmProviderRepository repository, ScmLogger logger )
+ {
+ super( logger );
+ setRepository( repository );
+ }
+
+ /**
+ * @return The repository.
+ */
+ public ScmProviderRepository getRepository()
+ {
+ return repository;
+ }
+
+ /**
+ * @param repository The repository to set.
+ */
+ public void setRepository( ScmProviderRepository repository )
+ {
+ this.repository = repository;
+ }
+
+ /**
+ * @return The fed.
+ */
+ public boolean isFed()
+ {
+ return fed;
+ }
+
+ /**
+ * @param fed The fed to set.
+ */
+ public void setFed( boolean fed )
+ {
+ this.fed = fed;
+ }
+
+ /**
+ * Process one line of output from the execution of the "scm xxxx" command.
+ * @param line The line of output from the external command that has been pumped to us.
+ * @see org.codehaus.plexus.util.cli.StreamConsumer#consumeLine(java.lang.String)
+ */
+ public void consumeLine( String line )
+ {
+ getLogger().debug( "Consumed line :" + line );
+ this.fed = true;
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/AbstractRepositoryConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,61 @@
+package org.apache.maven.scm.provider.jazz.command.consumer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.log.ScmLogger;
+
+/**
+ * This class exists only to consume output that is normally not needed,
+ * though it may be of interest when in debug mode.
+ *
+ * For example, "scm lock acquire" produces:
+ * "Locks successfully acquired."
+ * and "scm lock release" produces:
+ * "Locks successfully released."
+ *
+ * So, basically nothing of real interest to parse and pass back.
+ *
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class DebugLoggerConsumer
+ extends AbstractRepositoryConsumer
+{
+ private StringBuffer content = new StringBuffer();
+
+ private String ls = System.getProperty( "line.separator" );
+
+ public DebugLoggerConsumer( ScmLogger logger )
+ {
+ // Only ever used for debugging, so do not need the repository.
+ super( null, logger );
+ }
+
+ @Override
+ public void consumeLine( String line )
+ {
+ super.consumeLine( line );
+ content.append( line ).append( ls );
+ }
+
+ public String getOutput()
+ {
+ return content.toString();
+ }
+}
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/DebugLoggerConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java?rev=1329106&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java (added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java Mon Apr 23 07:45:33 2012
@@ -0,0 +1,52 @@
+package org.apache.maven.scm.provider.jazz.command.consumer;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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.log.ScmLogger;
+import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer;
+
+/**
+ * @author <a href="mailto:ChrisGWarp@gmail.com">Chris Graham</a>
+ */
+public class ErrorConsumer
+ extends StringStreamConsumer
+{
+ private boolean fFed = false;
+
+ private ScmLogger logger;
+
+ public ErrorConsumer(ScmLogger logger)
+ {
+ this.logger = logger;
+ }
+
+ public boolean hasBeenFed()
+ {
+ return fFed;
+ }
+
+ public void consumeLine( String line )
+ {
+ logger.debug( "ErrorConsumer.consumeLine: " + line );
+ fFed = true;
+ super.consumeLine( line );
+ }
+
+}
\ No newline at end of file
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/scm/trunk/maven-scm-providers/maven-scm-provider-jazz/src/main/java/org/apache/maven/scm/provider/jazz/command/consumer/ErrorConsumer.java
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision