comparison src/org/tmatesoft/hg/internal/RevlogStream.java @ 520:1ee452f31187

Experimental support for inverse direction history walking. Refactored/streamlined cancellation in HgLogCommand and down the stack
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Fri, 21 Dec 2012 21:20:26 +0100
parents 299870249a28
children 0f6fa88e2162
comparison
equal deleted inserted replaced
519:934037edbea0 520:1ee452f31187
27 import org.tmatesoft.hg.repo.HgInternals; 27 import org.tmatesoft.hg.repo.HgInternals;
28 import org.tmatesoft.hg.repo.HgInvalidControlFileException; 28 import org.tmatesoft.hg.repo.HgInvalidControlFileException;
29 import org.tmatesoft.hg.repo.HgInvalidRevisionException; 29 import org.tmatesoft.hg.repo.HgInvalidRevisionException;
30 import org.tmatesoft.hg.repo.HgInvalidStateException; 30 import org.tmatesoft.hg.repo.HgInvalidStateException;
31 import org.tmatesoft.hg.repo.HgRepository; 31 import org.tmatesoft.hg.repo.HgRepository;
32 import org.tmatesoft.hg.util.Adaptable;
32 33
33 34
34 /** 35 /**
35 * ? Single RevlogStream per file per repository with accessor to record access session (e.g. with back/forward operations), 36 * ? Single RevlogStream per file per repository with accessor to record access session (e.g. with back/forward operations),
36 * or numerous RevlogStream with separate representation of the underlying data (cached, lazy ChunkStream)? 37 * or numerous RevlogStream with separate representation of the underlying data (cached, lazy ChunkStream)?
380 class ReaderN1 { 381 class ReaderN1 {
381 private final Inspector inspector; 382 private final Inspector inspector;
382 private final boolean needData; 383 private final boolean needData;
383 private DataAccess daIndex = null, daData = null; 384 private DataAccess daIndex = null, daData = null;
384 private Lifecycle.BasicCallback cb = null; 385 private Lifecycle.BasicCallback cb = null;
386 private Lifecycle lifecycleListener = null;
385 private int lastRevisionRead = BAD_REVISION; 387 private int lastRevisionRead = BAD_REVISION;
386 private DataAccess lastUserData; 388 private DataAccess lastUserData;
387 // next are to track two major bottlenecks - patch application and actual time spent in inspector 389 // next are to track two major bottlenecks - patch application and actual time spent in inspector
388 // private long applyTime, inspectorTime; // TIMING 390 // private long applyTime, inspectorTime; // TIMING
389 391
397 public void start(int totalWork) { 399 public void start(int totalWork) {
398 daIndex = getIndexStream(); 400 daIndex = getIndexStream();
399 if (needData && !inline) { 401 if (needData && !inline) {
400 daData = getDataStream(); 402 daData = getDataStream();
401 } 403 }
402 if (inspector instanceof Lifecycle) { 404 lifecycleListener = Adaptable.Factory.getAdapter(inspector, Lifecycle.class, null);
405 if (lifecycleListener != null) {
403 cb = new Lifecycle.BasicCallback(); 406 cb = new Lifecycle.BasicCallback();
404 ((Lifecycle) inspector).start(totalWork, cb, cb); 407 lifecycleListener.start(totalWork, cb, cb);
405 } 408 }
406 // applyTime = inspectorTime = 0; // TIMING 409 // applyTime = inspectorTime = 0; // TIMING
407 } 410 }
408 411
412 // invoked only once per instance
409 public void finish() { 413 public void finish() {
410 if (lastUserData != null) { 414 if (lastUserData != null) {
411 lastUserData.done(); 415 lastUserData.done();
412 lastUserData = null; 416 lastUserData = null;
413 } 417 }
414 if (inspector instanceof Lifecycle) { 418 if (lifecycleListener != null) {
415 ((Lifecycle) inspector).finish(cb); 419 lifecycleListener.finish(cb);
420 lifecycleListener = null;
421 cb = null;
422
416 } 423 }
417 daIndex.done(); 424 daIndex.done();
418 if (daData != null) { 425 if (daData != null) {
419 daData.done(); 426 daData.done();
427 daData = null;
420 } 428 }
421 // System.out.printf("applyTime:%d ms, inspectorTime: %d ms\n", applyTime, inspectorTime); // TIMING 429 // System.out.printf("applyTime:%d ms, inspectorTime: %d ms\n", applyTime, inspectorTime); // TIMING
422 } 430 }
423 431
432 // may be invoked few times per instance life
424 public boolean range(int start, int end) throws IOException { 433 public boolean range(int start, int end) throws IOException {
425 byte[] nodeidBuf = new byte[20]; 434 byte[] nodeidBuf = new byte[20];
426 int i; 435 int i;
427 // it (i.e. replace with i >= start) 436 // it (i.e. replace with i >= start)
428 if (needData && (i = getBaseRevision(start)) < start) { 437 if (needData && (i = getBaseRevision(start)) < start) {