Mercurial > jhg
comparison src/org/tmatesoft/hg/repo/WorkingCopyStatusCollector.java @ 89:42bcb4bffd17
Refactored to simplify manifest collector
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 26 Jan 2011 06:18:31 +0100 |
parents | 658fa6b3a371 |
children | a95c700408a9 |
comparison
equal
deleted
inserted
replaced
88:61eedab3eb3e | 89:42bcb4bffd17 |
---|---|
26 import java.util.Collections; | 26 import java.util.Collections; |
27 import java.util.Set; | 27 import java.util.Set; |
28 import java.util.TreeSet; | 28 import java.util.TreeSet; |
29 | 29 |
30 import org.tmatesoft.hg.core.Nodeid; | 30 import org.tmatesoft.hg.core.Nodeid; |
31 import org.tmatesoft.hg.repo.StatusCollector.ManifestRevisionInspector; | |
31 import org.tmatesoft.hg.util.FileWalker; | 32 import org.tmatesoft.hg.util.FileWalker; |
32 | 33 |
33 /** | 34 /** |
34 * | 35 * |
35 * @author Artem Tikhomirov | 36 * @author Artem Tikhomirov |
81 Set<String> baseRevFiles = Collections.emptySet(); | 82 Set<String> baseRevFiles = Collections.emptySet(); |
82 if (!isTipBase) { | 83 if (!isTipBase) { |
83 if (baseRevisionCollector != null) { | 84 if (baseRevisionCollector != null) { |
84 collect = baseRevisionCollector.raw(baseRevision); | 85 collect = baseRevisionCollector.raw(baseRevision); |
85 } else { | 86 } else { |
86 collect = new StatusCollector.ManifestRevisionInspector(baseRevision, baseRevision); | 87 collect = new StatusCollector.ManifestRevisionInspector(); |
87 repo.getManifest().walk(baseRevision, baseRevision, collect); | 88 repo.getManifest().walk(baseRevision, baseRevision, collect); |
88 } | 89 } |
89 baseRevFiles = new TreeSet<String>(collect.files(baseRevision)); | 90 baseRevFiles = new TreeSet<String>(collect.files()); |
90 } | 91 } |
91 if (inspector instanceof StatusCollector.Record) { | 92 if (inspector instanceof StatusCollector.Record) { |
92 StatusCollector sc = baseRevisionCollector == null ? new StatusCollector(repo) : baseRevisionCollector; | 93 StatusCollector sc = baseRevisionCollector == null ? new StatusCollector(repo) : baseRevisionCollector; |
93 ((StatusCollector.Record) inspector).init(baseRevision, BAD_REVISION, sc); | 94 ((StatusCollector.Record) inspector).init(baseRevision, BAD_REVISION, sc); |
94 } | 95 } |
100 if (hgIgnore.isIgnored(fname)) { | 101 if (hgIgnore.isIgnored(fname)) { |
101 inspector.ignored(fname); | 102 inspector.ignored(fname); |
102 } else if (knownEntries.remove(fname)) { | 103 } else if (knownEntries.remove(fname)) { |
103 // modified, added, removed, clean | 104 // modified, added, removed, clean |
104 if (collect != null) { // need to check against base revision, not FS file | 105 if (collect != null) { // need to check against base revision, not FS file |
105 Nodeid nid1 = collect.nodeid(baseRevision, fname); | 106 checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, fname, f, inspector); |
106 String flags = collect.flags(baseRevision, fname); | |
107 checkLocalStatusAgainstBaseRevision(baseRevFiles, nid1, flags, fname, f, inspector); | |
108 baseRevFiles.remove(fname); | 107 baseRevFiles.remove(fname); |
109 } else { | 108 } else { |
110 checkLocalStatusAgainstFile(fname, f, inspector); | 109 checkLocalStatusAgainstFile(fname, f, inspector); |
111 } | 110 } |
112 } else { | 111 } else { |
164 inspector.modified(fname); | 163 inspector.modified(fname); |
165 } | 164 } |
166 } | 165 } |
167 | 166 |
168 // XXX refactor checkLocalStatus methods in more OO way | 167 // XXX refactor checkLocalStatus methods in more OO way |
169 private void checkLocalStatusAgainstBaseRevision(Set<String> baseRevNames, Nodeid nid1, String flags, String fname, File f, StatusCollector.Inspector inspector) { | 168 private void checkLocalStatusAgainstBaseRevision(Set<String> baseRevNames, ManifestRevisionInspector collect, String fname, File f, StatusCollector.Inspector inspector) { |
170 // fname is in the dirstate, either Normal, Added, Removed or Merged | 169 // fname is in the dirstate, either Normal, Added, Removed or Merged |
170 Nodeid nid1 = collect.nodeid(fname); | |
171 String flags = collect.flags(fname); | |
171 HgDirstate.Record r; | 172 HgDirstate.Record r; |
172 if (nid1 == null) { | 173 if (nid1 == null) { |
173 // normal: added? | 174 // normal: added? |
174 // added: not known at the time of baseRevision, shall report | 175 // added: not known at the time of baseRevision, shall report |
175 // merged: was not known, report as added? | 176 // merged: was not known, report as added? |