comparison src/org/tmatesoft/hg/core/HgFileRevision.java @ 628:6526d8adbc0f

Explicit HgRuntimeException to facilitate easy switch from runtime to checked exceptions
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Wed, 22 May 2013 15:52:31 +0200
parents 934037edbea0
children 5050ee565bd1
comparison
equal deleted inserted replaced
627:5153eb73b18d 628:6526d8adbc0f
105 flags = df.getFlags(revIdx); 105 flags = df.getFlags(revIdx);
106 } 106 }
107 return flags; 107 return flags;
108 } 108 }
109 109
110 public boolean wasCopied() throws HgException { 110 /**
111 * @return <code>true</code> if this file revision was created as a result of a copy/rename
112 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
113 */
114 public boolean wasCopied() throws HgRuntimeException {
111 if (isCopy == null) { 115 if (isCopy == null) {
112 checkCopy(); 116 checkCopy();
113 } 117 }
114 return isCopy.booleanValue(); 118 return isCopy.booleanValue();
115 } 119 }
116 /** 120 /**
117 * @return <code>null</code> if {@link #wasCopied()} is <code>false</code>, name of the copy source otherwise. 121 * @return <code>null</code> if {@link #wasCopied()} is <code>false</code>, name of the copy source otherwise.
122 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
118 */ 123 */
119 public Path getOriginIfCopy() throws HgException { 124 public Path getOriginIfCopy() throws HgRuntimeException {
120 if (wasCopied()) { 125 if (wasCopied()) {
121 return origin; 126 return origin;
122 } 127 }
123 return null; 128 return null;
124 } 129 }
143 parents = new Pair<Nodeid, Nodeid>(Nodeid.fromBinary(p1, 0), Nodeid.fromBinary(p2, 0)); 148 parents = new Pair<Nodeid, Nodeid>(Nodeid.fromBinary(p1, 0), Nodeid.fromBinary(p2, 0));
144 } 149 }
145 return parents; 150 return parents;
146 } 151 }
147 152
148 public void putContentTo(ByteChannel sink) throws HgException, CancelledException { 153 /**
154 * Pipe content of this file revision into the sink
155 * @param sink accepts file revision content
156 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
157 * @throws CancelledException if execution of the operation was cancelled
158 */
159 public void putContentTo(ByteChannel sink) throws HgRuntimeException, CancelledException {
149 HgDataFile fn = repo.getFileNode(path); 160 HgDataFile fn = repo.getFileNode(path);
150 int revisionIndex = fn.getRevisionIndex(revision); 161 int revisionIndex = fn.getRevisionIndex(revision);
151 fn.contentWithFilters(revisionIndex, sink); 162 fn.contentWithFilters(revisionIndex, sink);
152 } 163 }
153 164
154 @Override 165 @Override
155 public String toString() { 166 public String toString() {
156 return String.format("HgFileRevision(%s, %s)", getPath().toString(), revision.shortNotation()); 167 return String.format("HgFileRevision(%s, %s)", getPath().toString(), revision.shortNotation());
157 } 168 }
158 169
159 private void checkCopy() throws HgException { 170 private void checkCopy() throws HgRuntimeException {
160 HgDataFile fn = repo.getFileNode(path); 171 HgDataFile fn = repo.getFileNode(path);
161 if (fn.isCopy()) { 172 if (fn.isCopy()) {
162 if (fn.getRevision(0).equals(revision)) { 173 if (fn.getRevision(0).equals(revision)) {
163 // this HgFileRevision represents first revision of the copy 174 // this HgFileRevision represents first revision of the copy
164 isCopy = Boolean.TRUE; 175 isCopy = Boolean.TRUE;