comparison src/org/tmatesoft/hg/repo/Revlog.java @ 693:32b0d19e8aba

Fix file.isCopy() use for Log/History command. File revisions originating from another file list no parents even in the middle of revision chain
author Artem Tikhomirov <tikhomirov.artem@gmail.com>
date Mon, 05 Aug 2013 12:45:36 +0200
parents 6526d8adbc0f
children 7efabe0cddcf
comparison
equal deleted inserted replaced
692:e970b333f284 693:32b0d19e8aba
365 revisionInsp.next(revisionIndex, nid, linkRevIndex); 365 revisionInsp.next(revisionIndex, nid, linkRevIndex);
366 } 366 }
367 if (parentInsp != null) { 367 if (parentInsp != null) {
368 allRevisions[i] = nid; 368 allRevisions[i] = nid;
369 if (_start > 0) { 369 if (_start > 0) {
370 // there are chances we don't know parents here,
371 // postpone parent dispatching for later, now just collect what's missing
370 firstParentIndexes[i] = parent1RevIndex; 372 firstParentIndexes[i] = parent1RevIndex;
371 secondParentIndexes[i] = parent2RevIndex; 373 secondParentIndexes[i] = parent2RevIndex;
372 if (parent1RevIndex < _start && parent1RevIndex >= 0) { 374 if (parent1RevIndex < _start && parent1RevIndex >= 0) {
373 missingParents.put(parent1RevIndex, null); 375 missingParents.put(parent1RevIndex, null);
374 } 376 }
375 if (parent2RevIndex < _start && parent2RevIndex >= 0) { 377 if (parent2RevIndex < _start && parent2RevIndex >= 0) {
376 missingParents.put(parent2RevIndex, null); 378 missingParents.put(parent2RevIndex, null);
377 } 379 }
378 } else { 380 } else {
381 // we iterate from the very beginning, got every index we'll need
379 Nodeid p1 = parent1RevIndex == -1 ? Nodeid.NULL : allRevisions[parent1RevIndex]; 382 Nodeid p1 = parent1RevIndex == -1 ? Nodeid.NULL : allRevisions[parent1RevIndex];
380 Nodeid p2 = parent2RevIndex == -1 ? Nodeid.NULL : allRevisions[parent2RevIndex]; 383 Nodeid p2 = parent2RevIndex == -1 ? Nodeid.NULL : allRevisions[parent2RevIndex];
381 parentInsp.next(revisionIndex, allRevisions[i], parent1RevIndex, parent2RevIndex, p1, p2); 384 parentInsp.next(revisionIndex, allRevisions[i], parent1RevIndex, parent2RevIndex, p1, p2);
382 } 385 }
383 i++; 386 i++;
384 } 387 }
385 } 388 }
386 }); 389 });
387 if (parentInsp != null && _start > 0) { 390 if (parentInsp != null && _start > 0 ) {
388 assert missingParents.size() > 0; // in fact, more relaxed than assert. rather 'assume' 391 if (missingParents.size() > 0) {
389 // TODO [post-1.1] int[] IntMap#keys() or even sort of iterator that can modify values 392 // it's possible to get empty missingParents when _start > 0 e.g. when n-th file revision
390 for (int k = missingParents.firstKey(), l = missingParents.lastKey(); k <= l; k++) { 393 // is a copy of another file and hence got -1,-1 parents in this revlog, and we indexWalk(n,n)
391 if (missingParents.containsKey(k)) { 394 for (int k = missingParents.firstKey(), l = missingParents.lastKey(); k <= l; k++) {
392 Nodeid nid = getRepo().getChangelog().getRevision(k); 395 // TODO [post-1.1] int[] IntMap#keys() or even sort of iterator that can modify values
393 missingParents.put(k, nid); 396 if (missingParents.containsKey(k)) {
397 Nodeid nid = getRepo().getChangelog().getRevision(k);
398 missingParents.put(k, nid);
399 }
394 } 400 }
395 } 401 }
396 402
397 for (int i = 0, revNum = _start; i < allRevisions.length; i++, revNum++) { 403 for (int i = 0, revNum = _start; i < allRevisions.length; i++, revNum++) {
398 int riP1 = firstParentIndexes[i]; 404 int riP1 = firstParentIndexes[i];
404 // (don't check for riP1<end as I assume parents come prior to children in the changelog) 410 // (don't check for riP1<end as I assume parents come prior to children in the changelog)
405 p1 = allRevisions[riP1 - start]; 411 p1 = allRevisions[riP1 - start];
406 } else if (riP1 != -1) { 412 } else if (riP1 != -1) {
407 assert riP1 >=0 && riP1 < _start; 413 assert riP1 >=0 && riP1 < _start;
408 p1 = missingParents.get(riP1); 414 p1 = missingParents.get(riP1);
415 assert p1 != null;
409 } 416 }
410 // same for Pp2 417 // same for Pp2
411 if (riP2 >= _start) { 418 if (riP2 >= _start) {
412 p2 = allRevisions[riP2 - start]; 419 p2 = allRevisions[riP2 - start];
413 } else if (riP2 != -1) { 420 } else if (riP2 != -1) {
414 assert riP2 >= 0 && riP2 < _start; 421 assert riP2 >= 0 && riP2 < _start;
415 p2 = missingParents.get(riP2); 422 p2 = missingParents.get(riP2);
423 assert p2 != null;
416 } 424 }
417 parentInsp.next(revNum, allRevisions[i], riP1, riP2, p1, p2); 425 parentInsp.next(revNum, allRevisions[i], riP1, riP2, p1, p2);
418 } 426 }
419 } 427 }
420 } 428 }