comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 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
comparison
equal deleted inserted replaced
415:ee8264d80747 416:d30083c80d52
86 public Path getPath() { 86 public Path getPath() {
87 return path; // hgRepo.backresolve(this) -> name? In this case, what about hashed long names? 87 return path; // hgRepo.backresolve(this) -> name? In this case, what about hashed long names?
88 } 88 }
89 89
90 /** 90 /**
91 * Handy shorthand for {@link #length(int) length(getRevisionIndex(nodeid))} 91 * Handy shorthand for {@link #getLength(int) length(getRevisionIndex(nodeid))}
92 * 92 *
93 * @param nodeid revision of the file 93 * @param nodeid revision of the file
94 * 94 *
95 * @return size of the file content at the given revision 95 * @return size of the file content at the given revision
96 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog (<em>runtime exception</em>) 96 * @throws HgInvalidRevisionException if supplied nodeid doesn't identify any revision from this revlog (<em>runtime exception</em>)
97 * @throws HgInvalidControlFileException if access to revlog index/data entry failed 97 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
98 */ 98 */
99 public int length(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException { 99 public int getLength(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException {
100 try { 100 try {
101 return length(getRevisionIndex(nodeid)); 101 return getLength(getRevisionIndex(nodeid));
102 } catch (HgInvalidControlFileException ex) { 102 } catch (HgInvalidControlFileException ex) {
103 throw ex.isRevisionSet() ? ex : ex.setRevision(nodeid); 103 throw ex.isRevisionSet() ? ex : ex.setRevision(nodeid);
104 } catch (HgInvalidRevisionException ex) { 104 } catch (HgInvalidRevisionException ex) {
105 throw ex.isRevisionSet() ? ex : ex.setRevision(nodeid); 105 throw ex.isRevisionSet() ? ex : ex.setRevision(nodeid);
106 } 106 }
107 } 107 }
108 108
109 /** 109 /**
110 * @deprecated Use {@link #getLength(Nodeid)} instead
111 */
112 @Deprecated
113 public int length(Nodeid nodeid) throws HgInvalidControlFileException, HgInvalidRevisionException {
114 return getLength(nodeid);
115 }
116
117 /**
110 * @param fileRevisionIndex - revision local index, non-negative. From predefined constants, only {@link HgRepository#TIP} makes sense. 118 * @param fileRevisionIndex - revision local index, non-negative. From predefined constants, only {@link HgRepository#TIP} makes sense.
111 * @return size of the file content at the revision identified by local revision number. 119 * @return size of the file content at the revision identified by local revision number.
112 * @throws HgInvalidRevisionException if supplied argument doesn't represent revision index in this revlog (<em>runtime exception</em>) 120 * @throws HgInvalidRevisionException if supplied argument doesn't represent revision index in this revlog (<em>runtime exception</em>)
113 * @throws HgInvalidControlFileException if access to revlog index/data entry failed 121 * @throws HgInvalidControlFileException if access to revlog index/data entry failed
114 */ 122 */
115 public int length(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { 123 public int getLength(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException {
116 if (wrongRevisionIndex(fileRevisionIndex) || fileRevisionIndex == BAD_REVISION) { 124 if (wrongRevisionIndex(fileRevisionIndex) || fileRevisionIndex == BAD_REVISION) {
117 throw new HgInvalidRevisionException(fileRevisionIndex); 125 throw new HgInvalidRevisionException(fileRevisionIndex);
118 } 126 }
119 if (fileRevisionIndex == TIP) { 127 if (fileRevisionIndex == TIP) {
120 fileRevisionIndex = getLastRevision(); 128 fileRevisionIndex = getLastRevision();
135 final int dataLen = content.dataLength(fileRevisionIndex); 143 final int dataLen = content.dataLength(fileRevisionIndex);
136 if (metadata.known(fileRevisionIndex)) { 144 if (metadata.known(fileRevisionIndex)) {
137 return dataLen - metadata.dataOffset(fileRevisionIndex); 145 return dataLen - metadata.dataOffset(fileRevisionIndex);
138 } 146 }
139 return dataLen; 147 return dataLen;
148 }
149
150 /**
151 * @deprecated Use {@link #getLength(int)} instead
152 */
153 @Deprecated
154 public int length(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException {
155 return getLength(fileRevisionIndex);
140 } 156 }
141 157
142 /** 158 /**
143 * Reads content of the file from working directory. If file present in the working directory, its actual content without 159 * Reads content of the file from working directory. If file present in the working directory, its actual content without
144 * any filters is supplied through the sink. If file does not exist in the working dir, this method provides content of a file 160 * any filters is supplied through the sink. If file does not exist in the working dir, this method provides content of a file
547 public HgManifest.Flags getFlagsAtChangeset(int changesetRevisionIndex) { 563 public HgManifest.Flags getFlagsAtChangeset(int changesetRevisionIndex) {
548 } 564 }
549 */ 565 */
550 566
551 /** 567 /**
568 *
569 * @param fileRevisionIndex - revision local index, non-negative, or {@link HgRepository#TIP}.
552 * FIXME EXCEPTIONS 570 * FIXME EXCEPTIONS
553 * @throws HgInvalidControlFileException 571 * @throws HgInvalidControlFileException
554 * @throws HgInvalidRevisionException 572 * @throws HgInvalidRevisionException
555 */ 573 */
556 public HgManifest.Flags getFlags(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException { 574 public HgManifest.Flags getFlags(int fileRevisionIndex) throws HgInvalidControlFileException, HgInvalidRevisionException {
557 int changesetRevIndex = getChangesetRevisionIndex(fileRevisionIndex); 575 int changesetRevIndex = getChangesetRevisionIndex(fileRevisionIndex);
558 return getRepo().getManifest().extractFlags(changesetRevIndex, getPath()); 576 return getRepo().getManifest().extractFlags(changesetRevIndex, getPath());
559 } 577 }
560 578
561 @Override 579 @Override
562 public String toString() { 580 public String toString() {
563 StringBuilder sb = new StringBuilder(getClass().getSimpleName()); 581 StringBuilder sb = new StringBuilder(getClass().getSimpleName());
564 sb.append('('); 582 sb.append('(');
565 sb.append(getPath()); 583 sb.append(getPath());