comparison src/org/tmatesoft/hg/internal/ChangelogHelper.java @ 354:5f9073eabf06

Propagate errors with exceptions up to a end client
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 01 Dec 2011 05:21:40 +0100
parents f052f40839ec
children 2fadf8695f8a
comparison
equal deleted inserted replaced
353:0f3687e79f5a 354:5f9073eabf06
16 */ 16 */
17 package org.tmatesoft.hg.internal; 17 package org.tmatesoft.hg.internal;
18 18
19 import java.util.TreeMap; 19 import java.util.TreeMap;
20 20
21 import org.tmatesoft.hg.core.HgInvalidControlFileException;
21 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; 22 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset;
22 import org.tmatesoft.hg.repo.HgDataFile; 23 import org.tmatesoft.hg.repo.HgDataFile;
23 import org.tmatesoft.hg.repo.HgInternals; 24 import org.tmatesoft.hg.repo.HgInternals;
24 import org.tmatesoft.hg.repo.HgRepository; 25 import org.tmatesoft.hg.repo.HgRepository;
25 import org.tmatesoft.hg.util.Path; 26 import org.tmatesoft.hg.util.Path;
30 * @author TMate Software Ltd. 31 * @author TMate Software Ltd.
31 */ 32 */
32 public class ChangelogHelper { 33 public class ChangelogHelper {
33 private final int leftBoundary; 34 private final int leftBoundary;
34 private final HgRepository repo; 35 private final HgRepository repo;
35 private final TreeMap<Integer, RawChangeset> cache = new TreeMap<Integer, RawChangeset>(); 36 private final TreeMap<Integer, RawChangeset> cache = new TreeMap<Integer, RawChangeset>(); // FIXME use IntMap instead
36 private String nextCommitAuthor; 37 private String nextCommitAuthor;
37 38
38 /** 39 /**
39 * @param hgRepo 40 * @param hgRepo
40 * @param leftBoundaryRevision walker never visits revisions with local numbers less than specified, 41 * @param leftBoundaryRevision walker never visits revisions with local numbers less than specified,
53 } 54 }
54 55
55 /** 56 /**
56 * Walks changelog in reverse order 57 * Walks changelog in reverse order
57 * @param file 58 * @param file
58 * @return changeset where specified file is mentioned among affected files, or 59 * @return changeset where specified file is mentioned among affected files, or <code>null</code> if none found up to leftBoundary
59 * <code>null</code> if none found up to leftBoundary
60 */ 60 */
61 public RawChangeset findLatestChangeWith(Path file) { 61 public RawChangeset findLatestChangeWith(Path file) throws HgInvalidControlFileException {
62 HgDataFile df = repo.getFileNode(file); 62 HgDataFile df = repo.getFileNode(file);
63 if (!df.exists()) { 63 if (!df.exists()) {
64 return null; 64 return null;
65 } 65 }
66 int changelogRev = df.getChangesetLocalRevision(HgRepository.TIP); 66 int changelogRev = df.getChangesetLocalRevision(HgRepository.TIP);