comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.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 cd658b24a620
children 909306e412e2
comparison
equal deleted inserted replaced
430:d280759c2a3f 431:12f668401613
35 import org.tmatesoft.hg.internal.ByteArrayChannel; 35 import org.tmatesoft.hg.internal.ByteArrayChannel;
36 import org.tmatesoft.hg.internal.Experimental; 36 import org.tmatesoft.hg.internal.Experimental;
37 import org.tmatesoft.hg.internal.FilterByteChannel; 37 import org.tmatesoft.hg.internal.FilterByteChannel;
38 import org.tmatesoft.hg.internal.Internals; 38 import org.tmatesoft.hg.internal.Internals;
39 import org.tmatesoft.hg.internal.ManifestRevision; 39 import org.tmatesoft.hg.internal.ManifestRevision;
40 import org.tmatesoft.hg.internal.PathPool;
40 import org.tmatesoft.hg.internal.PathScope; 41 import org.tmatesoft.hg.internal.PathScope;
41 import org.tmatesoft.hg.internal.Preview; 42 import org.tmatesoft.hg.internal.Preview;
42 import org.tmatesoft.hg.util.Adaptable; 43 import org.tmatesoft.hg.util.Adaptable;
43 import org.tmatesoft.hg.util.ByteChannel; 44 import org.tmatesoft.hg.util.ByteChannel;
44 import org.tmatesoft.hg.util.CancelSupport; 45 import org.tmatesoft.hg.util.CancelSupport;
45 import org.tmatesoft.hg.util.CancelledException; 46 import org.tmatesoft.hg.util.CancelledException;
47 import org.tmatesoft.hg.util.Convertor;
46 import org.tmatesoft.hg.util.FileInfo; 48 import org.tmatesoft.hg.util.FileInfo;
47 import org.tmatesoft.hg.util.FileIterator; 49 import org.tmatesoft.hg.util.FileIterator;
48 import org.tmatesoft.hg.util.FileWalker; 50 import org.tmatesoft.hg.util.FileWalker;
49 import org.tmatesoft.hg.util.Path; 51 import org.tmatesoft.hg.util.Path;
50 import org.tmatesoft.hg.util.PathPool;
51 import org.tmatesoft.hg.util.PathRewrite; 52 import org.tmatesoft.hg.util.PathRewrite;
52 import org.tmatesoft.hg.util.RegularFileInfo; 53 import org.tmatesoft.hg.util.RegularFileInfo;
53 54
54 /** 55 /**
55 * 56 *
60 61
61 private final HgRepository repo; 62 private final HgRepository repo;
62 private final FileIterator repoWalker; 63 private final FileIterator repoWalker;
63 private HgDirstate dirstate; 64 private HgDirstate dirstate;
64 private HgStatusCollector baseRevisionCollector; 65 private HgStatusCollector baseRevisionCollector;
65 private PathPool pathPool; 66 private Convertor<Path> pathPool;
66 private ManifestRevision dirstateParentManifest; 67 private ManifestRevision dirstateParentManifest;
67 68
68 /** 69 /**
69 * Collector that iterates over complete working copy 70 * Collector that iterates over complete working copy
70 */ 71 */
90 */ 91 */
91 public void setBaseRevisionCollector(HgStatusCollector sc) { 92 public void setBaseRevisionCollector(HgStatusCollector sc) {
92 baseRevisionCollector = sc; 93 baseRevisionCollector = sc;
93 } 94 }
94 95
95 /*package-local*/ PathPool getPathPool() { 96 /*package-local*/ Convertor<Path> getPathPool() {
96 if (pathPool == null) { 97 if (pathPool == null) {
97 if (baseRevisionCollector == null) { 98 if (baseRevisionCollector == null) {
98 pathPool = new PathPool(new PathRewrite.Empty()); 99 pathPool = new PathPool(new PathRewrite.Empty());
99 } else { 100 } else {
100 return baseRevisionCollector.getPathPool(); 101 return baseRevisionCollector.getPathPool();
101 } 102 }
102 } 103 }
103 return pathPool; 104 return pathPool;
104 } 105 }
105 106
106 public void setPathPool(PathPool pathPool) { 107 public void setPathPool(Convertor<Path> pathConvertor) {
107 this.pathPool = pathPool; 108 pathPool = pathConvertor;
108 } 109 }
109 110
110 /** 111 /**
111 * Access to directory state information this collector uses. 112 * Access to directory state information this collector uses.
112 * @return directory state holder, never <code>null</code> 113 * @return directory state holder, never <code>null</code>
113 */ 114 */
114 public HgDirstate getDirstate() throws HgInvalidControlFileException { 115 public HgDirstate getDirstate() throws HgInvalidControlFileException {
115 if (dirstate == null) { 116 if (dirstate == null) {
116 dirstate = repo.loadDirstate(getPathPool()); 117 Convertor<Path> pp = getPathPool();
118 Path.Source ps;
119 if (pp instanceof Path.Source) {
120 ps = (Path.Source) pp;
121 } else {
122 ps = new Path.SimpleSource(new PathRewrite.Empty(), pp);
123 }
124 dirstate = repo.loadDirstate(ps);
117 } 125 }
118 return dirstate; 126 return dirstate;
119 } 127 }
120 128
121 private HgDirstate getDirstateImpl() { 129 private HgDirstate getDirstateImpl() {
204 final HgDirstate ds = getDirstateImpl(); 212 final HgDirstate ds = getDirstateImpl();
205 TreeSet<Path> knownEntries = ds.all(); // here just to get dirstate initialized 213 TreeSet<Path> knownEntries = ds.all(); // here just to get dirstate initialized
206 while (repoWalker.hasNext()) { 214 while (repoWalker.hasNext()) {
207 cs.checkCancelled(); 215 cs.checkCancelled();
208 repoWalker.next(); 216 repoWalker.next();
209 final Path fname = getPathPool().path(repoWalker.name()); 217 final Path fname = getPathPool().mangle(repoWalker.name());
210 FileInfo f = repoWalker.file(); 218 FileInfo f = repoWalker.file();
211 Path knownInDirstate; 219 Path knownInDirstate;
212 if (!f.exists()) { 220 if (!f.exists()) {
213 // file coming from iterator doesn't exist. 221 // file coming from iterator doesn't exist.
214 if ((knownInDirstate = ds.known(fname)) != null) { 222 if ((knownInDirstate = ds.known(fname)) != null) {
383 // merged: was not known, report as added? 391 // merged: was not known, report as added?
384 if ((r = getDirstateImpl().checkNormal(fname)) != null) { 392 if ((r = getDirstateImpl().checkNormal(fname)) != null) {
385 try { 393 try {
386 Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, baseRevNames, baseRevision); 394 Path origin = HgStatusCollector.getOriginIfCopy(repo, fname, baseRevNames, baseRevision);
387 if (origin != null) { 395 if (origin != null) {
388 inspector.copied(getPathPool().path(origin), fname); 396 inspector.copied(getPathPool().mangle(origin), fname);
389 return; 397 return;
390 } 398 }
391 } catch (HgInvalidFileException ex) { 399 } catch (HgInvalidFileException ex) {
392 // report failure and continue status collection 400 // report failure and continue status collection
393 inspector.invalid(fname, ex); 401 inspector.invalid(fname, ex);