Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/Revlog.java @ 135:3959bffb14e9
explicit op name instead math op to get last rev number
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Wed, 16 Feb 2011 22:00:39 +0100 |
parents | c0cc2535462c |
children | d5268ca7715b |
comparison
equal
deleted
inserted
replaced
134:afac8ddc5dd2 | 135:3959bffb14e9 |
---|---|
60 | 60 |
61 public final HgRepository getRepo() { | 61 public final HgRepository getRepo() { |
62 return repo; | 62 return repo; |
63 } | 63 } |
64 | 64 |
65 public int getRevisionCount() { | 65 public final int getRevisionCount() { |
66 return content.revisionCount(); | 66 return content.revisionCount(); |
67 } | 67 } |
68 | 68 |
69 public Nodeid getRevision(int revision) { | 69 public final int getLastRevision() { |
70 return content.revisionCount() - 1; | |
71 } | |
72 | |
73 public final Nodeid getRevision(int revision) { | |
70 // XXX cache nodeids? | 74 // XXX cache nodeids? |
71 return Nodeid.fromBinary(content.nodeid(revision), 0); | 75 return Nodeid.fromBinary(content.nodeid(revision), 0); |
72 } | 76 } |
73 | 77 |
74 public int getLocalRevision(Nodeid nid) { | 78 public final int getLocalRevision(Nodeid nid) { |
75 int revision = content.findLocalRevisionNumber(nid); | 79 int revision = content.findLocalRevisionNumber(nid); |
76 if (revision == BAD_REVISION) { | 80 if (revision == BAD_REVISION) { |
77 throw new IllegalArgumentException(String.format("%s doesn't represent a revision of %s", nid.toString(), this /*XXX HgDataFile.getPath might be more suitable here*/)); | 81 throw new IllegalArgumentException(String.format("%s doesn't represent a revision of %s", nid.toString(), this /*XXX HgDataFile.getPath might be more suitable here*/)); |
78 } | 82 } |
79 return revision; | 83 return revision; |
80 } | 84 } |
81 | 85 |
82 // Till now, i follow approach that NULL nodeid is never part of revlog | 86 // Till now, i follow approach that NULL nodeid is never part of revlog |
83 public boolean isKnown(Nodeid nodeid) { | 87 public final boolean isKnown(Nodeid nodeid) { |
84 final int rn = content.findLocalRevisionNumber(nodeid); | 88 final int rn = content.findLocalRevisionNumber(nodeid); |
85 if (Integer.MIN_VALUE == rn) { | 89 if (Integer.MIN_VALUE == rn) { |
86 return false; | 90 return false; |
87 } | 91 } |
88 if (rn < 0 || rn >= content.revisionCount()) { | 92 if (rn < 0 || rn >= content.revisionCount()) { |