Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 284:7232b94f2ae3
HgDirstate shall operate with Path instead of String for file names. Use of Pair instead of array of unspecified length for parents.
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Sat, 03 Sep 2011 13:12:13 +0200 |
parents | e51dd9a14b6f |
children | 6dbbc53fc46d |
comparison
equal
deleted
inserted
replaced
283:7a8e1a305a78 | 284:7232b94f2ae3 |
---|---|
95 } | 95 } |
96 | 96 |
97 | 97 |
98 private HgDirstate getDirstate() { | 98 private HgDirstate getDirstate() { |
99 if (dirstate == null) { | 99 if (dirstate == null) { |
100 dirstate = repo.loadDirstate(); | 100 dirstate = repo.loadDirstate(getPathPool()); |
101 } | 101 } |
102 return dirstate; | 102 return dirstate; |
103 } | 103 } |
104 | 104 |
105 private ManifestRevision getManifest(int changelogLocalRev) { | 105 private ManifestRevision getManifest(int changelogLocalRev) { |
106 assert changelogLocalRev >= 0; | |
106 ManifestRevision mr; | 107 ManifestRevision mr; |
107 if (baseRevisionCollector != null) { | 108 if (baseRevisionCollector != null) { |
108 mr = baseRevisionCollector.raw(changelogLocalRev); | 109 mr = baseRevisionCollector.raw(changelogLocalRev); |
109 } else { | 110 } else { |
110 mr = new ManifestRevision(null, null); | 111 mr = new ManifestRevision(null, null); |
115 | 116 |
116 private ManifestRevision getDirstateParentManifest() { | 117 private ManifestRevision getDirstateParentManifest() { |
117 // WC not necessarily points to TIP, but may be result of update to any previous revision. | 118 // WC not necessarily points to TIP, but may be result of update to any previous revision. |
118 // In such case, we need to compare local files not to their TIP content, but to specific version at the time of selected revision | 119 // In such case, we need to compare local files not to their TIP content, but to specific version at the time of selected revision |
119 if (dirstateParentManifest == null) { | 120 if (dirstateParentManifest == null) { |
120 Nodeid dirstateParent = getDirstate().parents()[0]; | 121 Nodeid dirstateParent = getDirstate().parents().first(); |
121 int changelogLocalRev = repo.getChangelog().getLocalRevision(dirstateParent); | 122 if (dirstateParent.isNull()) { |
122 dirstateParentManifest = getManifest(changelogLocalRev); | 123 dirstateParentManifest = baseRevisionCollector != null ? baseRevisionCollector.raw(-1) : HgStatusCollector.createEmptyManifestRevision(); |
124 } else { | |
125 int changelogLocalRev = repo.getChangelog().getLocalRevision(dirstateParent); | |
126 dirstateParentManifest = getManifest(changelogLocalRev); | |
127 } | |
123 } | 128 } |
124 return dirstateParentManifest; | 129 return dirstateParentManifest; |
125 } | 130 } |
126 | 131 |
127 // may be invoked few times, TIP or WORKING_COPY indicate comparison shall be run against working copy parent | 132 // may be invoked few times, TIP or WORKING_COPY indicate comparison shall be run against working copy parent |
150 rev1 = baseRevision; | 155 rev1 = baseRevision; |
151 } | 156 } |
152 ((HgStatusCollector.Record) inspector).init(rev1, rev2, sc); | 157 ((HgStatusCollector.Record) inspector).init(rev1, rev2, sc); |
153 } | 158 } |
154 final HgIgnore hgIgnore = repo.getIgnore(); | 159 final HgIgnore hgIgnore = repo.getIgnore(); |
155 TreeSet<String> knownEntries = getDirstate().all(); | 160 TreeSet<Path> knownEntries = getDirstate().all(); |
156 repoWalker.reset(); | 161 repoWalker.reset(); |
157 final PathPool pp = getPathPool(); | |
158 while (repoWalker.hasNext()) { | 162 while (repoWalker.hasNext()) { |
159 repoWalker.next(); | 163 repoWalker.next(); |
160 final Path fname = pp.path(repoWalker.name()); | 164 final Path fname = getPathPool().path(repoWalker.name()); |
161 File f = repoWalker.file(); | 165 File f = repoWalker.file(); |
162 if (!f.exists()) { | 166 if (!f.exists()) { |
163 // file coming from iterator doesn't exist. | 167 // file coming from iterator doesn't exist. |
164 if (knownEntries.remove(fname.toString())) { | 168 if (knownEntries.remove(fname)) { |
165 if (getDirstate().checkRemoved(fname) == null) { | 169 if (getDirstate().checkRemoved(fname) == null) { |
166 inspector.missing(fname); | 170 inspector.missing(fname); |
167 } else { | 171 } else { |
168 inspector.removed(fname); | 172 inspector.removed(fname); |
169 } | 173 } |
188 } | 192 } |
189 } | 193 } |
190 continue; | 194 continue; |
191 } | 195 } |
192 assert f.isFile(); | 196 assert f.isFile(); |
193 if (knownEntries.remove(fname.toString())) { | 197 if (knownEntries.remove(fname)) { |
194 // tracked file. | 198 // tracked file. |
195 // modified, added, removed, clean | 199 // modified, added, removed, clean |
196 if (collect != null) { // need to check against base revision, not FS file | 200 if (collect != null) { // need to check against base revision, not FS file |
197 checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, fname, f, inspector); | 201 checkLocalStatusAgainstBaseRevision(baseRevFiles, collect, baseRevision, fname, f, inspector); |
198 } else { | 202 } else { |
209 // yield two statuses for the same file) | 213 // yield two statuses for the same file) |
210 } | 214 } |
211 } | 215 } |
212 if (collect != null) { | 216 if (collect != null) { |
213 for (String r : baseRevFiles) { | 217 for (String r : baseRevFiles) { |
214 final Path fromBase = pp.path(r); | 218 final Path fromBase = getPathPool().path(r); |
215 if (repoWalker.inScope(fromBase)) { | 219 if (repoWalker.inScope(fromBase)) { |
216 inspector.removed(fromBase); | 220 inspector.removed(fromBase); |
217 } | 221 } |
218 } | 222 } |
219 } | 223 } |
220 for (String m : knownEntries) { | 224 for (Path m : knownEntries) { |
221 if (!repoWalker.inScope(pp.path(m))) { | 225 if (!repoWalker.inScope(m)) { |
222 // do not report as missing/removed those FileIterator doesn't care about. | 226 // do not report as missing/removed those FileIterator doesn't care about. |
223 continue; | 227 continue; |
224 } | 228 } |
225 // missing known file from a working dir | 229 // missing known file from a working dir |
226 if (getDirstate().checkRemoved(m) == null) { | 230 if (getDirstate().checkRemoved(m) == null) { |
227 // not removed from the repository = 'deleted' | 231 // not removed from the repository = 'deleted' |
228 inspector.missing(pp.path(m)); | 232 inspector.missing(m); |
229 } else { | 233 } else { |
230 // removed from the repo | 234 // removed from the repo |
231 // if we check against non-tip revision, do not report files that were added past that revision and now removed. | 235 // if we check against non-tip revision, do not report files that were added past that revision and now removed. |
232 if (collect == null || baseRevFiles.contains(m)) { | 236 if (collect == null || baseRevFiles.contains(m.toString())) { |
233 inspector.removed(pp.path(m)); | 237 inspector.removed(m); |
234 } | 238 } |
235 } | 239 } |
236 } | 240 } |
237 } | 241 } |
238 | 242 |