maven-scm-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From eveni...@apache.org
Subject svn commit: r380685 - in /maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm: ./ command/add/ command/changelog/ command/checkin/ command/checkout/ command/diff/ command/edit/ command/remove/ command/status/ command/tag/ command/unedit/ c...
Date Fri, 24 Feb 2006 15:18:06 GMT
Author: evenisse
Date: Fri Feb 24 07:18:00 2006
New Revision: 380685

URL: http://svn.apache.org/viewcvs?rev=380685&view=rev
Log:
[SCM-19] Resolve file status ambiguities + ScmResult copy constructor
Submitted by Torbjorn EIkli Smorgrav

Modified:
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java
    maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java (original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmFileStatus.java Fri
Feb 24 07:18:00 2006
@@ -17,52 +17,116 @@
  */
 
 /**
+ * Typesafe enum for file status
+ *
+ * There are two types of status defined in this class: <br>
+ * 1) Status: Changes in the working tree, not yet committed to the repository eg. MODIFIED
<br>
+ * 2) Transaction: The file is part of some transaction with the repository eg. CHECKED_IN
<br>
+ *
  * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>
  * @version $Id$
  */
 public final class ScmFileStatus
 {
+    /** File is added to the working tree and does not yet exist in the repository */
     public final static ScmFileStatus ADDED = new ScmFileStatus( "added" );
 
+    /**
+     * File is removed from the working tree thus not revisioned anymore.<br>
+     * The file is still present in the repository.<br>
+     * The file could be deleted from the filesystem depending on the provider.
+     */
     public final static ScmFileStatus DELETED = new ScmFileStatus( "deleted" );
 
+    /**
+     * The file has been modified in the working tree.
+     */
+    public static final ScmFileStatus MODIFIED = new ScmFileStatus( "modified" );
+
+    /** File from working tree is checked into the repository */
     public final static ScmFileStatus CHECKED_IN = new ScmFileStatus( "checked-in" );
 
+    /** File is checked out from the repository and into the working tree */
     public final static ScmFileStatus CHECKED_OUT = new ScmFileStatus( "checked-out" );
 
+    /**
+     * The file in the working tree has differences to the one in repository that
+     * conflicts ie. it cannot automatically be merged.
+     */
     public final static ScmFileStatus CONFLICT = new ScmFileStatus( "conflict" );
 
+    /**
+     * The file in the working tree has been updated with changes from the repository.
+     */
     public final static ScmFileStatus PATCHED = new ScmFileStatus( "patched" );
 
+    /**
+     * The file is added, removed or updated from the repository, thus its
+     * up-to-date with the version in the repository. See also isUpdate()
+     */
     public final static ScmFileStatus UPDATED = new ScmFileStatus( "updated" );
 
+    /** The file is part of a tag */
     public static final ScmFileStatus TAGGED = new ScmFileStatus( "tagged" );
 
-    public static final ScmFileStatus MODIFIED = new ScmFileStatus( "modified" );
-
     public static final ScmFileStatus LOCKED = new ScmFileStatus( "locked" );
 
+    /**
+     * The file is in the working tree but is not versioned and not ignored either.
+     */
     public static final ScmFileStatus UNKNOWN = new ScmFileStatus( "unknown" );
 
-    private String name;
+    private final String name;
 
     private ScmFileStatus( String name )
     {
         this.name = name;
     }
 
-    public boolean equals( Object o )
+    public String toString()
+    {
+        return name;
+    }
+
+    /**
+     * There are changes in the working tree that are not committed to the repository, or
<br>
+     * the file is unknown for the working tree.
+     *
+     * @return true on changes in the working tree or if the file is unknown.
+     */
+    public boolean isStatus()
     {
-        if ( !( o instanceof ScmFileStatus ) )
-        {
-            return false;
-        }
+        return this == UNKNOWN || isDiff();
+    }
 
-        return ( (ScmFileStatus) o ).name.equals( name );
+    /**
+     * There are changes in the working tree that are not committed to the repository. <br>
+     *
+     * @return true on changes in the working tree
+     */
+    public boolean isDiff()
+    {
+        return this == ADDED || this == DELETED || this == MODIFIED;
     }
 
-    public String toString()
+    /**
+     * @return true if the file was part of a transaction with the repository.
+     */
+    public boolean isTransaction()
     {
-        return name;
+        return this == CHECKED_IN || this == CHECKED_OUT || this == LOCKED
+        || this == TAGGED || isUpdate();
+    }
+
+    /**
+     * File is part of an update transaction with the repository.<br>
+     * Note: ADDED and REMOVED are not an update status since they indicates
+     * that the working tree has changed.<br>
+     * An update indicates the opposite, that the repository was changed compared to
+     * the working tree and that it is now synchronized unless there are conflicts.
+     */
+    public boolean isUpdate()
+    {
+        return this == CONFLICT || this == UPDATED || this == PATCHED;
     }
 }

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java (original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/ScmResult.java Fri Feb
24 07:18:00 2006
@@ -22,27 +22,33 @@
  */
 public class ScmResult
 {
-    private boolean success;
+    private final boolean success;
 
-    private String providerMessage;
+    private final String providerMessage;
 
-    private String commandOutput;
+    private final String commandOutput;
 
-    private String commandLine;
+    private final String commandLine;
 
     /**
-     * @deprecated
+     * Copy constructor.
+     *
+     * Typically used from derived classes when wrapping a ScmResult
+     * into a spesific type eg. AddAcmResult
      */
-    public static class Failure
-        extends ScmResult
+    public ScmResult( ScmResult scmResult )
     {
-        public Failure()
-        {
-            super( null, null, null, false );
-        }
+        this.commandLine = scmResult.commandLine;
+
+        this.providerMessage = scmResult.providerMessage;
+
+        this.commandOutput = scmResult.commandOutput;
+
+        this.success = scmResult.success;
     }
 
-    public ScmResult( String commandLine, String providerMessage, String commandOutput, boolean
success )
+    public ScmResult( String commandLine, String providerMessage,
+                      String commandOutput, boolean success )
     {
         this.commandLine = commandLine;
 
@@ -58,36 +64,29 @@
         return success;
     }
 
+    /**
+     * @return A message from the provider. On success this would typically be null or
+     *  an empty string. On failure it would be the error message from the provider
+     */
     public String getProviderMessage()
     {
         return providerMessage;
     }
 
-    public String getCommandOutput()
-    {
-        return commandOutput;
-    }
-
-    public String getCommandLine()
-    {
-        return commandLine;
-    }
-
     /**
-     * @return
-     * @deprecated
+     * @return Output from Std.Out from the provider during execution
+     *  of the command that resulted in this
      */
-    public String getMessage()
+    public String getCommandOutput()
     {
-        return providerMessage;
+        return commandOutput;
     }
 
     /**
-     * @return
-     * @deprecated
+     * @return The actual provider specific command that resulted in this
      */
-    public String getLongMessage()
+    public String getCommandLine()
     {
-        return commandOutput;
+        return commandLine;
     }
 }

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/add/AddScmResult.java
Fri Feb 24 07:18:00 2006
@@ -41,6 +41,13 @@
         this.addedFiles = addedFiles;
     }
 
+    public AddScmResult(List addedFiles, ScmResult result)
+    {
+        super(result);
+
+        this.addedFiles = addedFiles;
+    }
+
     public List getAddedFiles()
     {
         return addedFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/changelog/ChangeLogScmResult.java
Fri Feb 24 07:18:00 2006
@@ -39,6 +39,13 @@
         this.changeLog = changeLog;
     }
 
+    public ChangeLogScmResult(ChangeLogSet changeLog, ScmResult result)
+    {
+        super(result);
+
+        this.changeLog = changeLog;
+    }
+
     public ChangeLogSet getChangeLog()
     {
         return changeLog;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkin/CheckInScmResult.java
Fri Feb 24 07:18:00 2006
@@ -42,6 +42,13 @@
         this.checkedInFiles = checkedInFiles;
     }
 
+    public CheckInScmResult(List checkedInFiles, ScmResult result)
+    {
+    	super(result);
+
+    	this.checkedInFiles = checkedInFiles;
+    }
+
     public List getCheckedInFiles()
     {
         return checkedInFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/checkout/CheckOutScmResult.java
Fri Feb 24 07:18:00 2006
@@ -42,6 +42,13 @@
         this.checkedOutFiles = checkedOutFiles;
     }
 
+    public CheckOutScmResult(List checkedOutFiles, ScmResult result)
+    {
+    	super(result);
+
+    	this.checkedOutFiles = checkedOutFiles;
+    }
+
     public List getCheckedOutFiles()
     {
         return checkedOutFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/diff/DiffScmResult.java
Fri Feb 24 07:18:00 2006
@@ -47,6 +47,17 @@
         super( commandLine, providerMessage, commandOutput, success );
     }
 
+    public DiffScmResult(List changedFiles, Map differences, String patch, ScmResult result)
+    {
+    	super(result);
+
+    	this.changedFiles = changedFiles;
+
+    	this.differences = differences;
+
+    	this.patch = patch;
+    }
+
     public List getChangedFiles()
     {
         return changedFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/edit/EditScmResult.java
Fri Feb 24 07:18:00 2006
@@ -20,9 +20,6 @@
 
 import java.util.List;
 
-/**
- * 
- */
 public class EditScmResult
     extends ScmResult
 {
@@ -36,6 +33,13 @@
     public EditScmResult( String commandLine, List editFiles )
     {
         super( commandLine, null, null, true );
+
+        this.editFiles = editFiles;
+    }
+
+    public EditScmResult(List editFiles, ScmResult result)
+    {
+        super(result);
 
         this.editFiles = editFiles;
     }

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/remove/RemoveScmResult.java
Fri Feb 24 07:18:00 2006
@@ -41,6 +41,13 @@
         this.removedFiles = removedFiles;
     }
 
+    public RemoveScmResult(List removedFiles, ScmResult result)
+    {
+    	super(result);
+
+    	this.removedFiles = removedFiles;
+    }
+
     public List getRemovedFiles()
     {
         return removedFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/status/StatusScmResult.java
Fri Feb 24 07:18:00 2006
@@ -41,6 +41,13 @@
         this.changedFiles = changedFiles;
     }
 
+    public StatusScmResult(List changedFiles, ScmResult result)
+    {
+    	super(result);
+
+    	this.changedFiles = changedFiles;
+    }
+
     public List getChangedFiles()
     {
         return changedFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/tag/TagScmResult.java
Fri Feb 24 07:18:00 2006
@@ -41,6 +41,13 @@
         this.taggedFiles = taggedFiles;
     }
 
+    public TagScmResult( List taggedFiles, ScmResult result )
+    {
+        super( result );
+
+        this.taggedFiles = taggedFiles;
+    }
+
     public List getTaggedFiles()
     {
         return taggedFiles;

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/unedit/UnEditScmResult.java
Fri Feb 24 07:18:00 2006
@@ -20,9 +20,6 @@
 
 import java.util.List;
 
-/**
- * 
- */
 public class UnEditScmResult
     extends ScmResult
 {
@@ -36,6 +33,13 @@
     public UnEditScmResult( String commandLine, List unEditFiles )
     {
         super( commandLine, null, null, true );
+
+        this.unEditFiles = unEditFiles;
+    }
+
+    public UnEditScmResult( List unEditFiles, ScmResult result )
+    {
+        super( result );
 
         this.unEditFiles = unEditFiles;
     }

Modified: maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java
URL: http://svn.apache.org/viewcvs/maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java?rev=380685&r1=380684&r2=380685&view=diff
==============================================================================
--- maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java
(original)
+++ maven/scm/trunk/maven-scm-api/src/main/java/org/apache/maven/scm/command/update/UpdateScmResult.java
Fri Feb 24 07:18:00 2006
@@ -43,6 +43,15 @@
         this.updatedFiles = updatedFiles;
     }
 
+    public UpdateScmResult( List updatedFiles, List changes, ScmResult result )
+    {
+        super( result );
+
+        this.updatedFiles = updatedFiles;
+
+        this.changes = changes;
+    }
+
     public List getUpdatedFiles()
     {
         return updatedFiles;



Mime
View raw message