Index: pom.xml =================================================================== --- pom.xml (revision 763113) +++ pom.xml (working copy) @@ -199,6 +199,11 @@ maven-scm-provider-vss 1.3-SNAPSHOT + + org.apache.maven.scm + maven-scm-provider-tfs + 1.3-SNAPSHOT + Index: maven-scm-client/pom.xml =================================================================== --- maven-scm-client/pom.xml (revision 763113) +++ maven-scm-client/pom.xml (working copy) @@ -92,6 +92,10 @@ org.apache.maven.scm maven-scm-provider-vss + + org.apache.maven.scm + maven-scm-provider-tfs + Index: maven-scm-providers/pom.xml =================================================================== --- maven-scm-providers/pom.xml (revision 763113) +++ maven-scm-providers/pom.xml (working copy) @@ -48,6 +48,7 @@ maven-scm-providers-svn maven-scm-provider-synergy maven-scm-provider-vss + maven-scm-provider-tfs Index: maven-scm-providers/maven-scm-provider-tfs/pom.xml =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/pom.xml (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/pom.xml (revision 0) @@ -0,0 +1,119 @@ + + 4.0.0 + + org.apache.maven.scm + maven-scm-providers + 1.3-SNAPSHOT + + + maven-scm-provider-tfs + + TFS SCM Provider + http://labs.teamprise.com/maven + + + + + org.codehaus.plexus + plexus-maven-plugin + + + + descriptor + + + + + + + + + + org.apache.maven.plugins + maven-surefire-report-plugin + 2.4.2 + + + org.apache.maven.plugins + maven-changes-plugin + + %URL%/wi.aspx?id=%ISSUE% + + + + + changes-report + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + + + + javadoc + + + + + + org.codehaus.mojo + cobertura-maven-plugin + + + html + xml + + + + + + + A Maven 2 SCM Provider for Microsoft Visual Studio Team Foundation Server. + + Teamprise + http://www.teamprise.com + + + Team Foundation Server + http://labs.teamprise.com/ + + + Team Foundation Server + http://labs.teamprise.com/maven + + + http://labs.teamprise.com/ + + scm:tfs:http://alpo.teamprise.com:8080::$/Labs/main/source/maven-scm-provider-tfs + + + + + martin + Martin Woodward + martin@teamprise.com + http://www.woodwardweb.com + Teamprise + http://www.teamprise.com + + developer + + 0 + + + subhashgo + Subhash Gopalakrishnan + subhash@teamprise.com + Teamprise + http://www.teamprise.com + + developer + + +5.5 + + + + \ No newline at end of file Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProvider.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProvider.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProvider.java (revision 0) @@ -0,0 +1,240 @@ +package org.apache.maven.scm.provider.tfs; + +/* + * 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.net.URI; + +import org.apache.maven.scm.CommandParameters; +import org.apache.maven.scm.ScmException; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.command.add.AddScmResult; +import org.apache.maven.scm.command.branch.BranchScmResult; +import org.apache.maven.scm.command.changelog.ChangeLogScmResult; +import org.apache.maven.scm.command.checkin.CheckInScmResult; +import org.apache.maven.scm.command.checkout.CheckOutScmResult; +import org.apache.maven.scm.command.diff.DiffScmResult; +import org.apache.maven.scm.command.edit.EditScmResult; +import org.apache.maven.scm.command.export.ExportScmResult; +import org.apache.maven.scm.command.list.ListScmResult; +import org.apache.maven.scm.command.status.StatusScmResult; +import org.apache.maven.scm.command.tag.TagScmResult; +import org.apache.maven.scm.command.unedit.UnEditScmResult; +import org.apache.maven.scm.command.update.UpdateScmResult; +import org.apache.maven.scm.provider.AbstractScmProvider; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.TfsAddCommand; +import org.apache.maven.scm.provider.tfs.command.TfsBranchCommand; +import org.apache.maven.scm.provider.tfs.command.TfsChangeLogCommand; +import org.apache.maven.scm.provider.tfs.command.TfsCheckInCommand; +import org.apache.maven.scm.provider.tfs.command.TfsCheckOutCommand; +import org.apache.maven.scm.provider.tfs.command.TfsEditCommand; +import org.apache.maven.scm.provider.tfs.command.TfsListCommand; +import org.apache.maven.scm.provider.tfs.command.TfsStatusCommand; +import org.apache.maven.scm.provider.tfs.command.TfsTagCommand; +import org.apache.maven.scm.provider.tfs.command.TfsUnEditCommand; +import org.apache.maven.scm.provider.tfs.command.TfsUpdateCommand; +import org.apache.maven.scm.repository.ScmRepositoryException; + +/** + * @plexus.component role="org.apache.maven.scm.provider.ScmProvider" role-hint="tfs" + */ +public class TfsScmProvider + extends AbstractScmProvider +{ + + public static final String TFS_URL_FORMAT = + "[[domain\\]username[;password]@]http[s]://server_name[:port]:workspace:$/TeamProject/Path/To/Project"; + + // ---------------------------------------------------------------------- + // ScmProvider Implementation + // ---------------------------------------------------------------------- + + public String getScmType() + { + return "tfs"; + } + + public ScmProviderRepository makeProviderScmRepository( String scmUrl, char delimiter ) + throws ScmRepositoryException + { + // Look for the TFS URL after any '@' delmiter used to pass + // usernames/password etc + // We deliberately look for the last '@' character as username could + // contain an '@' also. + int lastAtPos = scmUrl.lastIndexOf( '@' ); + getLogger().info( "scmUrl - " + scmUrl ); + + String tfsUrl = ( lastAtPos < 0 ) ? scmUrl : scmUrl.substring( lastAtPos + 1 ); + String usernamePassword = ( lastAtPos < 0 ) ? null : scmUrl.substring( 0, lastAtPos ); + + // Look for TFS path after the end of the TFS URL + int tfsPathPos = tfsUrl.lastIndexOf( delimiter + "$/" ); + String serverPath = "$/"; + if ( tfsPathPos > 0 ) + { + serverPath = tfsUrl.substring( tfsPathPos + 1 ); + tfsUrl = tfsUrl.substring( 0, tfsPathPos ); + } + + // Look for workspace ater the end of the TFS URL + int workspacePos = tfsUrl.lastIndexOf( delimiter ); + String workspace = tfsUrl.substring( workspacePos + 1 ); + tfsUrl = tfsUrl.substring( 0, workspacePos ); + + try + { + // Use URI's validation to determine if valid URI. + URI tfsUri = URI.create( tfsUrl ); + String scheme = tfsUri.getScheme(); + getLogger().info( "Scheme - " + scheme ); + if ( scheme == null || !( scheme.equalsIgnoreCase( "http" ) || scheme.equalsIgnoreCase( "https" ) ) ) + { + throw new ScmRepositoryException( "TFS Url \"" + tfsUrl + "\" is not a valid URL. " + + "The TFS Url syntax is " + TFS_URL_FORMAT ); + } + } + catch ( IllegalArgumentException e ) + { + throw new ScmRepositoryException( "TFS Url \"" + tfsUrl + "\" is not a valid URL. The TFS Url syntax is " + + TFS_URL_FORMAT ); + } + + String username = null; + String password = null; + + if ( usernamePassword != null ) + { + // Deliberately not using .split here in case password contains a + // ';' + int delimPos = usernamePassword.indexOf( ';' ); + username = ( delimPos < 0 ) ? usernamePassword : usernamePassword.substring( 0, delimPos ); + password = ( delimPos < 0 ) ? null : usernamePassword.substring( delimPos + 1 ); + } + + return new TfsScmProviderRepository( tfsUrl, username, password, serverPath, workspace ); + + } + + protected ChangeLogScmResult changelog( ScmProviderRepository repository, ScmFileSet fileSet, + CommandParameters parameters ) + throws ScmException + { + TfsChangeLogCommand command = new TfsChangeLogCommand(); + command.setLogger( getLogger() ); + return (ChangeLogScmResult) command.execute( repository, fileSet, parameters ); + } + + protected CheckOutScmResult checkout( ScmProviderRepository repository, ScmFileSet fileSet, + CommandParameters parameters ) + throws ScmException + { + TfsCheckOutCommand command = new TfsCheckOutCommand(); + command.setLogger( getLogger() ); + return (CheckOutScmResult) command.execute( repository, fileSet, parameters ); + } + + protected EditScmResult edit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsEditCommand command = new TfsEditCommand(); + command.setLogger( getLogger() ); + return (EditScmResult) command.execute( repository, fileSet, parameters ); + } + + protected UnEditScmResult unedit( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsUnEditCommand command = new TfsUnEditCommand(); + command.setLogger( getLogger() ); + return (UnEditScmResult) command.execute( repository, fileSet, parameters ); + } + + protected StatusScmResult status( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsStatusCommand command = new TfsStatusCommand(); + command.setLogger( getLogger() ); + return (StatusScmResult) command.execute( repository, fileSet, parameters ); + } + + protected UpdateScmResult update( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsUpdateCommand command = new TfsUpdateCommand(); + command.setLogger( getLogger() ); + return (UpdateScmResult) command.execute( repository, fileSet, parameters ); + } + + protected CheckInScmResult checkin( ScmProviderRepository repository, ScmFileSet fileSet, + CommandParameters parameters ) + throws ScmException + { + TfsCheckInCommand command = new TfsCheckInCommand(); + command.setLogger( getLogger() ); + return (CheckInScmResult) command.execute( repository, fileSet, parameters ); + } + + protected AddScmResult add( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsAddCommand command = new TfsAddCommand(); + command.setLogger( getLogger() ); + return (AddScmResult) command.execute( repository, fileSet, parameters ); + } + + protected TagScmResult tag( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsTagCommand command = new TfsTagCommand(); + command.setLogger( getLogger() ); + return (TagScmResult) command.execute( repository, fileSet, parameters ); + } + + protected BranchScmResult branch( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsBranchCommand command = new TfsBranchCommand(); + command.setLogger( getLogger() ); + return (BranchScmResult) command.execute( repository, fileSet, parameters ); + } + + protected ListScmResult list( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + TfsListCommand command = new TfsListCommand(); + command.setLogger( getLogger() ); + return (ListScmResult) command.execute( repository, fileSet, parameters ); + } + + protected DiffScmResult diff( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + // Because tf launches only external diffs + return super.diff( repository, fileSet, parameters ); + } + + protected ExportScmResult export( ScmProviderRepository repository, ScmFileSet fileSet, CommandParameters parameters ) + throws ScmException + { + // Use checkout instead + return super.export( repository, fileSet, parameters ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProviderRepository.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProviderRepository.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/TfsScmProviderRepository.java (revision 0) @@ -0,0 +1,74 @@ +package org.apache.maven.scm.provider.tfs; + +/* + * 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.provider.ScmProviderRepository; +import org.codehaus.plexus.util.StringUtils; + +public class TfsScmProviderRepository + extends ScmProviderRepository +{ + private final String tfsUrl; + + private final String serverPath; + + private final String workspace; + + public TfsScmProviderRepository( String tfsUrl, String user, String password, String serverPath, String workspace ) + { + super(); + setUser( user ); + setPassword( password ); + this.tfsUrl = tfsUrl; + this.serverPath = serverPath; + this.workspace = workspace; + } + + public String getTfsUrl() + { + return tfsUrl; + } + + public String getWorkspace() + { + return workspace; + } + + public String getServerPath() + { + return serverPath; + } + + public String getUserPassword() + { + String userPassword = null; + + if ( !StringUtils.isEmpty( getUser() ) ) + { + userPassword = getUser(); + + if ( !StringUtils.isEmpty( getPassword() ) ) + { + userPassword += ";" + getPassword(); + } + } + return userPassword; + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommand.java (revision 0) @@ -0,0 +1,54 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.add.AbstractAddCommand; +import org.apache.maven.scm.command.add.AddScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; + +public class TfsAddCommand + extends AbstractAddCommand +{ + + protected ScmResult executeAddCommand( ScmProviderRepository r, ScmFileSet f, String m, boolean b ) + throws ScmException + { + TfsCommand command = createCommand( r, f ); + FileListConsumer fileConsumer = new FileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + int status = command.execute( fileConsumer, err ); + if ( status != 0 || err.hasBeenFed() ) + return new AddScmResult( command.getCommandline(), "Error code for TFS add command - " + status, + err.getOutput(), false ); + return new AddScmResult( command.getCommandline(), fileConsumer.getFiles() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f ) + { + TfsCommand command = new TfsCommand( "add", r, f, getLogger() ); + command.addArgument( f ); + return command; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommand.java (revision 0) @@ -0,0 +1,62 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 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.command.branch.BranchScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; + +public class TfsBranchCommand + extends AbstractBranchCommand +{ + + protected ScmResult executeBranchCommand( ScmProviderRepository r, ScmFileSet f, String branch, String message ) + throws ScmException + { + TfsCommand command = createCommand( r, f, branch ); + StringStreamConsumer out = new StringStreamConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + { + return new BranchScmResult( command.getCommandline(), "Error code for TFS branch command - " + status, + err.getOutput(), false ); + } + return new BranchScmResult( command.getCommandline(), new ArrayList() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, String branch ) + { + TfsCommand command = new TfsCommand( "branch", r, f, getLogger() ); + command.addArgument( f.getBasedir().getAbsolutePath() ); + command.addArgument( "-checkin" ); + command.addArgument( branch ); + return command; + } + + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommand.java (revision 0) @@ -0,0 +1,259 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.text.DateFormat; +import java.text.ParseException; +import java.util.ArrayList; +import java.util.Date; +import java.util.Iterator; +import java.util.List; +import java.util.Locale; +import java.util.TimeZone; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.apache.maven.scm.ChangeFile; +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.log.ScmLogger; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +import org.apache.maven.scm.util.AbstractConsumer; + +public class TfsChangeLogCommand + extends AbstractChangeLogCommand +{ + + protected ChangeLogScmResult executeChangeLogCommand( ScmProviderRepository r, ScmFileSet f, Date startDate, + Date endDate, ScmBranch branch, String datePattern ) + throws ScmException + { + ArrayList changeLogs = new ArrayList(); + Iterator iter = f.getFileList().iterator(); + if ( !iter.hasNext() ) + { + ArrayList dir = new ArrayList(); + // No files to iterate + dir.add( f.getBasedir() ); + iter = dir.iterator(); + } + TfsCommand command = null; + // tf history takes only one file arg + while ( iter.hasNext() ) + { + TfsChangeLogConsumer out = new TfsChangeLogConsumer( getLogger() ); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + + command = createCommand( r, f, ( (File) iter.next() ) ); + int status = command.execute( out, err ); + + if ( status != 0 || ( !out.hasBeenFed() && err.hasBeenFed() ) ) + return new ChangeLogScmResult( command.getCommandline(), "Error code for TFS changelog command - " + + status, err.getOutput(), false ); + changeLogs.addAll( out.getLogs() ); + } + return new ChangeLogScmResult( command.getCommandline(), new ChangeLogSet( changeLogs, startDate, endDate ) ); + + } + + protected TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, File file ) + { + TfsCommand command = new TfsCommand( "history", r, f, getLogger() ); + command.addArgument( "-format:detailed" ); + command.addArgument( file.getName() ); + return command; + } +} + +class TfsChangeLogConsumer + extends AbstractConsumer +{ + + private static final String PATTERN = + "^[^:]*:[ \t]([0-9]*)\n" + "[^:]*:[ \t](.*)\n[^:]*:[ \t](.*)\n" + + "[^:]*:((?:\n.*)*)\n\n[^\n :]*:(?=\n )((?:\n[ \t]+.*)*)"; + + private static final String PATTERN_ITEM = "\n ([^$]+) (\\$/.*)"; + + ArrayList logs = new ArrayList(); + + String buffer = ""; + + boolean fed = false; + + public TfsChangeLogConsumer( ScmLogger logger ) + { + super( logger ); + } + + public void consumeLine( String line ) + { + fed = true; + if ( line.startsWith( "-----" ) ) + { + addChangeLog(); + } + buffer += line + "\n"; + } + + public List getLogs() + { + addChangeLog(); + return logs; + } + + private void addChangeLog() + { + if ( !buffer.equals( "" ) ) + { + Pattern p = Pattern.compile( PATTERN ); + Matcher m = p.matcher( buffer ); + if ( m.find() ) + { + String revision = m.group( 1 ).trim(); + String username = m.group( 2 ).trim(); + String dateString = m.group( 3 ).trim(); + String comment = m.group( 4 ).trim(); + Pattern itemPattern = Pattern.compile( PATTERN_ITEM ); + Matcher itemMatcher = itemPattern.matcher( m.group( 5 ) ); + List files = new ArrayList(); + while ( itemMatcher.find() ) + { + ChangeFile file = new ChangeFile( itemMatcher.group( 2 ).trim(), revision ); + files.add( file ); + } + Date date; + try + { + date = parseDate( dateString ); + } + catch ( ParseException e ) + { + getLogger().error( "Date parse error", e ); + throw new RuntimeException( e ); + } + + ChangeSet change = new ChangeSet( date, comment, username, files ); + logs.add( change ); + } + buffer = ""; + } + } + + public boolean hasBeenFed() + { + return fed; + } + + protected static Date parseDate( String dateString ) + throws ParseException + { + Date date = null; + try + { + // Use the depricated Date.parse method as this is very good at + // detecting + // dates commonly output by the US and UK standard locales of + // dotnet that + // are output by the Microsoft command line client. + date = new Date( Date.parse( dateString ) ); + } + catch ( IllegalArgumentException e ) + { + // ignore - parse failed. + } + if ( date == null ) + { + // The old fashioned way did not work. Let's try it using a more + // complex + // alternative. + DateFormat[] formats = createDateFormatsForLocaleAndTimeZone( null, null ); + return parseWithFormats( dateString, formats ); + } + return date; + } + + private static Date parseWithFormats( String input, DateFormat[] formats ) + throws ParseException + { + ParseException parseException = null; + for ( int i = 0; i < formats.length; i++ ) + { + try + { + return formats[i].parse( input ); + } + catch ( ParseException ex ) + { + parseException = ex; + } + } + + throw parseException; + } + + /** + * Build an array of DateFormats that are commonly used for this locale and timezone. + */ + private static DateFormat[] createDateFormatsForLocaleAndTimeZone( Locale locale, TimeZone timeZone ) + { + if ( locale == null ) + { + locale = Locale.getDefault(); + } + + if ( timeZone == null ) + { + timeZone = TimeZone.getDefault(); + } + + List formats = new ArrayList(); + + for ( int dateStyle = DateFormat.FULL; dateStyle <= DateFormat.SHORT; dateStyle++ ) + { + for ( int timeStyle = DateFormat.FULL; timeStyle <= DateFormat.SHORT; timeStyle++ ) + { + DateFormat df = DateFormat.getDateTimeInstance( dateStyle, timeStyle, locale ); + if ( timeZone != null ) + { + df.setTimeZone( timeZone ); + } + formats.add( df ); + } + } + + for ( int dateStyle = DateFormat.FULL; dateStyle <= DateFormat.SHORT; dateStyle++ ) + { + DateFormat df = DateFormat.getDateInstance( dateStyle, locale ); + df.setTimeZone( timeZone ); + formats.add( df ); + } + + return (DateFormat[]) formats.toArray( new DateFormat[formats.size()] ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommand.java (revision 0) @@ -0,0 +1,58 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmVersion; +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.tfs.command.consumer.ErrorStreamConsumer; + +public class TfsCheckInCommand + extends AbstractCheckInCommand +{ + + protected CheckInScmResult executeCheckInCommand( ScmProviderRepository r, ScmFileSet f, String m, ScmVersion v ) + throws ScmException + { + + TfsCommand command = createCommand( r, f, m ); + FileListConsumer fileConsumer = new FileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + int status = command.execute( fileConsumer, err ); + if ( status != 0 || err.hasBeenFed() ) + return new CheckInScmResult( command.getCommandline(), "Error code for TFS checkin command - " + status, + err.getOutput(), false ); + return new CheckInScmResult( command.getCommandline(), fileConsumer.getFiles() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, String m ) + { + TfsCommand command = new TfsCommand( "checkin", r, f, getLogger() ); + command.addArgument( "-noprompt" ); + if ( m != null && !m.equals( "" ) ) + command.addArgument( "-comment:" + m + "" ); + command.addArgument( f ); + return command; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommand.java (revision 0) @@ -0,0 +1,187 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmException; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; +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.tfs.TfsScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +import org.codehaus.plexus.util.cli.StreamConsumer; + +// Usage: mvn scm:checkout -DcheckoutDirectory= +public class TfsCheckOutCommand + extends AbstractCheckOutCommand +{ + + protected CheckOutScmResult executeCheckOutCommand( ScmProviderRepository r, ScmFileSet f, ScmVersion v, + boolean recursive ) + throws ScmException + { + TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; + String url = tfsRepo.getServerPath(); + String tfsUrl = tfsRepo.getTfsUrl(); + String workspace = tfsRepo.getWorkspace(); + + // Try creating workspace + boolean workspaceProvided = workspace != null && !workspace.trim().equals( "" ); + if ( workspaceProvided ) + createWorkspace( r, f, workspace, tfsUrl ); + + TfsCommand command; + int status; + + if ( workspaceProvided ) + status = executeUnmapCommand( r, f ); + + ErrorStreamConsumer out = new ErrorStreamConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + if ( workspaceProvided ) + { + command = new TfsCommand( "workfold", r, null, getLogger() ); + command.addArgument( "-workspace:" + workspace ); + command.addArgument( "-map" ); + command.addArgument( url ); + command.addArgument( f.getBasedir().getAbsolutePath() ); + status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new CheckOutScmResult( command.getCommandline(), + "Error code for TFS checkout (workfold map) command - " + status, + err.getOutput(), false ); + } + FileListConsumer fileConsumer = new FileListConsumer(); + err = new ErrorStreamConsumer(); + command = createGetCommand( r, f, v, recursive ); + status = command.execute( fileConsumer, err ); + if ( status != 0 || err.hasBeenFed() ) + return new CheckOutScmResult( command.getCommandline(), "Error code for TFS checkout (get) command - " + + status, err.getOutput(), false ); + return new CheckOutScmResult( command.getCommandline(), fileConsumer.getFiles() ); + } + + TfsCommand createGetCommand( ScmProviderRepository r, ScmFileSet f, ScmVersion v, boolean recursive ) + { + TfsCommand command = new TfsCommand( "get", r, f, getLogger() ); + if ( recursive ) + command.addArgument( "-recursive" ); + command.addArgument( "-force" ); + if ( v != null && !v.equals( "" ) ) + { + String vType = ""; + if ( v.getType().equals( "Tag" ) ) + vType = "L"; + if ( v.getType().equals( "Revision" ) ) + vType = "C"; + command.addArgument( "-version:" + vType + v.getName() ); + } + command.addArgument( f.getBasedir().getAbsolutePath() ); + return command; + } + + public int executeUnmapCommand( ScmProviderRepository r, ScmFileSet f ) + throws ScmException + { + TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; + String url = tfsRepo.getServerPath(); + String workspace = tfsRepo.getWorkspace(); + ErrorStreamConsumer out = new ErrorStreamConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + TfsCommand command = new TfsCommand( "workfold", r, null, getLogger() ); + command.addArgument( "-workspace:" + workspace ); + command.addArgument( "-unmap" ); + command.addArgument( url ); + return command.execute( out, err ); + } + + private void createWorkspace( ScmProviderRepository r, ScmFileSet f, String workspace, String url ) + throws ScmException + { + ErrorStreamConsumer out = new ErrorStreamConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + // Checkout dir may not exist yet + TfsCommand command = new TfsCommand( "workspace", r, null, getLogger() ); + command.addArgument( "-new" ); + command.addArgument( "-comment:Creating workspace for maven command" ); + command.addArgument( "-server:" + url ); + command.addArgument( workspace ); + int status = command.execute( out, err ); + } + +} + +class FileListConsumer + implements StreamConsumer +{ + + boolean fed = false; + + String currentDir = ""; + + ArrayList files = new ArrayList(); + + public void consumeLine( String line ) + { + fed = true; + if ( line.endsWith( ":" ) ) + { + currentDir = line.substring( 0, line.lastIndexOf( ':' ) ); + ScmFile scmFile = new ScmFile( currentDir, ScmFileStatus.CHECKED_OUT ); + if ( !files.contains( scmFile ) ) + files.add( scmFile ); + } + else if ( line.trim().equals( "" ) ) + { + currentDir = ""; + } + else if ( !currentDir.equals( "" ) && line.contains( " " ) ) + { + String filename = line.split( " " )[1]; + files.add( getScmFile( filename ) ); + } + else + { + files.add( getScmFile( line ) ); + } + } + + protected ScmFile getScmFile( String filename ) + { + return new ScmFile( new File( currentDir, filename ).getAbsolutePath(), ScmFileStatus.CHECKED_OUT ); + } + + public List getFiles() + { + return files; + } + + public boolean hasBeenFed() + { + return fed; + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsCommand.java (revision 0) @@ -0,0 +1,120 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 org.apache.maven.scm.ScmException; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.log.ScmLogger; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +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 org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; + +public class TfsCommand +{ + + private ScmLogger logger; + + Commandline command; + + public TfsCommand( String cmd, ScmProviderRepository r, ScmFileSet f, ScmLogger logger ) + { + command = new Commandline(); + command.setExecutable( "tf" ); + if ( f != null ) + command.setWorkingDirectory( f.getBasedir().getAbsolutePath() ); + command.createArgument().setValue( cmd ); + if ( r.getUser() != null ) + { + command.createArgument().setValue( "-login:" + r.getUser() + "," + r.getPassword() ); + } + this.logger = logger; + } + + public void addArgument( ScmFileSet f ) + { + info( "files: " + f.getBasedir().getAbsolutePath() ); + Iterator iter = f.getFileList().iterator(); + while ( iter.hasNext() ) + command.createArgument().setValue( ( (File) iter.next() ).getPath() ); + } + + public void addArgument( String s ) + { + command.createArgument().setValue( s ); + } + + public int execute( StreamConsumer out, ErrorStreamConsumer err ) + throws ScmException + { + info( "Command line - " + getCommandline() ); + int status; + try + { + status = CommandLineUtils.executeCommandLine( command, out, err ); + } + catch ( CommandLineException e ) + { + throw new ScmException( "Error while executing TFS command line - " + getCommandline(), e ); + } + info( "err - " + err.getOutput() ); + if ( out instanceof StringStreamConsumer ) + { + StringStreamConsumer sc = (StringStreamConsumer) out; + debug( sc.getOutput() ); + } + if ( out instanceof FileListConsumer ) + { + FileListConsumer f = (FileListConsumer) out; + for ( Iterator i = f.getFiles().iterator(); i.hasNext(); ) + { + ScmFile file = (ScmFile) i.next(); + debug( file.getPath() ); + } + } + + return status; + } + + public String getCommandline() + { + return command.toString(); + } + + private void info( String message ) + { + if ( logger != null ) + logger.info( message ); + } + + private void debug( String message ) + { + if ( logger != null ) + logger.debug( message ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommand.java (revision 0) @@ -0,0 +1,54 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.edit.AbstractEditCommand; +import org.apache.maven.scm.command.edit.EditScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; + +//Usage: mvn scm:edit -DworkingDirectory= -Dincludes=* +public class TfsEditCommand + extends AbstractEditCommand +{ + + protected ScmResult executeEditCommand( ScmProviderRepository r, ScmFileSet f ) + throws ScmException + { + FileListConsumer out = new FileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + TfsCommand command = createCommand( r, f ); + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new EditScmResult( command.getCommandline(), "Error code for TFS edit command - " + status, + err.getOutput(), false ); + return new EditScmResult( command.getCommandline(), out.getFiles() ); + } + + protected TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f ) + { + TfsCommand command = new TfsCommand( "checkout", r, f, getLogger() ); + command.addArgument( f ); + return command; + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsListCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsListCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsListCommand.java (revision 0) @@ -0,0 +1,70 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmFile; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmVersion; +import org.apache.maven.scm.command.list.AbstractListCommand; +import org.apache.maven.scm.command.list.ListScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; + +public class TfsListCommand + extends AbstractListCommand +{ + + protected ListScmResult executeListCommand( ScmProviderRepository r, ScmFileSet f, boolean recursive, ScmVersion v ) + throws ScmException + { + FileListConsumer out = new ServerFileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + TfsCommand command = createCommand( r, f, recursive ); + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new ListScmResult( command.getCommandline(), "Error code for TFS list command - " + status, + err.getOutput(), false ); + return new ListScmResult( command.getCommandline(), out.getFiles() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, boolean recursive ) + { + TfsCommand command = new TfsCommand( "dir", r, f, getLogger() ); + if ( recursive ) + command.addArgument( "-recursive" ); + command.addArgument( f ); + return command; + } + +} + +class ServerFileListConsumer + extends FileListConsumer +{ + protected ScmFile getScmFile( String filename ) + { + if ( filename.startsWith( "$" ) ) + filename = filename.replace( "$", "" ); + String path = currentDir + "/" + filename; + return new ScmFile( path, ScmFileStatus.UNKNOWN ); + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommand.java (revision 0) @@ -0,0 +1,156 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.HashMap; +import java.util.Iterator; +import java.util.List; + +import org.apache.maven.scm.ScmException; +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.command.status.AbstractStatusCommand; +import org.apache.maven.scm.command.status.StatusScmResult; +import org.apache.maven.scm.log.ScmLogger; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +import org.codehaus.plexus.util.cli.StreamConsumer; + +public class TfsStatusCommand + extends AbstractStatusCommand +{ + + protected StatusScmResult executeStatusCommand( ScmProviderRepository r, ScmFileSet f ) + throws ScmException + { + TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; + + TfsCommand command = createCommand( tfsRepo, f ); + ChangedFileConsumer out = new ChangedFileConsumer( getLogger() ); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new StatusScmResult( command.getCommandline(), "Error code for TFS status command - " + status, + err.getOutput(), false ); + Iterator iter = out.getChangedFiles().iterator(); + getLogger().debug( "Iterating" ); + while ( iter.hasNext() ) + { + ScmFile file = (ScmFile) iter.next(); + getLogger().debug( file.getPath() + ":" + file.getStatus() ); + } + return new StatusScmResult( command.getCommandline(), out.getChangedFiles() ); + } + + TfsCommand createCommand( TfsScmProviderRepository r, ScmFileSet f ) + { + String url = r.getServerPath(); + String workspace = r.getWorkspace(); + TfsCommand command = new TfsCommand( "status", r, f, getLogger() ); + if ( workspace != null && !workspace.trim().equals( "" ) ) + command.addArgument( "-workspace:" + workspace ); + command.addArgument( "-recursive" ); + command.addArgument( "-format:detailed" ); + command.addArgument( url ); + return command; + } +} + +class ChangedFileConsumer + implements StreamConsumer +{ + + private ScmLogger logger; + + static final String KEY_CHANGE = "Change"; + + static final String KEY_LOCAL_ITEM = "Local item"; + + static final String CHANGE_EDIT = "edit"; + + static final String CHANGE_ADD = "add"; + + HashMap values = new HashMap(); + + ArrayList changedFiles = new ArrayList(); + + public ChangedFileConsumer( ScmLogger logger ) + { + this.logger = logger; + } + + public void consumeLine( String line ) + { + if ( line.contains( ":" ) ) + { + String[] s = line.split( ":", 2 ); + if ( s.length > 1 ) + values.put( s[0].trim(), s[1].trim() ); + } + if ( line.trim().equals( "" ) ) + { + extractChangedFile(); + } + logger.debug( "line -" + line ); + } + + private void extractChangedFile() + { + String change = getChange(); + if ( change != null ) + { + ScmFileStatus stat = ScmFileStatus.UNKNOWN; + if ( change.equals( ChangedFileConsumer.CHANGE_EDIT ) ) + stat = ScmFileStatus.MODIFIED; + if ( change.equals( ChangedFileConsumer.CHANGE_ADD ) ) + stat = ScmFileStatus.ADDED; + changedFiles.add( new ScmFile( getLocalPath(), stat ) ); + values.clear(); + } + } + + public List getChangedFiles() + { + if ( values.size() > 0 ) + { + extractChangedFile(); + } + return changedFiles; + } + + private String getChange() + { + return (String) values.get( KEY_CHANGE ); + } + + private String getLocalPath() + { + String local = (String) values.get( KEY_LOCAL_ITEM ); + if ( local != null ) + { + local = local.split( "]", 2 )[1].trim(); + } + return local; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommand.java (revision 0) @@ -0,0 +1,77 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmTagParameters; +import org.apache.maven.scm.command.tag.AbstractTagCommand; +import org.apache.maven.scm.command.tag.TagScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; +import org.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; + +public class TfsTagCommand + extends AbstractTagCommand +{ + + protected ScmResult executeTagCommand( ScmProviderRepository r, ScmFileSet f, String tag, String message ) + throws ScmException + { + return executeTagCommand( r, f, tag, new ScmTagParameters( message ) ); + } + + protected ScmResult executeTagCommand( ScmProviderRepository r, ScmFileSet f, String tag, + ScmTagParameters scmTagParameters ) + throws ScmException + { + TfsCommand command = createCommand( r, f, tag, scmTagParameters ); + + StringStreamConsumer out = new StringStreamConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new TagScmResult( command.getCommandline(), "Error code for TFS label command - " + status, + err.getOutput(), false ); + return new TagScmResult( command.getCommandline(), f.getFileList() ); + + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, String tag, + ScmTagParameters scmTagParameters ) + { + TfsScmProviderRepository tfsRepo = (TfsScmProviderRepository) r; + String url = tfsRepo.getServerPath(); + + TfsCommand command = new TfsCommand( "label", r, f, getLogger() ); + command.addArgument( tag ); + command.addArgument( url ); + command.addArgument( "-recursive" ); + command.addArgument( "-child:replace" ); + String message = scmTagParameters.getMessage(); + if ( message != null && !message.equals( "" ) ) + command.addArgument( "-comment:" + message ); + return command; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommand.java (revision 0) @@ -0,0 +1,54 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.unedit.AbstractUnEditCommand; +import org.apache.maven.scm.command.unedit.UnEditScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; + +// Usage: mvn scm:unedit -DworkingDirectory= -Dincludes=* +public class TfsUnEditCommand + extends AbstractUnEditCommand +{ + + protected ScmResult executeUnEditCommand( ScmProviderRepository r, ScmFileSet f ) + throws ScmException + { + FileListConsumer out = new FileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + TfsCommand command = createCommand( r, f ); + int status = command.execute( out, err ); + if ( status != 0 || err.hasBeenFed() ) + return new UnEditScmResult( command.getCommandline(), "Error code for TFS unedit command - " + status, + err.getOutput(), false ); + return new UnEditScmResult( command.getCommandline(), out.getFiles() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f ) + { + TfsCommand command = new TfsCommand( "undo", r, f, getLogger() ); + command.addArgument( f ); + return command; + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommand.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommand.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommand.java (revision 0) @@ -0,0 +1,73 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmVersion; +import org.apache.maven.scm.command.changelog.ChangeLogCommand; +import org.apache.maven.scm.command.update.AbstractUpdateCommand; +import org.apache.maven.scm.command.update.UpdateScmResult; +import org.apache.maven.scm.provider.ScmProviderRepository; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.apache.maven.scm.provider.tfs.command.consumer.ErrorStreamConsumer; + +public class TfsUpdateCommand + extends AbstractUpdateCommand +{ + + protected UpdateScmResult executeUpdateCommand( ScmProviderRepository r, ScmFileSet f, ScmVersion v ) + throws ScmException + { + FileListConsumer fileConsumer = new FileListConsumer(); + ErrorStreamConsumer err = new ErrorStreamConsumer(); + TfsCommand command = createCommand( r, f, v ); + int status = command.execute( fileConsumer, err ); + if ( status != 0 || err.hasBeenFed() ) + return new UpdateScmResult( command.getCommandline(), "Error code for TFS update command - " + status, + err.getOutput(), false ); + return new UpdateScmResult( command.getCommandline(), fileConsumer.getFiles() ); + } + + TfsCommand createCommand( ScmProviderRepository r, ScmFileSet f, ScmVersion v ) + { + String serverPath = ( (TfsScmProviderRepository) r ).getServerPath(); + TfsCommand command = new TfsCommand( "get", r, f, getLogger() ); + command.addArgument( serverPath ); + if ( v != null && !v.equals( "" ) ) + { + String vType = ""; + if ( v.getType().equals( "Tag" ) ) + vType = "L"; + if ( v.getType().equals( "Revision" ) ) + vType = "C"; + command.addArgument( "-version:" + vType + v.getName() ); + } + return command; + } + + protected ChangeLogCommand getChangeLogCommand() + { + TfsChangeLogCommand changeLogCommand = new TfsChangeLogCommand(); + changeLogCommand.setLogger( getLogger() ); + return changeLogCommand; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/consumer/ErrorStreamConsumer.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/consumer/ErrorStreamConsumer.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/main/java/org/apache/maven/scm/provider/tfs/command/consumer/ErrorStreamConsumer.java (revision 0) @@ -0,0 +1,41 @@ +package org.apache.maven.scm.provider.tfs.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.codehaus.plexus.util.cli.CommandLineUtils.StringStreamConsumer; + +public class ErrorStreamConsumer + extends StringStreamConsumer +{ + + private boolean fed = false; + + public void consumeLine( String line ) + { + fed = true; + super.consumeLine( line ); + } + + public boolean hasBeenFed() + { + return fed; + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsAddCommandTest.java (revision 0) @@ -0,0 +1,37 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsAddCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsAddCommand().createCommand( repo, getScmFileSet() ).command; + String expected = "tf add -login:user,password " + getFileList(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsBranchCommandTest.java (revision 0) @@ -0,0 +1,38 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsBranchCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsBranchCommand().createCommand( repo, getScmFileSet(), "branch" ).command; + String path = getScmFileSet().getBasedir().getAbsolutePath(); + String expected = "tf branch -login:user,password " + path + " -checkin branch"; + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsChangeLogCommandTest.java (revision 0) @@ -0,0 +1,104 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsChangeLogCommandTest + extends TfsCommandTest +{ + + private FileListConsumer consumer; + + protected void setUp() + throws Exception + { + super.setUp(); + consumer = new FileListConsumer(); + } + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + File f = new File( "file" ); + Commandline cmd = new TfsChangeLogCommand().createCommand( repo, getScmFileSet(), f ).command; + String expected = "tf history -login:user,password -format:detailed " + f.getName(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + public void testCommand() + { + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing .tpattributes" ); + consumer.consumeLine( "Replacing .classpath" ); + consumer.consumeLine( "Replacing .myclasspath" ); + consumer.consumeLine( "Replacing .project" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing .tpignore" ); + consumer.consumeLine( "Replacing about.html" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing build.properties" ); + consumer.consumeLine( "Replacing customBuildCallbacks.xml" ); + consumer.consumeLine( "" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 11, consumer.getFiles().size() ); + assertTrue( consumer.getFiles().contains( new ScmFile( "C:\\temp\\maven\\c8", ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( "C:\\temp\\maven\\c8\\build.properties", + ScmFileStatus.CHECKED_OUT ) ) ); + } + + public void testMSCommand() + { + consumer.consumeLine( "c:\\temp\\maven:" ); + consumer.consumeLine( "Replacing c10" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "c:\\temp\\maven\\c10:" ); + consumer.consumeLine( "Replacing .classpath" ); + consumer.consumeLine( "Replacing .myclasspath" ); + consumer.consumeLine( "Replacing .project" ); + consumer.consumeLine( "Replacing .settings" ); + consumer.consumeLine( "Replacing .tpattributes" ); + consumer.consumeLine( "Replacing .tpignore" ); + consumer.consumeLine( "Replacing about.html" ); + consumer.consumeLine( "Replacing bin" ); + consumer.consumeLine( "Replacing build.properties" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 11, consumer.getFiles().size() ); + assertTrue( consumer.getFiles().contains( new ScmFile( "c:\\temp\\maven", ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( "c:\\temp\\maven\\c10\\build.properties", + ScmFileStatus.CHECKED_OUT ) ) ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckInCommandTest.java (revision 0) @@ -0,0 +1,40 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsCheckInCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = + new TfsCheckInCommand().createCommand( repo, getScmFileSet(), "A comment of many words" ).command; + String expected = + "tf checkin -login:user,password -noprompt -comment:\"A comment of many words\" " + getFileList(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCheckOutCommandTest.java (revision 0) @@ -0,0 +1,106 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmRevision; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsCheckOutCommandTest + extends TfsCommandTest +{ + + private FileListConsumer consumer; + + protected void setUp() + throws Exception + { + super.setUp(); + consumer = new FileListConsumer(); + } + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + ScmRevision rev = new ScmRevision( "revision" ); + String path = getScmFileSet().getBasedir().getAbsolutePath(); + Commandline cmd = new TfsCheckOutCommand().createGetCommand( repo, getScmFileSet(), rev, true ).command; + String expected = "tf get -login:user,password -recursive -force -version:Crevision " + path; + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + public void testCommand() + { + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing .tpattributes" ); + consumer.consumeLine( "Replacing .classpath" ); + consumer.consumeLine( "Replacing .myclasspath" ); + consumer.consumeLine( "Replacing .project" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8\\.settings:" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing .tpignore" ); + consumer.consumeLine( "Replacing about.html" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8\\bin:" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "C:\\temp\\maven\\c8:" ); + consumer.consumeLine( "Replacing build.properties" ); + consumer.consumeLine( "Replacing customBuildCallbacks.xml" ); + consumer.consumeLine( "" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 11, consumer.getFiles().size() ); + assertTrue( consumer.getFiles().contains( new ScmFile( "C:\\temp\\maven\\c8", ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( "C:\\temp\\maven\\c8\\build.properties", + ScmFileStatus.CHECKED_OUT ) ) ); + } + + public void testMSCommand() + { + consumer.consumeLine( "c:\\temp\\maven:" ); + consumer.consumeLine( "Replacing c10" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "c:\\temp\\maven\\c10:" ); + consumer.consumeLine( "Replacing .classpath" ); + consumer.consumeLine( "Replacing .myclasspath" ); + consumer.consumeLine( "Replacing .project" ); + consumer.consumeLine( "Replacing .settings" ); + consumer.consumeLine( "Replacing .tpattributes" ); + consumer.consumeLine( "Replacing .tpignore" ); + consumer.consumeLine( "Replacing about.html" ); + consumer.consumeLine( "Replacing bin" ); + consumer.consumeLine( "Replacing build.properties" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 11, consumer.getFiles().size() ); + assertTrue( consumer.getFiles().contains( new ScmFile( "c:\\temp\\maven", ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( "c:\\temp\\maven\\c10\\build.properties", + ScmFileStatus.CHECKED_OUT ) ) ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsCommandTest.java (revision 0) @@ -0,0 +1,59 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 org.apache.maven.scm.ScmFileSet; +import org.apache.maven.scm.ScmTestCase; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; + +public class TfsCommandTest + extends ScmTestCase +{ + + protected TfsScmProviderRepository getScmProviderRepository() + { + return new TfsScmProviderRepository( "http://tfsurl", "user", "password", "serverpath", "workspace" ); + } + + protected String getFileList() + { + String path = ""; + for ( Iterator i = getScmFileSet().getFileList().iterator(); i.hasNext(); ) + { + File f = (File) i.next(); + path += f.getName() + " "; + } + return path.trim(); + } + + protected ScmFileSet getScmFileSet() + { + return new ScmFileSet( new File( "c:\basedir" ), new File( "file" ) ); + } + + public void testFileList() + { + assertTrue( getScmFileSet().getFileList().size() > 0 ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsEditCommandTest.java (revision 0) @@ -0,0 +1,70 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.Iterator; + +import junit.framework.TestCase; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.ScmTagParameters; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsEditCommandTest + extends TfsCommandTest +{ + + private FileListConsumer consumer; + + protected void setUp() + throws Exception + { + super.setUp(); + consumer = new FileListConsumer(); + } + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsEditCommand().createCommand( repo, getScmFileSet() ).command; + String expected = + "tf checkout -login:user,password " + getFileList(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + public void testCommand() + { + consumer.consumeLine( ".classpath" ); + consumer.consumeLine( ".project" ); + consumer.consumeLine( "build.properties" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "META-INF:" ); + consumer.consumeLine( "MANIFEST.MF" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "src\\pluginp:" ); + consumer.consumeLine( "Activator.java" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 7, consumer.getFiles().size() ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsListCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsListCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsListCommandTest.java (revision 0) @@ -0,0 +1,84 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 junit.framework.TestCase; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsListCommandTest + extends TfsCommandTest +{ + + private ServerFileListConsumer consumer; + + protected void setUp() + throws Exception + { + super.setUp(); + consumer = new ServerFileListConsumer(); + } + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsListCommand().createCommand( repo, getScmFileSet(), true ).command; + String expected = "tf dir -login:user,password -recursive " + getFileList(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + public void testMSCommand() + { + consumer.consumeLine( "$/junk/com.teamprise.core/libs/xstream-1.1.3/lib:" ); + consumer.consumeLine( "xpp3-1.1.3.4d_b4_min.jar" ); + consumer.consumeLine( "xpp3-license.txt" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/com.teamprise.core/messages:" ); + consumer.consumeLine( "$com" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/com.teamprise.core/messages/com:" ); + consumer.consumeLine( "$teamprise" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/com.teamprise.core/messages/com/teamprise:" ); + consumer.consumeLine( "$core" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/com.teamprise.core/messages/com/teamprise/core:" ); + consumer.consumeLine( "$pguidance" ); + consumer.consumeLine( "$workitem" ); + + assertNotNull( consumer.getFiles() ); + assertEquals( 9, consumer.getFiles().size() ); + assertTrue( consumer.getFiles().contains( + new ScmFile( + "$/junk/com.teamprise.core/libs/xstream-1.1.3/lib/xpp3-license.txt", + ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( "$/junk/com.teamprise.core/messages/com", + ScmFileStatus.CHECKED_OUT ) ) ); + assertTrue( consumer.getFiles().contains( + new ScmFile( + "$/junk/com.teamprise.core/messages/com/teamprise/core/pguidance", + ScmFileStatus.CHECKED_OUT ) ) ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsStatusCommandTest.java (revision 0) @@ -0,0 +1,135 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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 java.util.Locale; + +import org.apache.maven.scm.ScmFile; +import org.apache.maven.scm.ScmFileStatus; +import org.apache.maven.scm.log.DefaultLog; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsStatusCommandTest + extends TfsCommandTest +{ + + private ChangedFileConsumer consumer; + + private Locale defaultLocale; + + protected void setUp() + throws Exception + { + super.setUp(); + consumer = new ChangedFileConsumer( new DefaultLog() ); + defaultLocale = Locale.getDefault(); + } + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsStatusCommand().createCommand( repo, getScmFileSet() ).command; + String expected = + "tf status -login:user,password -workspace:workspace -recursive -format:detailed " + repo.getServerPath(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + + protected void tearDown() + throws Exception + { + Locale.setDefault( defaultLocale ); + } + + public void testCommand() + { + consumer.consumeLine( "$/junk/pluginp/.classpath;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.classpath" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/pluginp/.project;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.project" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/pluginp/build.properties;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\build.properties" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/pluginp/META-INF/MANIFEST.MF;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: Mar 12, 2009 2:18:31 AM" ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\META-INF\\MANIFEST.MF" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + + List changedFiles = consumer.getChangedFiles(); + assertNotNull( changedFiles ); + assertEquals( 4, changedFiles.size() ); + assertTrue( changedFiles.contains( new ScmFile( "C:\\temp\\maven\\c4\\.classpath", ScmFileStatus.MODIFIED ) ) ); + assertTrue( changedFiles.contains( new ScmFile( "C:\\temp\\maven\\c4\\META-INF\\MANIFEST.MF", + ScmFileStatus.MODIFIED ) ) ); + } + + public void testLocale() + { + Locale.setDefault( Locale.GERMAN ); + String date = "12.03.2009 02:18:31"; + consumer.consumeLine( "$/junk/pluginp/.classpath;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: " + date ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.classpath" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + consumer.consumeLine( "$/junk/pluginp/.project;C1858" ); + consumer.consumeLine( " User: CDESG\\subhash" ); + consumer.consumeLine( " Date: " + date ); + consumer.consumeLine( " Lock: none" ); + consumer.consumeLine( " Change: edit" ); + consumer.consumeLine( " Workspace: purinaTest" ); + consumer.consumeLine( " Local item: [SUBHASH-PC] C:\\temp\\maven\\c4\\.project" ); + consumer.consumeLine( " File type: windows-1252" ); + consumer.consumeLine( "" ); + List changedFiles = consumer.getChangedFiles(); + assertNotNull( changedFiles ); + assertEquals( 2, changedFiles.size() ); + } +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsTagCommandTest.java (revision 0) @@ -0,0 +1,41 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmTagParameters; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsTagCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + ScmTagParameters param = new ScmTagParameters( "Message of many words" ); + Commandline cmd = new TfsTagCommand().createCommand( repo, getScmFileSet(), "tag", param ).command; + String expected = + "tf label -login:user,password tag " + repo.getServerPath() + + " -recursive -child:replace -comment:\"Message of many words\""; + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUnEditCommandTest.java (revision 0) @@ -0,0 +1,37 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsUnEditCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + Commandline cmd = new TfsUnEditCommand().createCommand( repo, getScmFileSet() ).command; + String expected = "tf undo -login:user,password " + getFileList(); + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + +} Index: maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommandTest.java =================================================================== --- maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommandTest.java (revision 0) +++ maven-scm-providers/maven-scm-provider-tfs/src/test/java/org/apache/maven/scm/provider/tfs/command/TfsUpdateCommandTest.java (revision 0) @@ -0,0 +1,40 @@ +package org.apache.maven.scm.provider.tfs.command; + +/* + * 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.ScmRevision; +import org.apache.maven.scm.provider.tfs.TfsScmProviderRepository; +import org.codehaus.plexus.util.cli.Commandline; + +public class TfsUpdateCommandTest + extends TfsCommandTest +{ + + public void testCommandline() + { + TfsScmProviderRepository repo = getScmProviderRepository(); + ScmRevision rev = new ScmRevision( "revision" ); + Commandline cmd = new TfsUpdateCommand().createCommand( repo, getScmFileSet(), rev ).command; + String path = repo.getServerPath(); + String expected = "tf get -login:user,password " + path + " -version:Crevision"; + assertCommandLine( expected, getWorkingDirectory(), cmd ); + } + +} Index: maven-scm-providers/maven-scm-providers-standard/pom.xml =================================================================== --- maven-scm-providers/maven-scm-providers-standard/pom.xml (revision 763113) +++ maven-scm-providers/maven-scm-providers-standard/pom.xml (working copy) @@ -94,5 +94,10 @@ maven-scm-provider-vss runtime + + org.apache.maven.scm + maven-scm-provider-tfs + runtime +