Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgDataFile.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 | afac8ddc5dd2 |
children | 1a7a9a20e1f9 |
comparison
equal
deleted
inserted
replaced
134:afac8ddc5dd2 | 135:3959bffb14e9 |
---|---|
95 // for data files need to check heading of the file content for possible metadata | 95 // for data files need to check heading of the file content for possible metadata |
96 // @see http://mercurial.selenic.com/wiki/FileFormats#data.2BAC8- | 96 // @see http://mercurial.selenic.com/wiki/FileFormats#data.2BAC8- |
97 @Override | 97 @Override |
98 public byte[] content(int revision) { | 98 public byte[] content(int revision) { |
99 if (revision == TIP) { | 99 if (revision == TIP) { |
100 revision = content.revisionCount() - 1; // FIXME maxRevision. | 100 revision = getLastRevision(); |
101 } | 101 } |
102 byte[] data = super.content(revision); | 102 byte[] data = super.content(revision); |
103 if (metadata == null) { | 103 if (metadata == null) { |
104 metadata = new Metadata(); | 104 metadata = new Metadata(); |
105 } | 105 } |
152 System.arraycopy(data, toSkip, rv, 0, rv.length); | 152 System.arraycopy(data, toSkip, rv, 0, rv.length); |
153 return rv; | 153 return rv; |
154 } | 154 } |
155 | 155 |
156 public void history(HgChangelog.Inspector inspector) { | 156 public void history(HgChangelog.Inspector inspector) { |
157 history(0, content.revisionCount() - 1, inspector); | 157 history(0, getLastRevision(), inspector); |
158 } | 158 } |
159 | 159 |
160 public void history(int start, int end, HgChangelog.Inspector inspector) { | 160 public void history(int start, int end, HgChangelog.Inspector inspector) { |
161 if (!exists()) { | 161 if (!exists()) { |
162 throw new IllegalStateException("Can't get history of invalid repository file node"); | 162 throw new IllegalStateException("Can't get history of invalid repository file node"); |
163 } | 163 } |
164 final int last = content.revisionCount() - 1; | 164 final int last = getLastRevision(); |
165 if (start < 0 || start > last) { | 165 if (start < 0 || start > last) { |
166 throw new IllegalArgumentException(); | 166 throw new IllegalArgumentException(); |
167 } | 167 } |
168 if (end == TIP) { | 168 if (end == TIP) { |
169 end = last; | 169 end = last; |