Mercurial > hg4j
comparison src/org/tmatesoft/hg/internal/BlameHelper.java @ 628:6526d8adbc0f
Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
| author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
|---|---|
| date | Wed, 22 May 2013 15:52:31 +0200 |
| parents | b4948b159ab1 |
| children | 5f52074707b2 |
comparison
equal
deleted
inserted
replaced
| 627:5153eb73b18d | 628:6526d8adbc0f |
|---|---|
| 32 import org.tmatesoft.hg.repo.HgBlameInspector.RevisionDescriptor; | 32 import org.tmatesoft.hg.repo.HgBlameInspector.RevisionDescriptor; |
| 33 import org.tmatesoft.hg.repo.HgBlameInspector.RevisionDescriptor.Recipient; | 33 import org.tmatesoft.hg.repo.HgBlameInspector.RevisionDescriptor.Recipient; |
| 34 import org.tmatesoft.hg.repo.HgBlameInspector; | 34 import org.tmatesoft.hg.repo.HgBlameInspector; |
| 35 import org.tmatesoft.hg.repo.HgDataFile; | 35 import org.tmatesoft.hg.repo.HgDataFile; |
| 36 import org.tmatesoft.hg.repo.HgInvalidStateException; | 36 import org.tmatesoft.hg.repo.HgInvalidStateException; |
| 37 import org.tmatesoft.hg.repo.HgRuntimeException; | |
| 37 import org.tmatesoft.hg.util.Adaptable; | 38 import org.tmatesoft.hg.util.Adaptable; |
| 38 import org.tmatesoft.hg.util.CancelledException; | 39 import org.tmatesoft.hg.util.CancelledException; |
| 39 import org.tmatesoft.hg.util.Pair; | 40 import org.tmatesoft.hg.util.Pair; |
| 40 | 41 |
| 41 /** | 42 /** |
| 60 * to iteration over file history. | 61 * to iteration over file history. |
| 61 | 62 |
| 62 * <p>NOTE, clogRevIndexEnd has to list name of the supplied file in the corresponding manifest, | 63 * <p>NOTE, clogRevIndexEnd has to list name of the supplied file in the corresponding manifest, |
| 63 * as it's not possible to trace rename history otherwise. | 64 * as it's not possible to trace rename history otherwise. |
| 64 */ | 65 */ |
| 65 public FileHistory prepare(HgDataFile df, int clogRevIndexStart, int clogRevIndexEnd) { | 66 public FileHistory prepare(HgDataFile df, int clogRevIndexStart, int clogRevIndexEnd) throws HgRuntimeException { |
| 66 assert clogRevIndexStart <= clogRevIndexEnd; | 67 assert clogRevIndexStart <= clogRevIndexEnd; |
| 67 FileHistory fileHistory = new FileHistory(df, clogRevIndexStart, clogRevIndexEnd); | 68 FileHistory fileHistory = new FileHistory(df, clogRevIndexStart, clogRevIndexEnd); |
| 68 fileHistory.build(); | 69 fileHistory.build(); |
| 69 int cacheHint = 5; // cache comes useful when we follow merge branches and don't want to | 70 int cacheHint = 5; // cache comes useful when we follow merge branches and don't want to |
| 70 // parse base revision twice. There's no easy way to determine max(distance(all(base,merge))), | 71 // parse base revision twice. There's no easy way to determine max(distance(all(base,merge))), |
| 82 } | 83 } |
| 83 return fileHistory; | 84 return fileHistory; |
| 84 } | 85 } |
| 85 | 86 |
| 86 // NO_REVISION is not allowed as any argument | 87 // NO_REVISION is not allowed as any argument |
| 87 public void diff(int fileRevIndex1, int clogRevIndex1, int fileRevIndex2, int clogRevIndex2) throws HgCallbackTargetException { | 88 public void diff(int fileRevIndex1, int clogRevIndex1, int fileRevIndex2, int clogRevIndex2) throws HgCallbackTargetException, HgRuntimeException { |
| 88 HgDataFile targetFile = linesCache.getFile(clogRevIndex2); | 89 HgDataFile targetFile = linesCache.getFile(clogRevIndex2); |
| 89 LineSequence c1 = linesCache.lines(clogRevIndex1, fileRevIndex1); | 90 LineSequence c1 = linesCache.lines(clogRevIndex1, fileRevIndex1); |
| 90 LineSequence c2 = linesCache.lines(clogRevIndex2, fileRevIndex2); | 91 LineSequence c2 = linesCache.lines(clogRevIndex2, fileRevIndex2); |
| 91 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); | 92 DiffHelper<LineSequence> pg = new DiffHelper<LineSequence>(); |
| 92 pg.init(c1, c2); | 93 pg.init(c1, c2); |
| 93 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex2, insp, clogRevIndex1, clogRevIndex2); | 94 BlameBlockInspector bbi = new BlameBlockInspector(targetFile, fileRevIndex2, insp, clogRevIndex1, clogRevIndex2); |
| 94 pg.findMatchingBlocks(bbi); | 95 pg.findMatchingBlocks(bbi); |
| 95 bbi.checkErrors(); | 96 bbi.checkErrors(); |
| 96 } | 97 } |
| 97 | 98 |
| 98 public void annotateChange(int fileRevIndex, int csetRevIndex, int[] fileParentRevs, int[] fileParentClogRevs) throws HgCallbackTargetException { | 99 public void annotateChange(int fileRevIndex, int csetRevIndex, int[] fileParentRevs, int[] fileParentClogRevs) throws HgCallbackTargetException, HgRuntimeException { |
| 99 HgDataFile targetFile = linesCache.getFile(csetRevIndex); | 100 HgDataFile targetFile = linesCache.getFile(csetRevIndex); |
| 100 final LineSequence fileRevLines = linesCache.lines(csetRevIndex, fileRevIndex); | 101 final LineSequence fileRevLines = linesCache.lines(csetRevIndex, fileRevIndex); |
| 101 if (fileParentClogRevs[0] != NO_REVISION && fileParentClogRevs[1] != NO_REVISION) { | 102 if (fileParentClogRevs[0] != NO_REVISION && fileParentClogRevs[1] != NO_REVISION) { |
| 102 int p1ClogIndex = fileParentClogRevs[0]; | 103 int p1ClogIndex = fileParentClogRevs[0]; |
| 103 int p2ClogIndex = fileParentClogRevs[1]; | 104 int p2ClogIndex = fileParentClogRevs[1]; |
| 174 } | 175 } |
| 175 } | 176 } |
| 176 throw new HgInvalidStateException(String.format("Got %d file-changelog mappings, but no luck for revision %d.", files.size(), clogRevIndex)); | 177 throw new HgInvalidStateException(String.format("Got %d file-changelog mappings, but no luck for revision %d.", files.size(), clogRevIndex)); |
| 177 } | 178 } |
| 178 | 179 |
| 179 public LineSequence lines(int clogRevIndex, int fileRevIndex) { | 180 public LineSequence lines(int clogRevIndex, int fileRevIndex) throws HgRuntimeException { |
| 180 Pair<Integer, LineSequence> cached = checkCache(clogRevIndex); | 181 Pair<Integer, LineSequence> cached = checkCache(clogRevIndex); |
| 181 if (cached != null) { | 182 if (cached != null) { |
| 182 return cached.second(); | 183 return cached.second(); |
| 183 } | 184 } |
| 184 HgDataFile df = getFile(clogRevIndex); | 185 HgDataFile df = getFile(clogRevIndex); |
