Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/Revlog.java @ 534:243202f1bda5
Commit: refactor revision creation code from clone command to work separately, fit into existing library structure
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Mon, 04 Feb 2013 18:00:55 +0100 |
parents | b3c16d1aede0 |
children | dd4f6311af52 |
comparison
equal
deleted
inserted
replaced
533:e6f72c9829a6 | 534:243202f1bda5 |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2010-2012 TMate Software Ltd | 2 * Copyright (c) 2010-2013 TMate Software Ltd |
3 * | 3 * |
4 * This program is free software; you can redistribute it and/or modify | 4 * This program is free software; you can redistribute it and/or modify |
5 * it under the terms of the GNU General Public License as published by | 5 * it under the terms of the GNU General Public License as published by |
6 * the Free Software Foundation; version 2 of the License. | 6 * the Free Software Foundation; version 2 of the License. |
7 * | 7 * |
82 public final int getRevisionCount() throws HgRuntimeException { | 82 public final int getRevisionCount() throws HgRuntimeException { |
83 return content.revisionCount(); | 83 return content.revisionCount(); |
84 } | 84 } |
85 | 85 |
86 /** | 86 /** |
87 * @return index of last known revision, a.k.a. {@link HgRepository#TIP} | 87 * @return index of last known revision, a.k.a. {@link HgRepository#TIP}, or {@link HgRepository#NO_REVISION} if revlog is empty |
88 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> | 88 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> |
89 */ | 89 */ |
90 public final int getLastRevision() throws HgRuntimeException { | 90 public final int getLastRevision() throws HgRuntimeException { |
91 return content.revisionCount() - 1; | 91 // although old code gives correct result when revlog is empty (NO_REVISION deliberately == -1), |
92 // it's still better to be explicit | |
93 int revCount = content.revisionCount(); | |
94 return revCount == 0 ? NO_REVISION : revCount - 1; | |
92 } | 95 } |
93 | 96 |
94 /** | 97 /** |
95 * Map revision index to unique revision identifier (nodeid). | 98 * Map revision index to unique revision identifier (nodeid). |
96 * | 99 * |