comparison src/org/tmatesoft/hg/repo/HgStatusCollector.java @ 141:8248aae33f7d

Adopt FileIterator moving towards WCStatusCollector parameterizing. Improved path handling, move 'em around
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 17 Feb 2011 04:08:34 +0100
parents 3959bffb14e9
children 37a34044e6bd
comparison
equal deleted inserted replaced
140:1c1891ad1c73 141:8248aae33f7d
159 inspector.clean(pp.path(fname)); 159 inspector.clean(pp.path(fname));
160 } else { 160 } else {
161 inspector.modified(pp.path(fname)); 161 inspector.modified(pp.path(fname));
162 } 162 }
163 } else { 163 } else {
164 String copyOrigin = getOriginIfCopy(repo, fname, r1Files, rev1); 164 Path copyTarget = pp.path(fname);
165 Path copyOrigin = getOriginIfCopy(repo, copyTarget, r1Files, rev1);
165 if (copyOrigin != null) { 166 if (copyOrigin != null) {
166 inspector.copied(pp.path(copyOrigin), pp.path(fname)); 167 inspector.copied(pp.path(copyOrigin) /*pipe through pool, just in case*/, copyTarget);
167 } else { 168 } else {
168 inspector.added(pp.path(fname)); 169 inspector.added(copyTarget);
169 } 170 }
170 } 171 }
171 } 172 }
172 for (String left : r1Files) { 173 for (String left : r1Files) {
173 inspector.removed(pp.path(left)); 174 inspector.removed(pp.path(left));
178 Record rv = new Record(); 179 Record rv = new Record();
179 walk(rev1, rev2, rv); 180 walk(rev1, rev2, rv);
180 return rv; 181 return rv;
181 } 182 }
182 183
183 /*package-local*/static String getOriginIfCopy(HgRepository hgRepo, String fname, Collection<String> originals, int originalChangelogRevision) { 184 /*package-local*/static Path getOriginIfCopy(HgRepository hgRepo, Path fname, Collection<String> originals, int originalChangelogRevision) {
184 HgDataFile df = hgRepo.getFileNode(fname); 185 HgDataFile df = hgRepo.getFileNode(fname);
185 while (df.isCopy()) { 186 while (df.isCopy()) {
186 Path original = df.getCopySourceName(); 187 Path original = df.getCopySourceName();
187 if (originals.contains(original.toString())) { 188 if (originals.contains(original.toString())) {
188 df = hgRepo.getFileNode(original); 189 df = hgRepo.getFileNode(original);
190 if (changelogRevision <= originalChangelogRevision) { 191 if (changelogRevision <= originalChangelogRevision) {
191 // copy/rename source was known prior to rev1 192 // copy/rename source was known prior to rev1
192 // (both r1Files.contains is true and original was created earlier than rev1) 193 // (both r1Files.contains is true and original was created earlier than rev1)
193 // without r1Files.contains changelogRevision <= rev1 won't suffice as the file 194 // without r1Files.contains changelogRevision <= rev1 won't suffice as the file
194 // might get removed somewhere in between (changelogRevision < R < rev1) 195 // might get removed somewhere in between (changelogRevision < R < rev1)
195 return original.toString(); 196 return original;
196 } 197 }
197 break; // copy/rename done later 198 break; // copy/rename done later
198 } 199 }
199 df = hgRepo.getFileNode(original); // try more steps away 200 df = hgRepo.getFileNode(original); // try more steps away
200 } 201 }