comparison src/org/tmatesoft/hg/core/HgManifestCommand.java @ 285:6dbbc53fc46d

Use Path instead of plain String for manifest file names
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Sat, 03 Sep 2011 21:46:13 +0200
parents 4c3b9f679412
children 189dc6dc1c3e
comparison
equal deleted inserted replaced
284:7232b94f2ae3 285:6dbbc53fc46d
25 import java.util.LinkedList; 25 import java.util.LinkedList;
26 import java.util.List; 26 import java.util.List;
27 27
28 import org.tmatesoft.hg.repo.HgManifest; 28 import org.tmatesoft.hg.repo.HgManifest;
29 import org.tmatesoft.hg.repo.HgRepository; 29 import org.tmatesoft.hg.repo.HgRepository;
30 import org.tmatesoft.hg.repo.HgManifest.Flags;
30 import org.tmatesoft.hg.util.Path; 31 import org.tmatesoft.hg.util.Path;
31 import org.tmatesoft.hg.util.PathPool; 32 import org.tmatesoft.hg.util.PathPool;
32 import org.tmatesoft.hg.util.PathRewrite; 33 import org.tmatesoft.hg.util.PathRewrite;
33 34
34 35
126 void file(HgFileRevision fileRevision); // XXX allow to check p is invalid (df.exists()) 127 void file(HgFileRevision fileRevision); // XXX allow to check p is invalid (df.exists())
127 void end(Nodeid manifestRevision); 128 void end(Nodeid manifestRevision);
128 } 129 }
129 130
130 // I'd rather let HgManifestCommand implement HgManifest.Inspector directly, but this pollutes API alot 131 // I'd rather let HgManifestCommand implement HgManifest.Inspector directly, but this pollutes API alot
131 private class Mediator implements HgManifest.Inspector { 132 private class Mediator implements HgManifest.Inspector2 {
132 // file names are likely to repeat in each revision, hence caching of Paths. 133 // file names are likely to repeat in each revision, hence caching of Paths.
133 // However, once HgManifest.Inspector switches to Path objects, perhaps global Path pool 134 // However, once HgManifest.Inspector switches to Path objects, perhaps global Path pool
134 // might be more effective? 135 // might be more effective?
135 private PathPool pathPool; 136 private PathPool pathPool;
136 private List<HgFileRevision> manifestContent; 137 private List<HgFileRevision> manifestContent;
177 visitor.end(manifestNodeid); 178 visitor.end(manifestNodeid);
178 manifestNodeid = null; 179 manifestNodeid = null;
179 return true; 180 return true;
180 } 181 }
181 public boolean next(Nodeid nid, String fname, String flags) { 182 public boolean next(Nodeid nid, String fname, String flags) {
182 Path p = pathPool.path(fname); 183 throw new HgBadStateException(HgManifest.Inspector2.class.getName());
183 if (matcher != null && !matcher.accept(p)) { 184 }
185
186 public boolean next(Nodeid nid, Path fname, Flags flags) {
187 if (matcher != null && !matcher.accept(fname)) {
184 return true; 188 return true;
185 } 189 }
186 HgFileRevision fr = new HgFileRevision(repo, nid, p); 190 HgFileRevision fr = new HgFileRevision(repo, nid, fname);
187 if (needDirs) { 191 if (needDirs) {
188 manifestContent.add(fr); 192 manifestContent.add(fr);
189 } else { 193 } else {
190 visitor.file(fr); 194 visitor.file(fr);
191 } 195 }