comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 316:ee6b467c1a5f

Supply HGFileRevision with copy information when possible, calculate it otherwise
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 28 Sep 2011 13:09:16 +0200
parents 2ffcbf360fd5
children 678e326fd27c
comparison
equal deleted inserted replaced
315:8952f89be195 316:ee6b467c1a5f
309 return null; 309 return null;
310 } 310 }
311 311
312 // XXX for r1..r2 status, only modified, added, removed (and perhaps, clean) make sense 312 // XXX for r1..r2 status, only modified, added, removed (and perhaps, clean) make sense
313 // XXX Need to specify whether copy targets are in added or not (@see Inspector#copied above) 313 // XXX Need to specify whether copy targets are in added or not (@see Inspector#copied above)
314 /**
315 * Straightforward {@link HgStatusInspector} implementation that collects all status values.
316 *
317 * <p>Naturally, {@link Record Records} originating from {@link HgStatusCollector} would report only <em>modified, added,
318 * removed</em> and <em>clean</em> values, other are available only when using {@link Record} with {@link HgWorkingCopyStatusCollector}.
319 *
320 * <p>Note, this implementation records copied files as added, thus key values in {@link #getCopied()} map are subset of paths
321 * from {@link #getAdded()}.
322 */
314 public static class Record implements HgStatusInspector { 323 public static class Record implements HgStatusInspector {
315 private List<Path> modified, added, removed, clean, missing, unknown, ignored; 324 private List<Path> modified, added, removed, clean, missing, unknown, ignored;
316 private Map<Path, Path> copied; 325 private Map<Path, Path> copied;
317 326
318 private int startRev, endRev; 327 private int startRev, endRev;
360 369
361 public List<Path> getRemoved() { 370 public List<Path> getRemoved() {
362 return proper(removed); 371 return proper(removed);
363 } 372 }
364 373
374 /**
375 * Map files from {@link #getAdded()} to their original filenames, if were copied/moved.
376 */
365 public Map<Path,Path> getCopied() { 377 public Map<Path,Path> getCopied() {
366 if (copied == null) { 378 if (copied == null) {
367 return Collections.emptyMap(); 379 return Collections.emptyMap();
368 } 380 }
369 return Collections.unmodifiableMap(copied); 381 return Collections.unmodifiableMap(copied);
383 395
384 public List<Path> getIgnored() { 396 public List<Path> getIgnored() {
385 return proper(ignored); 397 return proper(ignored);
386 } 398 }
387 399
388 private List<Path> proper(List<Path> l) { 400 private static List<Path> proper(List<Path> l) {
389 if (l == null) { 401 if (l == null) {
390 return Collections.emptyList(); 402 return Collections.emptyList();
391 } 403 }
392 return Collections.unmodifiableList(l); 404 return Collections.unmodifiableList(l);
393 } 405 }