# HG changeset patch # User Artem Tikhomirov # Date 1299723529 -3600 # Node ID a5198b6487dc14b36f8c4d537e74656d54994360 # Parent c17a08095e4420202ac1b2d939ef6d5f8bebb569 Record reasons for slow status for future reference diff -r c17a08095e44 -r a5198b6487dc src/org/tmatesoft/hg/repo/HgDataFile.java --- a/src/org/tmatesoft/hg/repo/HgDataFile.java Wed Mar 09 13:57:33 2011 +0100 +++ b/src/org/tmatesoft/hg/repo/HgDataFile.java Thu Mar 10 03:18:49 2011 +0100 @@ -192,16 +192,23 @@ public boolean isCopy() throws HgDataStreamException { if (metadata == null || !metadata.checked(0)) { // content() always initializes metadata. - // FIXME this is expensive way to find out metadata, distinct RevlogStream.Iterator would be better. + // FIXME this is expensive way to find out metadata, distinct RevlogStream.Iterator would be better. + // Alternatively, may parameterize MetadataContentPipe to do prepare only. + // For reference, when throwing CancelledException, hg status -A --rev 3:80 takes 70 ms + // however, if we just consume buffer instead (buffer.position(buffer.limit()), same command takes ~320ms + // (compared to command-line counterpart of 190ms) try { content(0, new ByteChannel() { // No-op channel - public int write(ByteBuffer buffer) throws IOException { + public int write(ByteBuffer buffer) throws IOException, CancelledException { // pretend we consumed whole buffer - int rv = buffer.remaining(); - buffer.position(buffer.limit()); - return rv; +// int rv = buffer.remaining(); +// buffer.position(buffer.limit()); +// return rv; + throw new CancelledException(); } }); + } catch (CancelledException ex) { + // it's ok, we did that } catch (Exception ex) { throw new HgDataStreamException("Can't initialize metadata", ex); }