Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/ManifestRevision.java @ 431:12f668401613
FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 29 Mar 2012 20:54:04 +0200 |
parents | 6437d261048a |
children | 5a455624be4f |
comparison
equal
deleted
inserted
replaced
430:d280759c2a3f | 431:12f668401613 |
---|---|
19 import java.util.Collection; | 19 import java.util.Collection; |
20 import java.util.TreeMap; | 20 import java.util.TreeMap; |
21 | 21 |
22 import org.tmatesoft.hg.core.Nodeid; | 22 import org.tmatesoft.hg.core.Nodeid; |
23 import org.tmatesoft.hg.repo.HgManifest; | 23 import org.tmatesoft.hg.repo.HgManifest; |
24 import org.tmatesoft.hg.util.Convertor; | |
24 import org.tmatesoft.hg.util.Path; | 25 import org.tmatesoft.hg.util.Path; |
25 | 26 |
26 /** | 27 /** |
27 * Specific revision of the manifest. | 28 * Specific revision of the manifest. |
28 * Note, suited to keep single revision only ({@link #changeset()}). | 29 * Note, suited to keep single revision only ({@link #changeset()}). |
31 * @author TMate Software Ltd. | 32 * @author TMate Software Ltd. |
32 */ | 33 */ |
33 public final class ManifestRevision implements HgManifest.Inspector { | 34 public final class ManifestRevision implements HgManifest.Inspector { |
34 private final TreeMap<Path, Nodeid> idsMap; | 35 private final TreeMap<Path, Nodeid> idsMap; |
35 private final TreeMap<Path, HgManifest.Flags> flagsMap; | 36 private final TreeMap<Path, HgManifest.Flags> flagsMap; |
36 private final Pool<Nodeid> idsPool; | 37 private final Convertor<Nodeid> idsPool; |
37 private final Pool<Path> namesPool; | 38 private final Convertor<Path> namesPool; |
38 private Nodeid changeset; | 39 private Nodeid changeset; |
39 private int changelogRev; | 40 private int changelogRev; |
40 | 41 |
41 // optional pools for effective management of nodeids and filenames (they are likely | 42 // optional pools for effective management of nodeids and filenames (they are likely |
42 // to be duplicated among different manifest revisions | 43 // to be duplicated among different manifest revisions |
43 public ManifestRevision(Pool<Nodeid> nodeidPool, Pool<Path> filenamePool) { | 44 public ManifestRevision(Pool<Nodeid> nodeidPool, Convertor<Path> filenamePool) { |
44 idsPool = nodeidPool; | 45 idsPool = nodeidPool; |
45 namesPool = filenamePool; | 46 namesPool = filenamePool; |
46 idsMap = new TreeMap<Path, Nodeid>(); | 47 idsMap = new TreeMap<Path, Nodeid>(); |
47 flagsMap = new TreeMap<Path, HgManifest.Flags>(); | 48 flagsMap = new TreeMap<Path, HgManifest.Flags>(); |
48 } | 49 } |
73 | 74 |
74 // | 75 // |
75 | 76 |
76 public boolean next(Nodeid nid, Path fname, HgManifest.Flags flags) { | 77 public boolean next(Nodeid nid, Path fname, HgManifest.Flags flags) { |
77 if (namesPool != null) { | 78 if (namesPool != null) { |
78 fname = namesPool.unify(fname); | 79 fname = namesPool.mangle(fname); |
79 } | 80 } |
80 if (idsPool != null) { | 81 if (idsPool != null) { |
81 nid = idsPool.unify(nid); | 82 nid = idsPool.mangle(nid); |
82 } | 83 } |
83 idsMap.put(fname, nid); | 84 idsMap.put(fname, nid); |
84 if (flags != HgManifest.Flags.RegularFile) { | 85 if (flags != HgManifest.Flags.RegularFile) { |
85 // TreeMap$Entry takes 32 bytes. No reason to keep regular file attribute (in fact, no flags state) | 86 // TreeMap$Entry takes 32 bytes. No reason to keep regular file attribute (in fact, no flags state) |
86 // for such price | 87 // for such price |