Mercurial > hg4j
comparison src/org/tmatesoft/hg/repo/HgDataFile.java @ 163:a5198b6487dc
Record reasons for slow status for future reference
author | Artem Tikhomirov <tikhomirov.artem@gmail.com> |
---|---|
date | Thu, 10 Mar 2011 03:18:49 +0100 |
parents | b413b16d10a5 |
children | 41a778e3fd31 |
comparison
equal
deleted
inserted
replaced
162:c17a08095e44 | 163:a5198b6487dc |
---|---|
190 } | 190 } |
191 | 191 |
192 public boolean isCopy() throws HgDataStreamException { | 192 public boolean isCopy() throws HgDataStreamException { |
193 if (metadata == null || !metadata.checked(0)) { | 193 if (metadata == null || !metadata.checked(0)) { |
194 // content() always initializes metadata. | 194 // content() always initializes metadata. |
195 // FIXME this is expensive way to find out metadata, distinct RevlogStream.Iterator would be better. | 195 // FIXME this is expensive way to find out metadata, distinct RevlogStream.Iterator would be better. |
196 // Alternatively, may parameterize MetadataContentPipe to do prepare only. | |
197 // For reference, when throwing CancelledException, hg status -A --rev 3:80 takes 70 ms | |
198 // however, if we just consume buffer instead (buffer.position(buffer.limit()), same command takes ~320ms | |
199 // (compared to command-line counterpart of 190ms) | |
196 try { | 200 try { |
197 content(0, new ByteChannel() { // No-op channel | 201 content(0, new ByteChannel() { // No-op channel |
198 public int write(ByteBuffer buffer) throws IOException { | 202 public int write(ByteBuffer buffer) throws IOException, CancelledException { |
199 // pretend we consumed whole buffer | 203 // pretend we consumed whole buffer |
200 int rv = buffer.remaining(); | 204 // int rv = buffer.remaining(); |
201 buffer.position(buffer.limit()); | 205 // buffer.position(buffer.limit()); |
202 return rv; | 206 // return rv; |
207 throw new CancelledException(); | |
203 } | 208 } |
204 }); | 209 }); |
210 } catch (CancelledException ex) { | |
211 // it's ok, we did that | |
205 } catch (Exception ex) { | 212 } catch (Exception ex) { |
206 throw new HgDataStreamException("Can't initialize metadata", ex); | 213 throw new HgDataStreamException("Can't initialize metadata", ex); |
207 } | 214 } |
208 } | 215 } |
209 if (!metadata.known(0)) { | 216 if (!metadata.known(0)) { |