Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgWorkingCopyStatusCollector.java @ 218:047b1dec7a04
Issue 7: Correctly handle manifest and changelog with different number of (or non-matching) revisions
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Tue, 17 May 2011 03:42:33 +0200 |
parents | c9b305df0b89 |
children | d63583b47bfa |
comparison
equal
deleted
inserted
replaced
217:e39cf474ef94 | 218:047b1dec7a04 |
---|---|
16 */ | 16 */ |
17 package org.tmatesoft.hg.repo; | 17 package org.tmatesoft.hg.repo; |
18 | 18 |
19 import static java.lang.Math.max; | 19 import static java.lang.Math.max; |
20 import static java.lang.Math.min; | 20 import static java.lang.Math.min; |
21 import static org.tmatesoft.hg.repo.HgRepository.*; | |
21 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; | 22 import static org.tmatesoft.hg.repo.HgRepository.BAD_REVISION; |
22 import static org.tmatesoft.hg.repo.HgRepository.TIP; | 23 import static org.tmatesoft.hg.repo.HgRepository.TIP; |
23 | 24 |
24 import java.io.File; | 25 import java.io.File; |
25 import java.io.FileInputStream; | 26 import java.io.FileInputStream; |
59 public HgWorkingCopyStatusCollector(HgRepository hgRepo) { | 60 public HgWorkingCopyStatusCollector(HgRepository hgRepo) { |
60 this(hgRepo, hgRepo.createWorkingDirWalker()); | 61 this(hgRepo, hgRepo.createWorkingDirWalker()); |
61 } | 62 } |
62 | 63 |
63 HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator hgRepoWalker) { | 64 HgWorkingCopyStatusCollector(HgRepository hgRepo, FileIterator hgRepoWalker) { |
64 this.repo = hgRepo; | 65 repo = hgRepo; |
65 this.repoWalker = hgRepoWalker; | 66 repoWalker = hgRepoWalker; |
66 } | 67 } |
67 | 68 |
68 /** | 69 /** |
69 * Optionally, supply a collector instance that may cache (or have already cached) base revision | 70 * Optionally, supply a collector instance that may cache (or have already cached) base revision |
70 * @param sc may be null | 71 * @param sc may be null |
96 return dirstate; | 97 return dirstate; |
97 } | 98 } |
98 | 99 |
99 // may be invoked few times | 100 // may be invoked few times |
100 public void walk(int baseRevision, HgStatusInspector inspector) { | 101 public void walk(int baseRevision, HgStatusInspector inspector) { |
102 if (HgInternals.wrongLocalRevision(baseRevision) || baseRevision == BAD_REVISION || baseRevision == WORKING_COPY) { | |
103 throw new IllegalArgumentException(String.valueOf(baseRevision)); | |
104 } | |
101 final HgIgnore hgIgnore = repo.getIgnore(); | 105 final HgIgnore hgIgnore = repo.getIgnore(); |
102 TreeSet<String> knownEntries = getDirstate().all(); | 106 TreeSet<String> knownEntries = getDirstate().all(); |
103 final boolean isTipBase; | 107 final boolean isTipBase; |
104 if (baseRevision == TIP) { | 108 if (baseRevision == TIP) { |
105 baseRevision = repo.getManifest().getRevisionCount() - 1; | 109 baseRevision = repo.getChangelog().getLastRevision(); |
106 isTipBase = true; | 110 isTipBase = true; |
107 } else { | 111 } else { |
108 isTipBase = baseRevision == repo.getManifest().getRevisionCount() - 1; | 112 isTipBase = baseRevision == repo.getChangelog().getLastRevision(); |
109 } | 113 } |
110 HgStatusCollector.ManifestRevisionInspector collect = null; | 114 HgStatusCollector.ManifestRevisionInspector collect = null; |
111 Set<String> baseRevFiles = Collections.emptySet(); | 115 Set<String> baseRevFiles = Collections.emptySet(); |
112 if (!isTipBase) { | 116 if (!isTipBase) { |
113 if (baseRevisionCollector != null) { | 117 if (baseRevisionCollector != null) { |