comparison src/org/tmatesoft/hg/core/StatusCommand.java @ 127:2e395db595e2

Moved HgStatus to toplevel
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 16 Feb 2011 18:42:10 +0100
parents 4f509f5bc8cb
children 44b97930570c
comparison
equal deleted inserted replaced
126:b92a638764be 127:2e395db595e2
14 * the terms of a license other than GNU General Public License 14 * the terms of a license other than GNU General Public License
15 * contact TMate Software at support@hg4j.com 15 * contact TMate Software at support@hg4j.com
16 */ 16 */
17 package org.tmatesoft.hg.core; 17 package org.tmatesoft.hg.core;
18 18
19 import static org.tmatesoft.hg.core.StatusCommand.HgStatus.Kind.*; 19 import static org.tmatesoft.hg.core.HgStatus.Kind.*;
20 import static org.tmatesoft.hg.repo.HgRepository.*; 20 import static org.tmatesoft.hg.repo.HgRepository.*;
21 21
22 import java.util.ConcurrentModificationException; 22 import java.util.ConcurrentModificationException;
23 23
24 import org.tmatesoft.hg.core.Path.Matcher; 24 import org.tmatesoft.hg.core.Path.Matcher;
25 import org.tmatesoft.hg.core.StatusCommand.HgStatus.Kind;
26 import org.tmatesoft.hg.repo.HgRepository; 25 import org.tmatesoft.hg.repo.HgRepository;
27 import org.tmatesoft.hg.repo.HgStatusCollector; 26 import org.tmatesoft.hg.repo.HgStatusCollector;
28 import org.tmatesoft.hg.repo.HgStatusInspector; 27 import org.tmatesoft.hg.repo.HgStatusInspector;
29 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector; 28 import org.tmatesoft.hg.repo.HgWorkingCopyStatusCollector;
30 29
175 174
176 public interface Handler { 175 public interface Handler {
177 void handleStatus(HgStatus s); 176 void handleStatus(HgStatus s);
178 } 177 }
179 178
180 public static class HgStatus {
181 public enum Kind {
182 Modified, Added, Removed, Unknown, Missing, Clean, Ignored
183 };
184 private final Kind kind;
185 private final Path path;
186 private final Path origin;
187
188 HgStatus(Kind kind, Path path) {
189 this(kind, path, null);
190 }
191
192 HgStatus(Kind kind, Path path, Path copyOrigin) {
193 this.kind = kind;
194 this.path = path;
195 origin = copyOrigin;
196 }
197
198 public Kind getKind() {
199 return kind;
200 }
201
202 public Path getPath() {
203 return path;
204 }
205
206 public Path getOriginalPath() {
207 return origin;
208 }
209
210 public boolean isCopy() {
211 return origin != null;
212 }
213 }
214
215
216 private class Mediator implements HgStatusInspector { 179 private class Mediator implements HgStatusInspector {
217 boolean needModified; 180 boolean needModified;
218 boolean needAdded; 181 boolean needAdded;
219 boolean needRemoved; 182 boolean needRemoved;
220 boolean needUnknown; 183 boolean needUnknown;
255 } 218 }
256 } 219 }
257 public void copied(Path fnameOrigin, Path fnameAdded) { 220 public void copied(Path fnameOrigin, Path fnameAdded) {
258 if (needCopies) { 221 if (needCopies) {
259 if (matcher == null || matcher.accept(fnameAdded)) { 222 if (matcher == null || matcher.accept(fnameAdded)) {
260 handler.handleStatus(new HgStatus(Kind.Added, fnameAdded, fnameOrigin)); 223 handler.handleStatus(new HgStatus(Added, fnameAdded, fnameOrigin));
261 } 224 }
262 } 225 }
263 } 226 }
264 public void missing(Path fname) { 227 public void missing(Path fname) {
265 if (needMissing) { 228 if (needMissing) {