001package org.apache.maven.scm;002003/*004 * Licensed to the Apache Software Foundation (ASF) under one005 * or more contributor license agreements. See the NOTICE file006 * distributed with this work for additional information007 * regarding copyright ownership. The ASF licenses this file008 * to you under the Apache License, Version 2.0 (the009 * "License"); you may not use this file except in compliance010 * with the License. You may obtain a copy of the License at011 *012 * http://www.apache.org/licenses/LICENSE-2.0013 *014 * Unless required by applicable law or agreed to in writing,015 * software distributed under the License is distributed on an016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY017 * KIND, either express or implied. See the License for the018 * specific language governing permissions and limitations019 * under the License.020 */021022import java.io.Serializable;023024/**025 * @TODO move to a real enum026 * <p/>027 * Typesafe enum for file status028 * </p>029 * <p/>030 * There are two types of status defined in this class: <br/>031 * 1) Status: Changes in the working tree, not yet committed to the repository eg. MODIFIED <br/>032 * 2) Transaction: The file is part of some transaction with the repository eg. CHECKED_IN033 * </p>034 *035 * @author <a href="mailto:trygvis@inamo.no">Trygve Laugst&oslash;l</a>036 *037 */038public final class ScmFileStatus039 implements Serializable040{041 private static final long serialVersionUID = -7840223279162817915L;042043 /**044 * File is added to the working tree and does not yet exist in the repository045 */046 public static final ScmFileStatus ADDED = new ScmFileStatus( "added" );047048 /**049 * File is removed from the working tree thus not revisioned anymore.<br>050 * The file is still present in the repository.<br>051 * The file could be deleted from the filesystem depending on the provider.052 */053 public static final ScmFileStatus DELETED = new ScmFileStatus( "deleted" );054055 /**056 * The file has been modified in the working tree.057 */058 public static final ScmFileStatus MODIFIED = new ScmFileStatus( "modified" );059060 /**061 * The file has been renamed or moved in the working tree.062 * @since 1.7063 */064 public static final ScmFileStatus RENAMED = new ScmFileStatus( "renamed" );065066 /**067 * The file has been copied in the working tree.068 * @since 1.7069 */070 public static final ScmFileStatus COPIED = new ScmFileStatus( "copied" );071072 /**073 * The file is missing in the working tree.074 */075 public static final ScmFileStatus MISSING = new ScmFileStatus( "missing" );076077 /**078 * File from working tree is checked into the repository079 */080 public static final ScmFileStatus CHECKED_IN = new ScmFileStatus( "checked-in" );081082 /**083 * File is checked out from the repository and into the working tree084 */085 public static final ScmFileStatus CHECKED_OUT = new ScmFileStatus( "checked-out" );086087 /**088 * The file in the working tree has differences to the one in repository that089 * conflicts ie. it cannot automatically be merged.090 */091 public static final ScmFileStatus CONFLICT = new ScmFileStatus( "conflict" );092093 /**094 * The file in the working tree has been updated with changes from the repository.095 */096 public static final ScmFileStatus PATCHED = new ScmFileStatus( "patched" );097098 /**099 * The file is added, removed or updated from the repository, thus its100 * up-to-date with the version in the repository. See also isUpdate()101 */102 public static final ScmFileStatus UPDATED = new ScmFileStatus( "updated" );103104 /**105 * The file is part of a tag.106 */107 public static final ScmFileStatus TAGGED = new ScmFileStatus( "tagged" );108109 /**110 * The file is locked.111 */112 public static final ScmFileStatus LOCKED = new ScmFileStatus( "locked" );113114 /**115 * The file is in the working tree but is not versioned and not ignored either.116 */117 public static final ScmFileStatus UNKNOWN = new ScmFileStatus( "unknown" );118119 /**120 * @since 1.5121 * The file is being edited122 */123 public static final ScmFileStatus EDITED = new ScmFileStatus( "edit" );124125 /**126 * The status name127 */128 private final String name;129130 private ScmFileStatus( String name )131 {132 this.name = name;133 }134135 /** {@inheritDoc} */136 public String toString()137 {138 return name;139 }140141 /**142 * There are changes in the working tree that are not committed to the repository, or <br>143 * the file is unknown for the working tree.144 *145 * @return true on changes in the working tree or if the file is unknown.146 */147 public boolean isStatus()148 {149 return this == UNKNOWN || isDiff();150 }151152 /**153 * There are changes in the working tree that are not committed to the repository. <br>154 *155 * @return true on changes in the working tree156 */157 public boolean isDiff()158 {159 return this == ADDED || this == DELETED || this == MODIFIED;160 }161162 /**163 * @return true if the file was part of a transaction with the repository.164 */165 public boolean isTransaction()166 {167 return this == CHECKED_IN || this == CHECKED_OUT || this == LOCKED || this == TAGGED || isUpdate();168 }169170 /**171 * File is part of an update transaction with the repository.<br>172 * Note: ADDED and REMOVED are not an update status since they indicates173 * that the working tree has changed.<br>174 * An update indicates the opposite, that the repository was changed compared to175 * the working tree and that it is now synchronized unless there are conflicts.176 *177 * @return true if the status is conflict, updated or patched.178 */179 public boolean isUpdate()180 {181 return this == CONFLICT || this == UPDATED || this == PATCHED;182 }183}