Mercurial > jhg
comparison src/com/tmate/hgkit/ll/WorkingCopyStatusCollector.java @ 68:0e499fed9b3d
StatusCommand with tests. Extra constants to indicate common revision cases
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 22 Jan 2011 22:11:24 +0100 |
parents | a47530a2ea12 |
children |
comparison
equal
deleted
inserted
replaced
67:64bddc2dcc0e | 68:0e499fed9b3d |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2011 Artem Tikhomirov | 2 * Copyright (c) 2011 Artem Tikhomirov |
3 */ | 3 */ |
4 package com.tmate.hgkit.ll; | 4 package com.tmate.hgkit.ll; |
5 | 5 |
6 import static com.tmate.hgkit.ll.HgRepository.BAD_REVISION; | |
6 import static com.tmate.hgkit.ll.HgRepository.TIP; | 7 import static com.tmate.hgkit.ll.HgRepository.TIP; |
7 | 8 |
8 import java.io.BufferedInputStream; | 9 import java.io.BufferedInputStream; |
9 import java.io.File; | 10 import java.io.File; |
10 import java.io.FileInputStream; | 11 import java.io.FileInputStream; |
52 | 53 |
53 // may be invoked few times | 54 // may be invoked few times |
54 public void walk(int baseRevision, StatusCollector.Inspector inspector) { | 55 public void walk(int baseRevision, StatusCollector.Inspector inspector) { |
55 final HgIgnore hgIgnore = ((LocalHgRepo) repo).loadIgnore(); // FIXME hack | 56 final HgIgnore hgIgnore = ((LocalHgRepo) repo).loadIgnore(); // FIXME hack |
56 TreeSet<String> knownEntries = getDirstate().all(); | 57 TreeSet<String> knownEntries = getDirstate().all(); |
57 final boolean isTipBase = baseRevision == TIP || baseRevision == repo.getManifest().getRevisionCount(); | 58 final boolean isTipBase; |
59 if (baseRevision == TIP) { | |
60 baseRevision = repo.getManifest().getRevisionCount() - 1; | |
61 isTipBase = true; | |
62 } else { | |
63 isTipBase = baseRevision == repo.getManifest().getRevisionCount() - 1; | |
64 } | |
58 StatusCollector.ManifestRevisionInspector collect = null; | 65 StatusCollector.ManifestRevisionInspector collect = null; |
59 Set<String> baseRevFiles = Collections.emptySet(); | 66 Set<String> baseRevFiles = Collections.emptySet(); |
60 if (!isTipBase) { | 67 if (!isTipBase) { |
61 if (baseRevisionCollector != null) { | 68 if (baseRevisionCollector != null) { |
62 collect = baseRevisionCollector.raw(baseRevision); | 69 collect = baseRevisionCollector.raw(baseRevision); |
63 } else { | 70 } else { |
64 collect = new StatusCollector.ManifestRevisionInspector(baseRevision, baseRevision); | 71 collect = new StatusCollector.ManifestRevisionInspector(baseRevision, baseRevision); |
65 repo.getManifest().walk(baseRevision, baseRevision, collect); | 72 repo.getManifest().walk(baseRevision, baseRevision, collect); |
66 } | 73 } |
67 baseRevFiles = new TreeSet<String>(collect.files(baseRevision)); | 74 baseRevFiles = new TreeSet<String>(collect.files(baseRevision)); |
75 } | |
76 if (inspector instanceof StatusCollector.Record) { | |
77 StatusCollector sc = baseRevisionCollector == null ? new StatusCollector(repo) : baseRevisionCollector; | |
78 ((StatusCollector.Record) inspector).init(baseRevision, BAD_REVISION, sc); | |
68 } | 79 } |
69 repoWalker.reset(); | 80 repoWalker.reset(); |
70 while (repoWalker.hasNext()) { | 81 while (repoWalker.hasNext()) { |
71 repoWalker.next(); | 82 repoWalker.next(); |
72 String fname = repoWalker.name(); | 83 String fname = repoWalker.name(); |