comparison src/org/tmatesoft/hg/repo/Revlog.java @ 431:12f668401613

FIXMEs: awkward API refactored, what need to be internal got hidden; public aspects got captured in slim interfaces
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Thu, 29 Mar 2012 20:54:04 +0200
parents 48f993aa2f41
children 1fc0da631200
comparison
equal deleted inserted replaced
430:d280759c2a3f 431:12f668401613
288 * @param end 288 * @param end
289 * @param inspector 289 * @param inspector
290 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em> 290 * @throws HgRuntimeException subclass thereof to indicate issues with the library. <em>Runtime exception</em>
291 */ 291 */
292 @Experimental 292 @Experimental
293 public void walk(int start, int end, final Revlog.Inspector inspector) throws HgRuntimeException { 293 public void indexWalk(int start, int end, final Revlog.Inspector inspector) throws HgRuntimeException {
294 int lastRev = getLastRevision(); 294 int lastRev = getLastRevision();
295 if (start == TIP) { 295 if (start == TIP) {
296 start = lastRev; 296 start = lastRev;
297 } 297 }
298 if (end == TIP) { 298 if (end == TIP) {
385 // real improvement (IntMap has 2n capacity, and element lookup is log(n) instead of array's constant) 385 // real improvement (IntMap has 2n capacity, and element lookup is log(n) instead of array's constant)
386 secondParent = new Nodeid[revisionCount]; 386 secondParent = new Nodeid[revisionCount];
387 // 387 //
388 sequential = new Nodeid[revisionCount]; 388 sequential = new Nodeid[revisionCount];
389 sorted = new Nodeid[revisionCount]; 389 sorted = new Nodeid[revisionCount];
390 Revlog.this.walk(0, TIP, this); 390 Revlog.this.indexWalk(0, TIP, this);
391 Arrays.sort(sorted); 391 Arrays.sort(sorted);
392 sorted2natural = new int[revisionCount]; 392 sorted2natural = new int[revisionCount];
393 for (int i = 0; i < revisionCount; i++) { 393 for (int i = 0; i < revisionCount; i++) {
394 Nodeid n = sequential[i]; 394 Nodeid n = sequential[i];
395 int x = Arrays.binarySearch(sorted, n); 395 int x = Arrays.binarySearch(sorted, n);
570 public RevisionMap init(/*XXX Pool<Nodeid> to reuse nodeids, if possible. */) throws HgInvalidControlFileException{ 570 public RevisionMap init(/*XXX Pool<Nodeid> to reuse nodeids, if possible. */) throws HgInvalidControlFileException{
571 // XXX HgRepository.register((RepoChangeListener) this); // listen to changes in repo, re-init if needed? 571 // XXX HgRepository.register((RepoChangeListener) this); // listen to changes in repo, re-init if needed?
572 final int revisionCount = Revlog.this.getRevisionCount(); 572 final int revisionCount = Revlog.this.getRevisionCount();
573 sequential = new Nodeid[revisionCount]; 573 sequential = new Nodeid[revisionCount];
574 sorted = new Nodeid[revisionCount]; 574 sorted = new Nodeid[revisionCount];
575 Revlog.this.walk(0, TIP, this); 575 Revlog.this.indexWalk(0, TIP, this);
576 // next is alternative to Arrays.sort(sorted), and build sorted2natural looking up each element of sequential in sorted. 576 // next is alternative to Arrays.sort(sorted), and build sorted2natural looking up each element of sequential in sorted.
577 // the way sorted2natural was build is O(n*log n). 577 // the way sorted2natural was build is O(n*log n).
578 final ArrayHelper ah = new ArrayHelper(); 578 final ArrayHelper ah = new ArrayHelper();
579 ah.sort(sorted); 579 ah.sort(sorted);
580 // note, values in ArrayHelper#getReversed are 1-based indexes, not 0-based 580 // note, values in ArrayHelper#getReversed are 1-based indexes, not 0-based