maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mper...@apache.org
Subject svn commit: r431501 - in /maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src: main/java/org/apache/maven/scm/provider/perforce/ main/java/org/apache/maven/scm/provider/perforce/command/tag/ test/java/org/apache/maven/scm/provider/perfo...
Date Tue, 15 Aug 2006 03:03:15 GMT
Author: mperham
Date: Mon Aug 14 20:03:15 2006
New Revision: 431501

URL: http://svn.apache.org/viewvc?rev=431501&view=rev
Log:
PR: SCM-211
Set current Perforce user as owner of created tag

Added:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/PerforceInfoCommandTest.java
  (with props)
Modified:
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
    maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/PerforceScmProviderTest.java

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.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/PerforceScmProvider.java?rev=431501&r1=431500&r2=431501&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/PerforceScmProvider.java
Mon Aug 14 20:03:15 2006
@@ -58,6 +58,7 @@
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l </a>
+ * @author mperham
  * @version $Id$
  */
 public class PerforceScmProvider

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.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/tag/PerforceTagCommand.java?rev=431501&r1=431500&r2=431501&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/main/java/org/apache/maven/scm/provider/perforce/command/tag/PerforceTagCommand.java
Mon Aug 14 20:03:15 2006
@@ -24,6 +24,7 @@
 import org.apache.maven.scm.provider.ScmProviderRepository;
 import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
 import org.apache.maven.scm.provider.perforce.command.PerforceCommand;
+import org.apache.maven.scm.provider.perforce.command.PerforceInfoCommand;
 import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
 import org.codehaus.plexus.util.cli.CommandLineException;
 import org.codehaus.plexus.util.cli.Commandline;
@@ -157,13 +158,21 @@
     /*
      * Label: foo-label 
      * View: //depot/path/to/repos/...
+     * Owner: mperham
      */
-    public static String createLabelSpecification( PerforceScmProviderRepository repo, String
tag )
+    public String createLabelSpecification( PerforceScmProviderRepository repo, String tag
)
     {
         StringBuffer buf = new StringBuffer();
         buf.append( "Label: " ).append( tag ).append( NEWLINE );
         buf.append( "View: " ).append( PerforceScmProvider.getCanonicalRepoPath( repo.getPath()
) ).append( NEWLINE );
+        String username = repo.getUser();
+        if ( username == null )
+        {
+            // I have no idea why but Perforce doesn't default the owner to the current user.
+            // Since the user is not explicitly set, we use 'p4 info' to query for the current
user.
+            username = PerforceInfoCommand.getInfo( this, repo ).getEntry( "User name" );
+        }
+        buf.append( "Owner: " ).append( username ).append( NEWLINE );
         return buf.toString();
     }
-
-}
+}
\ No newline at end of file

Modified: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/PerforceScmProviderTest.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/PerforceScmProviderTest.java?rev=431501&r1=431500&r2=431501&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/PerforceScmProviderTest.java
(original)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/PerforceScmProviderTest.java
Mon Aug 14 20:03:15 2006
@@ -19,6 +19,13 @@
 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 org.codehaus.plexus.util.cli.CommandLineException;
+
+import java.io.OutputStream;
+import java.io.DataOutputStream;
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 
 /**
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
@@ -27,6 +34,36 @@
 public class PerforceScmProviderTest
     extends ScmTestCase
 {
+    private static Boolean live = null;
+
+    public static boolean hasClientBinaries()
+    {
+        if ( live == null )
+        {
+            try
+            {
+                Commandline command = new Commandline();
+                command.setExecutable( "p4" );
+                Process proc = command.execute();
+                BufferedReader br = new BufferedReader( new InputStreamReader( proc.getInputStream()
) );
+                String line;
+                while ( ( line = br.readLine() ) != null )
+                {
+                    //System.out.println(line);
+                }
+                int rc = proc.exitValue();
+                live = (rc == 0 ? Boolean.TRUE : Boolean.FALSE);
+            }
+            catch ( Exception e )
+            {
+                e.printStackTrace();
+                live = Boolean.FALSE;
+            }
+        }
+
+        return live.booleanValue();
+    }
+
     public void testParseConnection()
         throws Exception
     {

Added: maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/PerforceInfoCommandTest.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/PerforceInfoCommandTest.java?rev=431501&view=auto
==============================================================================
--- maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/PerforceInfoCommandTest.java
(added)
+++ maven/scm/trunk/maven-scm-providers/maven-scm-provider-perforce/src/test/java/org/apache/maven/scm/provider/perforce/command/PerforceInfoCommandTest.java
Mon Aug 14 20:03:15 2006
@@ -0,0 +1,37 @@
+package org.apache.maven.scm.provider.perforce.command;
+
+import org.apache.maven.scm.ScmTestCase;
+import org.apache.maven.scm.provider.perforce.repository.PerforceScmProviderRepository;
+import org.apache.maven.scm.provider.perforce.PerforceScmProvider;
+import org.apache.maven.scm.provider.perforce.PerforceScmProviderTest;
+import org.apache.maven.scm.provider.perforce.command.tag.PerforceTagCommand;
+import org.apache.maven.scm.repository.ScmRepository;
+
+/**
+ * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
+ * @version $Id: PerforceScmProviderTest.java 372209 2006-01-25 13:30:01Z evenisse $
+ */
+public class PerforceInfoCommandTest
+    extends ScmTestCase
+{
+    public void testPerforceInfo()
+        throws Exception
+    {
+        ScmRepository repo = makeScmRepository( "scm:perforce://depot/projects/pathname"
);
+
+        PerforceScmProviderRepository p4Repo = (PerforceScmProviderRepository) repo.getProviderRepository();
+
+        PerforceScmProvider prov = new PerforceScmProvider();
+        PerforceTagCommand cmd = new PerforceTagCommand();
+        cmd.setLogger( prov.getLogger() );
+
+        if ( PerforceScmProviderTest.hasClientBinaries() )
+        {
+            assertNotNull( PerforceInfoCommand.getInfo( cmd, p4Repo ).getEntry( "User name"
) );
+            assertNotNull( PerforceInfoCommand.getInfo( cmd, p4Repo ).getEntry( "Client root"
) );
+            assertNotNull( PerforceInfoCommand.getInfo( cmd, p4Repo ).getEntry( "Client name"
) );
+            assertNotNull( PerforceInfoCommand.getInfo( cmd, p4Repo ).getEntry( "Client host"
) );
+            assertNull( PerforceInfoCommand.getInfo( cmd, p4Repo ).getEntry( "foobar" ) );
+        }
+    }
+}

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



Mime
View raw message