Mercurial > jhg
comparison src/org/tmatesoft/hg/internal/ChangelogHelper.java @ 154:ba2bf656f00f
Changeset => RawChangeset
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 24 Feb 2011 22:16:19 +0100 |
parents | 1c1891ad1c73 |
children | f052f40839ec |
comparison
equal
deleted
inserted
replaced
153:ab7ea2ac21cb | 154:ba2bf656f00f |
---|---|
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.repo.HgChangelog.Changeset; | 21 import org.tmatesoft.hg.repo.HgChangelog.RawChangeset; |
22 import org.tmatesoft.hg.repo.HgDataFile; | 22 import org.tmatesoft.hg.repo.HgDataFile; |
23 import org.tmatesoft.hg.repo.HgInternals; | 23 import org.tmatesoft.hg.repo.HgInternals; |
24 import org.tmatesoft.hg.repo.HgRepository; | 24 import org.tmatesoft.hg.repo.HgRepository; |
25 import org.tmatesoft.hg.util.Path; | 25 import org.tmatesoft.hg.util.Path; |
26 | 26 |
30 * @author TMate Software Ltd. | 30 * @author TMate Software Ltd. |
31 */ | 31 */ |
32 public class ChangelogHelper { | 32 public class ChangelogHelper { |
33 private final int leftBoundary; | 33 private final int leftBoundary; |
34 private final HgRepository repo; | 34 private final HgRepository repo; |
35 private final TreeMap<Integer, Changeset> cache = new TreeMap<Integer, Changeset>(); | 35 private final TreeMap<Integer, RawChangeset> cache = new TreeMap<Integer, RawChangeset>(); |
36 private String nextCommitAuthor; | 36 private String nextCommitAuthor; |
37 | 37 |
38 /** | 38 /** |
39 * @param hgRepo | 39 * @param hgRepo |
40 * @param leftBoundaryRevision walker never visits revisions with local numbers less than specified, | 40 * @param leftBoundaryRevision walker never visits revisions with local numbers less than specified, |
56 * Walks changelog in reverse order | 56 * Walks changelog in reverse order |
57 * @param file | 57 * @param file |
58 * @return changeset where specified file is mentioned among affected files, or | 58 * @return changeset where specified file is mentioned among affected files, or |
59 * <code>null</code> if none found up to leftBoundary | 59 * <code>null</code> if none found up to leftBoundary |
60 */ | 60 */ |
61 public Changeset findLatestChangeWith(Path file) { | 61 public RawChangeset findLatestChangeWith(Path file) { |
62 HgDataFile df = repo.getFileNode(file); | 62 HgDataFile df = repo.getFileNode(file); |
63 int changelogRev = df.getChangesetLocalRevision(HgRepository.TIP); | 63 int changelogRev = df.getChangesetLocalRevision(HgRepository.TIP); |
64 if (changelogRev >= leftBoundary) { | 64 if (changelogRev >= leftBoundary) { |
65 // the method is likely to be invoked for different files, | 65 // the method is likely to be invoked for different files, |
66 // while changesets might be the same. Cache 'em not to read too much. | 66 // while changesets might be the same. Cache 'em not to read too much. |
67 Changeset cs = cache.get(changelogRev); | 67 RawChangeset cs = cache.get(changelogRev); |
68 if (cs == null) { | 68 if (cs == null) { |
69 cs = repo.getChangelog().range(changelogRev, changelogRev).get(0); | 69 cs = repo.getChangelog().range(changelogRev, changelogRev).get(0); |
70 cache.put(changelogRev, cs); | 70 cache.put(changelogRev, cs); |
71 } | 71 } |
72 return cs; | 72 return cs; |