You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2012/04/23 10:20:48 UTC

svn commit: r1329116 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/command/edit/ test/java/org/apache/maven/scm/provider/perforce/command/edit/

Author: olamy
Date: Mon Apr 23 08:20:47 2012
New Revision: 1329116

URL: http://svn.apache.org/viewvc?rev=1329116&view=rev
Log:
[SCM-671] Perforce provider Edit command incorrectly ignores working Directory.
Submitted by Don Walling.

Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java?rev=1329116&r1=1329115&r2=1329116&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommand.java Mon Apr 23 08:20:47 2012
@@ -100,7 +100,7 @@ public class PerforceEditCommand
             List<File> fs = files.getFileList();
             for ( int i = 0; i < fs.size(); i++ )
             {
-                File file = (File) fs.get( i );
+                File file = new File( workingDirectory, fs.get( i ).getPath() );
                 // I want to use relative paths to add files to make testing
                 // simpler.
                 // Otherwise the absolute path will be different on everyone's

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java
URL: http://svn.apache.org/viewvc/maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java?rev=1329116&r1=1329115&r2=1329116&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java (original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/edit/PerforceEditCommandTest.java Mon Apr 23 08:20:47 2012
@@ -1,68 +1,76 @@
-package org.apache.maven.scm.provider.perforce.command.edit;
-
-/*
- * 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.ScmFileSet;
-import org.apache.maven.scm.ScmTestCase;
-import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
-import org.apache.maven.scm.repository.ScmRepository;
-import org.codehaus.plexus.util.cli.Commandline;
-
-import java.io.File;
-import java.util.Arrays;
-
-/**
- * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
- * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
- * @version $Id$
- */
-public class PerforceEditCommandTest
-    extends ScmTestCase
-{
-    private static final File workingDir = new File( "." );
-
-    private static final String cmdPrefix = "p4 -d " + workingDir.getAbsolutePath();
-
-    public void testGetCommandLine()
-        throws Exception
-    {
-        testCommandLine( "scm:perforce://depot/projects/pathname", cmdPrefix + " edit foo.xml bar.xml" );
-    }
-
-    // ----------------------------------------------------------------------
-    //
-    // ----------------------------------------------------------------------
-
-    private void testCommandLine( String scmUrl, String commandLine )
-        throws Exception
-    {
-        //File workingDirectory = getTestFile( "target/perforce-edit-command-test" );
-
-        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
-        PerforceScmProviderRepository svnRepository = (PerforceScmProviderRepository) repository
-            .getProviderRepository();
-        ScmFileSet files =
-            new ScmFileSet( new File( "." ),
-                            Arrays.asList( new File[] { new File( "foo.xml" ), new File( "bar.xml" ) } ) );
-        Commandline cl = PerforceEditCommand.createCommandLine( svnRepository, workingDir, files );
-
-        assertCommandLine( commandLine, null, cl );
-    }
-}
+package org.apache.maven.scm.provider.perforce.command.edit;
+
+/*
+ * 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.ScmFileSet;
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.repository.ScmRepository;
+import org.codehaus.plexus.util.cli.Commandline;
+
+import java.io.File;
+import java.util.Arrays;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: PerforceEditCommandTest.java 660011 2008-05-25 18:31:54Z hboutemy $
+ */
+public class PerforceEditCommandTest
+    extends ScmTestCase
+{
+    private static final String cmdPrefix = "p4 -d ";
+
+    public void testGetCommandLine()
+        throws Exception
+    {
+        File workingDir = new File( "." );
+        testCommandLine( "scm:perforce://depot/projects/pathname",
+                         cmdPrefix + workingDir.getAbsolutePath() + " edit foo.xml bar.xml", workingDir );
+    }
+
+    public void testRelativeCommandLine()
+        throws Exception
+    {
+        File workingDir = new File( "baz/qux" );
+        testCommandLine( "scm:perforce://depot/projects/pathname",
+                         cmdPrefix + workingDir.getAbsolutePath() + " edit foo.xml bar.xml", workingDir );
+    }
+
+    // ----------------------------------------------------------------------
+    //
+    // ----------------------------------------------------------------------
+
+    private void testCommandLine( String scmUrl, String commandLine, File workingDir )
+        throws Exception
+    {
+        //File workingDirectory = getTestFile( "target/perforce-edit-command-test" );
+
+        ScmRepository repository = getScmManager().makeScmRepository( scmUrl );
+        PerforceScmProviderRepository svnRepository =
+            (PerforceScmProviderRepository) repository.getProviderRepository();
+        ScmFileSet files = new ScmFileSet( new File( "." ), Arrays.asList(
+            new File[]{ new File( "foo.xml" ), new File( "bar.xml" ) } ) );
+        Commandline cl = PerforceEditCommand.createCommandLine( svnRepository, workingDir, files );
+
+        assertCommandLine( commandLine, null, cl );
+    }
+
+}