Mercurial > jhg
changeset 416:d30083c80d52
Better names - non-confusing and aligned with the rest of API
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 22 Mar 2012 19:11:33 +0100 |
parents | ee8264d80747 |
children | ccd7d25e5aea |
files | cmdline/org/tmatesoft/hg/console/Main.java src/org/tmatesoft/hg/repo/HgDataFile.java src/org/tmatesoft/hg/repo/Revlog.java |
diffstat | 3 files changed, 30 insertions(+), 12 deletions(-) [+] |
line wrap: on
line diff
--- a/cmdline/org/tmatesoft/hg/console/Main.java Thu Mar 22 18:54:11 2012 +0100 +++ b/cmdline/org/tmatesoft/hg/console/Main.java Thu Mar 22 19:11:33 2012 +0100 @@ -602,7 +602,7 @@ // expected: 359, 2123, 3079 byte[] b = s.getBytes(); final Nodeid nid = Nodeid.fromAscii(b, 0, b.length); - System.out.println(s + " : " + n.length(nid)); + System.out.println(s + " : " + n.getLength(nid)); } }
--- a/src/org/tmatesoft/hg/repo/HgDataFile.java Thu Mar 22 18:54:11 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/HgDataFile.java Thu Mar 22 19:11:33 2012 +0100 @@ -88,7 +88,7 @@ } /** - * Handy shorthand for {@link #length(int) length(getRevisionIndex(nodeid))} + * Handy shorthand for {@link #getLength(int) length(getRevisionIndex(nodeid))} * * @param nodeid revision of the file * @@ -96,9 +96,9 @@ * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog (<em>runtime exception</em>) * @throws HgInvalidControlFileException if access to revlog index/data entry failed */ - public int length(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException { + public int getLength(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException { try { - return length(getRevisionIndex(nodeid)); + return getLength(getRevisionIndex(nodeid)); } catch (HgInvalidControlFileException ex) { throw ex.isRevisionSet() ? ex : ex.setRevision(nodeid); } catch (HgInvalidRevisionException ex) { @@ -107,12 +107,20 @@ } /** + * @deprecated Use {@link #getLength(Nodeid)} instead + */ + @Deprecated + public int length(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException { + return getLength(nodeid); + } + + /** * @param fileRevisionIndex - revision local index, non-negative. From predefined constants, only {@link HgRepository#TIP} makes sense. * @return size of the file content at the revision identified by local revision number. * @throws HgInvalidRevisionException if supplied argument doesn't represent revision index in this revlog (<em>runtime exception</em>) * @throws HgInvalidControlFileException if access to revlog index/data entry failed */ - public int length(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { + public int getLength(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { if (wrongRevisionIndex(fileRevisionIndex) || fileRevisionIndex == BAD_REVISION) { throw new HgInvalidRevisionException(fileRevisionIndex); } @@ -138,6 +146,14 @@ } return dataLen; } + + /** + * @deprecated Use {@link #getLength(int)} instead + */ + @Deprecated + public int length(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { + return getLength(fileRevisionIndex); + } /** * Reads content of the file from working directory. If file present in the working directory, its actual content without @@ -549,6 +565,8 @@ */ /** + * + * @param fileRevisionIndex - revision local index, non-negative, or {@link HgRepository#TIP}. * FIXME EXCEPTIONS * @throws HgInvalidControlFileException * @throws HgInvalidRevisionException @@ -557,7 +575,7 @@ int changesetRevIndex = getChangesetRevisionIndex(fileRevisionIndex); return getRepo().getManifest().extractFlags(changesetRevIndex, getPath()); } - + @Override public String toString() { StringBuilder sb = new StringBuilder(getClass().getSimpleName());
--- a/src/org/tmatesoft/hg/repo/Revlog.java Thu Mar 22 18:54:11 2012 +0100 +++ b/src/org/tmatesoft/hg/repo/Revlog.java Thu Mar 22 19:11:33 2012 +0100 @@ -196,25 +196,25 @@ /** * Access to revision data as is (decompressed, but otherwise unprocessed, i.e. not parsed for e.g. changeset or manifest entries). * - * @param fileRevisionIndex index of this revlog change (not a changelog revision index), non-negative. From predefined constants, only {@link HgRepository#TIP} makes sense. + * @param revisionIndex index of this revlog change (not a changelog revision index), non-negative. From predefined constants, only {@link HgRepository#TIP} makes sense. * @param sink data destination * * @throws HgInvalidRevisionException if supplied argument doesn't represent revision index in this revlog * @throws HgInvalidControlFileException if access to revlog index/data entry failed * @throws CancelledException if content retrieval operation was cancelled */ - protected void rawContent(int fileRevisionIndex, ByteChannel sink) throws HgInvalidControlFileException, CancelledException, HgInvalidRevisionException { + protected void rawContent(int revisionIndex, ByteChannel sink) throws HgInvalidControlFileException, CancelledException, HgInvalidRevisionException { if (sink == null) { throw new IllegalArgumentException(); } try { ContentPipe insp = new ContentPipe(sink, 0, repo.getContext().getLog()); insp.checkCancelled(); - content.iterate(fileRevisionIndex, fileRevisionIndex, true, insp); + content.iterate(revisionIndex, revisionIndex, true, insp); insp.checkFailed(); } catch (IOException ex) { - HgInvalidControlFileException e = new HgInvalidControlFileException(String.format("Access to revision %d content failed", fileRevisionIndex), ex, null); - e.setRevisionIndex(fileRevisionIndex); + HgInvalidControlFileException e = new HgInvalidControlFileException(String.format("Access to revision %d content failed", revisionIndex), ex, null); + e.setRevisionIndex(revisionIndex); // FIXME e.setFileName(content.getIndexFile() or this.getHumanFriendlyPath()) - shall decide whether // protected abstract getPath() with impl in HgDataFile, HgManifest and HgChangelog or path is data of either Revlog or RevlogStream // Do the same (add file name) below @@ -223,7 +223,7 @@ throw ex; } catch (HgException ex) { HgInvalidControlFileException e = new HgInvalidControlFileException(ex.getClass().getSimpleName(), ex, null); - e.setRevisionIndex(fileRevisionIndex); + e.setRevisionIndex(revisionIndex); throw e; } }