Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Graph improvement: When there are multiple inbound merge arrows, try to combine as many as possible into a single riser. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA3-256: |
1eb9f5a81a9af81172a33601cdc6912e |
| User & Date: | drh 2020-06-08 17:10:27.557 |
Context
|
2020-06-08
| ||
| 18:13 | Minor bug fixes in the new merge-riser coalescing logic of the graph generator. ... (check-in: 7688673a8e user: drh tags: trunk) | |
| 17:10 | Graph improvement: When there are multiple inbound merge arrows, try to combine as many as possible into a single riser. ... (check-in: 1eb9f5a81a user: drh tags: trunk) | |
| 12:10 | Update the built-in SQLite to the latest trunk version for testing. ... (check-in: 3ab64c5a4d user: drh tags: trunk) | |
Changes
Changes to src/graph.c.
| ︙ | ︙ | |||
54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
** but which are included just so that we can capture their background color.
*/
struct GraphRow {
int rid; /* The rid for the check-in */
i8 nParent; /* Number of parents. */
i8 nCherrypick; /* Subset of aParent that are cherrypicks */
i8 nNonCherrypick; /* Number of non-cherrypick parents */
int *aParent; /* Array of parents. 0 element is primary .*/
char *zBranch; /* Branch name */
char *zBgClr; /* Background Color */
char zUuid[HNAME_MAX+1]; /* Check-in for file ID */
GraphRow *pNext; /* Next row down in the list of all rows */
GraphRow *pPrev; /* Previous row */
| > | 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
** but which are included just so that we can capture their background color.
*/
struct GraphRow {
int rid; /* The rid for the check-in */
i8 nParent; /* Number of parents. */
i8 nCherrypick; /* Subset of aParent that are cherrypicks */
i8 nNonCherrypick; /* Number of non-cherrypick parents */
u8 nMergeChild; /* Number of merge children */
int *aParent; /* Array of parents. 0 element is primary .*/
char *zBranch; /* Branch name */
char *zBgClr; /* Background Color */
char zUuid[HNAME_MAX+1]; /* Check-in for file ID */
GraphRow *pNext; /* Next row down in the list of all rows */
GraphRow *pPrev; /* Previous row */
|
| ︙ | ︙ | |||
470 471 472 473 474 475 476 |
** the current check-in. If a merge parent is not in the visible section
** of this graph, then no arrows will be drawn for it, so remove it from
** the aParent[] array.
*/
if( (tmFlags & (TIMELINE_DISJOINT|TIMELINE_XMERGE))!=0 ){
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
for(i=1; i<pRow->nParent; i++){
| | > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 |
** the current check-in. If a merge parent is not in the visible section
** of this graph, then no arrows will be drawn for it, so remove it from
** the aParent[] array.
*/
if( (tmFlags & (TIMELINE_DISJOINT|TIMELINE_XMERGE))!=0 ){
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
for(i=1; i<pRow->nParent; i++){
GraphRow *pParent = hashFind(p, pRow->aParent[i]);
if( pParent==0 ){
memmove(pRow->aParent+i, pRow->aParent+i+1,
sizeof(pRow->aParent[0])*(pRow->nParent-i-1));
pRow->nParent--;
if( i<pRow->nNonCherrypick ){
pRow->nNonCherrypick--;
}else{
pRow->nCherrypick--;
}
i--;
}
}
}
}
/* Put the deepest (earliest) merge parent first in the list.
** An off-screen merge parent is considered deepest.
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext ){
if( pRow->nParent<=1 ) continue;
for(i=1; i<pRow->nParent; i++){
GraphRow *pParent = hashFind(p, pRow->aParent[i]);
if( pParent ) pParent->nMergeChild++;
}
if( pRow->nCherrypick>1 ){
int iBest = -1;
int iDeepest = -1;
for(i=pRow->nNonCherrypick; i<pRow->nParent; i++){
GraphRow *pParent = hashFind(p, pRow->aParent[i]);
if( pParent==0 ){
iBest = i;
break;
}
if( pParent->idx>iDeepest ){
iDeepest = pParent->idx;
iBest = i;
}
}
i = pRow->nNonCherrypick;
if( iBest>i ){
int x = pRow->aParent[i];
pRow->aParent[i] = pRow->aParent[iBest];
pRow->aParent[iBest] = x;
}
}
if( pRow->nNonCherrypick>2 ){
int iBest = -1;
int iDeepest = -1;
for(i=1; i<pRow->nNonCherrypick; i++){
GraphRow *pParent = hashFind(p, pRow->aParent[i]);
if( pParent==0 ){
iBest = i;
break;
}
if( pParent->idx>iDeepest ){
iDeepest = pParent->idx;
iBest = i;
}
}
if( iBest>1 ){
int x = pRow->aParent[1];
pRow->aParent[1] = pRow->aParent[iBest];
pRow->aParent[iBest] = x;
}
}
}
/* If the primary parent is in a different branch, but there are
** other parents in the same branch, reorder the parents to make
** the parent from the same branch the primary parent.
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->isDup ) continue;
|
| ︙ | ︙ | |||
666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 |
}
}
/*
** Insert merge rails and merge arrows
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
for(i=1; i<pRow->nParent; i++){
int parentRid = pRow->aParent[i];
pDesc = hashFind(p, parentRid);
if( pDesc==0 ){
/* Merge from a node that is off-screen */
int iMrail = -1;
for(j=0; j<GR_MAX_RAIL; j++){
if( mergeRiserFrom[j]==parentRid ){
iMrail = j;
break;
}
}
if( iMrail==-1 ){
iMrail = findFreeRail(p, pRow->idx, p->pLast->idx, 0);
if( p->mxRail>=GR_MAX_RAIL ) return;
mergeRiserFrom[iMrail] = parentRid;
}
mask = BIT(iMrail);
if( i>=pRow->nNonCherrypick ){
pRow->mergeIn[iMrail] = 2;
pRow->cherrypickDown |= mask;
}else{
pRow->mergeIn[iMrail] = 1;
pRow->mergeDown |= mask;
}
for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}else{
| > > > > > > > > > > > > > > > > > > > > > > > > > > | | | > > > > > | 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 |
}
}
/*
** Insert merge rails and merge arrows
*/
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
int iReuseIdx = -1;
int iReuseRail = -1;
int isCherrypick = 0;
for(i=1; i<pRow->nParent; i++){
int parentRid = pRow->aParent[i];
if( i==pRow->nNonCherrypick ){
iReuseIdx = -1;
iReuseRail = -1;
isCherrypick = 1;
}
pDesc = hashFind(p, parentRid);
if( pDesc==0 ){
/* Merge from a node that is off-screen */
if( iReuseIdx>=p->nRow+1 ){
continue; /* Suppress multiple off-screen merges */
}
int iMrail = -1;
for(j=0; j<GR_MAX_RAIL; j++){
if( mergeRiserFrom[j]==parentRid ){
iMrail = j;
break;
}
}
if( iMrail==-1 ){
iMrail = findFreeRail(p, pRow->idx, p->pLast->idx, 0);
if( p->mxRail>=GR_MAX_RAIL ) return;
mergeRiserFrom[iMrail] = parentRid;
}
iReuseIdx = p->nRow+1;
iReuseRail = iMrail;
mask = BIT(iMrail);
if( i>=pRow->nNonCherrypick ){
pRow->mergeIn[iMrail] = 2;
pRow->cherrypickDown |= mask;
}else{
pRow->mergeIn[iMrail] = 1;
pRow->mergeDown |= mask;
}
for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}else{
/* The merge parent node does exist on this graph */
if( iReuseIdx>pDesc->idx
&& pDesc->nMergeChild==1
){
/* Reuse an existing merge riser */
pDesc->mergeOut = iReuseRail;
if( isCherrypick ){
pDesc->cherrypickUpto = pDesc->idx;
}else{
pDesc->hasNormalOutMerge = 1;
pDesc->mergeUpto = pDesc->idx;
}
}else{
/* Create a new merge for an on-screen node */
createMergeRiser(p, pDesc, pRow, isCherrypick);
if( p->mxRail>=GR_MAX_RAIL ) return;
if( iReuseIdx<0 && pDesc->nMergeChild==1 ){
iReuseIdx = pDesc->idx;
iReuseRail = pDesc->mergeOut;
}
}
}
}
}
/*
** Insert merge rails from primaries to duplicates.
*/
|
| ︙ | ︙ |
Changes to src/graph.js.
| ︙ | ︙ | |||
429 430 431 432 433 434 435 436 |
if( p.u==0 && p.mo==p.r ){
mergeLines[p.mo] = u.r<p.r ? -mergeOffset-mLine.w : mergeOffset;
}else{
mergeLines[p.mo] = -mLine.w/2;
}
x1 += mergeLines[p.mo]
var y0 = p.y+2;
if( p.mu==p.id ){
| > > > > | > > > > > > > > > | | 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 |
if( p.u==0 && p.mo==p.r ){
mergeLines[p.mo] = u.r<p.r ? -mergeOffset-mLine.w : mergeOffset;
}else{
mergeLines[p.mo] = -mLine.w/2;
}
x1 += mergeLines[p.mo]
var y0 = p.y+2;
var isCP = p.hasOwnProperty('cu');
if( p.mu==p.id ){
/* Merge out error to an existing riser from below */
var dx = x1<x0 ? mArrow.w : -mArrow.w;
if( isCP ){
drawCherrypickLine(x0,y0,x1+dx,null);
cls = "arrow cherrypick " + (x1<x0 ? "l" : "r");
}else{
drawMergeLine(x0,y0,x1+dx,null);
cls = "arrow merge " + (x1<x0 ? "l" : "r");
}
if( p.mu==p.cu ){
dx = x1<x0 ? mLine.w : -(mArrow.w + mLine.w/2);
drawBox(cls,null,x1+dx,y0+(mLine.w-mArrow.h)/2);
}
y1 = y0;
}else{
drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
drawMergeLine(x1,y0+mLine.w,null,y1);
}
if( isCP ){
var u2 = tx.rowinfo[p.cu-tx.iTopRow];
var y2 = miLineY(u2);
drawCherrypickLine(x1,y1,null,y2);
}
}else if( mergeOffset ){
mergeLines[p.mo] = u.r<p.r ? -mergeOffset-mLine.w : mergeOffset;
x1 += mergeLines[p.mo];
|
| ︙ | ︙ |
Changes to src/timeline.c.
| ︙ | ︙ | |||
997 998 999 1000 1001 1002 1003 |
if( pRow->bDescender ){
cgi_printf("\"d\":%d,", pRow->bDescender);
}
if( pRow->mergeOut>=0 ){
cgi_printf("\"mo\":%d,", aiMap[pRow->mergeOut]);
if( pRow->mergeUpto==0 ) pRow->mergeUpto = pRow->idx;
cgi_printf("\"mu\":%d,", pRow->mergeUpto);
| | | 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 |
if( pRow->bDescender ){
cgi_printf("\"d\":%d,", pRow->bDescender);
}
if( pRow->mergeOut>=0 ){
cgi_printf("\"mo\":%d,", aiMap[pRow->mergeOut]);
if( pRow->mergeUpto==0 ) pRow->mergeUpto = pRow->idx;
cgi_printf("\"mu\":%d,", pRow->mergeUpto);
if( pRow->cherrypickUpto>0 && pRow->cherrypickUpto<=pRow->mergeUpto ){
cgi_printf("\"cu\":%d,", pRow->cherrypickUpto);
}
}
if( pRow->isStepParent ){
cgi_printf("\"sb\":%d,", pRow->aiRiser[pRow->iRail]);
}else{
cgi_printf("\"u\":%d,", pRow->aiRiser[pRow->iRail]);
|
| ︙ | ︙ |