Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
| Comment: | Increase the maximum graph with to 40 rails. Fix the graph display for individual files, which was broken by the prior change. |
|---|---|
| Downloads: | Tarball | ZIP archive |
| Timelines: | family | ancestors | descendants | both | trunk |
| Files: | files | file ages | folders |
| SHA1: |
8d4ee62b1876a1721057d5afd0e52b90 |
| User & Date: | drh 2012-12-06 02:44:16.196 |
Context
|
2012-12-06
| ||
| 02:51 | Disable the "Diffs" link from the check-in information page. Better to use the click-to-diff feature of the graph. The code was disabled using #if 0 so it is easy to reactivate it if desired. check-in: 89ab1185bf user: drh tags: trunk | |
| 02:44 | Increase the maximum graph with to 40 rails. Fix the graph display for individual files, which was broken by the prior change. check-in: 8d4ee62b18 user: drh tags: trunk | |
| 01:47 | Make the spacing between vertical rail centerlines in the graph adjustable based on the number of rails. Use less horizontal space. check-in: d57481a707 user: drh tags: trunk | |
Changes
Changes to src/finfo.c.
| ︙ | ︙ | |||
440 441 442 443 444 445 446 447 |
db_finalize(&q);
if( pGraph ){
graph_finish(pGraph, 0);
if( pGraph->nErr ){
graph_free(pGraph);
pGraph = 0;
}else{
@ <tr><td></td><td>
| > | | 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 |
db_finalize(&q);
if( pGraph ){
graph_finish(pGraph, 0);
if( pGraph->nErr ){
graph_free(pGraph);
pGraph = 0;
}else{
int w = (pGraph->mxRail+1)*pGraph->iRailPitch + 10;
@ <tr><td></td><td>
@ <div id="grbtm" style="width:%d(w)px;"></div>
@ </td><td></td></tr>
}
}
@ </table>
timeline_output_graph_javascript(pGraph, 0, 1);
style_footer();
}
|
Changes to src/graph.c.
| ︙ | ︙ | |||
19 20 21 22 23 24 25 | */ #include "config.h" #include "graph.h" #include <assert.h> #if INTERFACE | | | 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
*/
#include "config.h"
#include "graph.h"
#include <assert.h>
#if INTERFACE
#define GR_MAX_RAIL 40 /* Max number of "rails" to display */
/* The graph appears vertically beside a timeline. Each row in the
** timeline corresponds to a row in the graph. GraphRow.idx is 0 for
** the top-most row and increases moving down. Hence (in the absence of
** time skew) parents have a larger index than their children.
*/
struct GraphRow {
|
| ︙ | ︙ | |||
49 50 51 52 53 54 55 | u8 timeWarp; /* Child is earlier in time */ u8 bDescender; /* True if riser from bottom of graph to here. */ i8 iRail; /* Which rail this check-in appears on. 0-based.*/ i8 mergeOut; /* Merge out to this rail. -1 if no merge-out */ u8 mergeIn[GR_MAX_RAIL]; /* Merge in from non-zero rails */ int aiRiser[GR_MAX_RAIL]; /* Risers from this node to a higher row. */ int mergeUpto; /* Draw the mergeOut rail up to this level */ | | | > > > | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
u8 timeWarp; /* Child is earlier in time */
u8 bDescender; /* True if riser from bottom of graph to here. */
i8 iRail; /* Which rail this check-in appears on. 0-based.*/
i8 mergeOut; /* Merge out to this rail. -1 if no merge-out */
u8 mergeIn[GR_MAX_RAIL]; /* Merge in from non-zero rails */
int aiRiser[GR_MAX_RAIL]; /* Risers from this node to a higher row. */
int mergeUpto; /* Draw the mergeOut rail up to this level */
u64 mergeDown; /* Draw merge lines up from bottom of graph */
u64 railInUse; /* Mask of occupied rails at this row */
};
/* Context while building a graph
*/
struct GraphContext {
int nErr; /* Number of errors encountered */
int mxRail; /* Number of rails required to render the graph */
int iRailPitch; /* Pixels between rail centers */
GraphRow *pFirst; /* First row in the list */
GraphRow *pLast; /* Last row in the list */
int nBranch; /* Number of distinct branches */
char **azBranch; /* Names of the branches */
int nRow; /* Number of rows */
int nHash; /* Number of slots in apHash[] */
GraphRow **apHash; /* Hash table of GraphRow objects. Key: rid */
};
#endif
/* The N-th bit */
#define BIT(N) (((u64)1)<<(N))
/*
** Malloc for zeroed space. Panic if unable to provide the
** requested space.
*/
void *safeMalloc(int nByte){
void *p = fossil_malloc(nByte);
memset(p, 0, nByte);
|
| ︙ | ︙ | |||
214 215 216 217 218 219 220 | /* ** Return the index of a rail currently not in use for any row between ** top and bottom, inclusive. */ static int findFreeRail( GraphContext *p, /* The graph context */ int top, int btm, /* Span of rows for which the rail is needed */ | | | | 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
/*
** Return the index of a rail currently not in use for any row between
** top and bottom, inclusive.
*/
static int findFreeRail(
GraphContext *p, /* The graph context */
int top, int btm, /* Span of rows for which the rail is needed */
u64 inUseMask, /* Mask or rails already in use */
int iNearto /* Find rail nearest to this rail */
){
GraphRow *pRow;
int i;
int iBest = 0;
int iBestDist = 9999;
for(pRow=p->pFirst; pRow && pRow->idx<top; pRow=pRow->pNext){}
while( pRow && pRow->idx<=btm ){
inUseMask |= pRow->railInUse;
pRow = pRow->pNext;
}
for(i=0; i<32; i++){
if( (inUseMask & BIT(i))==0 ){
int dist;
if( iNearto<=0 ){
return i;
}
dist = i - iNearto;
if( dist<0 ) dist = -dist;
if( dist<iBestDist ){
|
| ︙ | ︙ | |||
252 253 254 255 256 257 258 |
/*
** Assign all children of node pBottom to the same rail as pBottom.
*/
static void assignChildrenToRail(GraphRow *pBottom){
int iRail = pBottom->iRail;
GraphRow *pCurrent;
GraphRow *pPrior;
| | | 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 |
/*
** Assign all children of node pBottom to the same rail as pBottom.
*/
static void assignChildrenToRail(GraphRow *pBottom){
int iRail = pBottom->iRail;
GraphRow *pCurrent;
GraphRow *pPrior;
u64 mask = ((u64)1)<<iRail;
pBottom->iRail = iRail;
pBottom->railInUse |= mask;
pPrior = pBottom;
for(pCurrent=pBottom->pChild; pCurrent; pCurrent=pCurrent->pChild){
assert( pPrior->idx > pCurrent->idx );
assert( pCurrent->iRail<0 );
|
| ︙ | ︙ | |||
280 281 282 283 284 285 286 |
*/
static void createMergeRiser(
GraphContext *p,
GraphRow *pParent,
GraphRow *pChild
){
int u;
| | | | | | | 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 |
*/
static void createMergeRiser(
GraphContext *p,
GraphRow *pParent,
GraphRow *pChild
){
int u;
u64 mask;
GraphRow *pLoop;
if( pParent->mergeOut<0 ){
u = pParent->aiRiser[pParent->iRail];
if( u>=0 && u<pChild->idx ){
/* The thick arrow up to the next primary child of pDesc goes
** further up than the thin merge arrow riser, so draw them both
** on the same rail. */
pParent->mergeOut = pParent->iRail*4;
if( pParent->iRail<pChild->iRail ) pParent->mergeOut += 2;
pParent->mergeUpto = pChild->idx;
}else{
/* The thin merge arrow riser is taller than the thick primary
** child riser, so use separate rails. */
int iTarget = pParent->iRail;
pParent->mergeOut = findFreeRail(p, pChild->idx, pParent->idx-1,
0, iTarget)*4 + 1;
pParent->mergeUpto = pChild->idx;
mask = BIT(pParent->mergeOut/4);
for(pLoop=pChild->pNext; pLoop && pLoop->rid!=pParent->rid;
pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}
}
pChild->mergeIn[pParent->mergeOut/4] = (pParent->mergeOut&3)+1;
}
/*
** Compute the maximum rail number.
*/
static void find_max_rail(GraphContext *p){
GraphRow *pRow;
p->mxRail = 0;
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4;
while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>(BIT(p->mxRail+1)-1) ){
p->mxRail++;
}
}
}
/*
** Compute the complete graph
*/
void graph_finish(GraphContext *p, int omitDescenders){
GraphRow *pRow, *pDesc, *pDup, *pLoop, *pParent;
int i;
u64 mask;
u64 inUse;
int hasDup = 0; /* True if one or more isDup entries */
const char *zTrunk;
if( p==0 || p->pFirst==0 || p->nErr ) return;
p->nErr = 1; /* Assume an error until proven otherwise */
/* Initialize all rows */
|
| ︙ | ︙ | |||
421 422 423 424 425 426 427 |
if( pRow->nParent==0 || hashFind(p,pRow->aParent[0])==0 ){
if( omitDescenders ){
pRow->iRail = findFreeRail(p, pRow->idxTop, pRow->idx, 0, 0);
}else{
pRow->iRail = ++p->mxRail;
}
if( p->mxRail>=GR_MAX_RAIL ) return;
| | | | | | | | | | 424 425 426 427 428 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 464 465 466 467 468 469 470 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 |
if( pRow->nParent==0 || hashFind(p,pRow->aParent[0])==0 ){
if( omitDescenders ){
pRow->iRail = findFreeRail(p, pRow->idxTop, pRow->idx, 0, 0);
}else{
pRow->iRail = ++p->mxRail;
}
if( p->mxRail>=GR_MAX_RAIL ) return;
mask = BIT(pRow->iRail);
if( !omitDescenders ){
pRow->bDescender = pRow->nParent>0;
for(pLoop=pRow; pLoop; pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}
assignChildrenToRail(pRow);
}
}
}
/* Assign rails to all rows that are still unassigned.
*/
inUse = BIT(p->mxRail+1) - 1;
for(pRow=p->pLast; pRow; pRow=pRow->pPrev){
int parentRid;
if( pRow->iRail>=0 ){
if( pRow->pChild==0 && !pRow->timeWarp ){
if( omitDescenders || count_nonbranch_children(pRow->rid)==0 ){
inUse &= ~BIT(pRow->iRail);
}else{
pRow->aiRiser[pRow->iRail] = 0;
mask = BIT(pRow->iRail);
for(pLoop=pRow; pLoop; pLoop=pLoop->pPrev){
pLoop->railInUse |= mask;
}
}
}
continue;
}
if( pRow->isDup ){
continue;
}else{
assert( pRow->nParent>0 );
parentRid = pRow->aParent[0];
pParent = hashFind(p, parentRid);
if( pParent==0 ){
pRow->iRail = ++p->mxRail;
if( p->mxRail>=GR_MAX_RAIL ) return;
pRow->railInUse = BIT(pRow->iRail);
continue;
}
if( pParent->idx>pRow->idx ){
/* Common case: Child occurs after parent and is above the
** parent in the timeline */
pRow->iRail = findFreeRail(p, 0, pParent->idx, inUse, pParent->iRail);
if( p->mxRail>=GR_MAX_RAIL ) return;
pParent->aiRiser[pRow->iRail] = pRow->idx;
}else{
/* Timewarp case: Child occurs earlier in time than parent and
** appears below the parent in the timeline. */
int iDownRail = ++p->mxRail;
if( iDownRail<1 ) iDownRail = ++p->mxRail;
pRow->iRail = ++p->mxRail;
if( p->mxRail>=GR_MAX_RAIL ) return;
pRow->railInUse = BIT(pRow->iRail);
pParent->aiRiser[iDownRail] = pRow->idx;
mask = BIT(iDownRail);
inUse |= mask;
for(pLoop=p->pFirst; pLoop; pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}
}
mask = BIT(pRow->iRail);
pRow->railInUse |= mask;
if( pRow->pChild==0 ){
inUse &= ~mask;
}else{
inUse |= mask;
assignChildrenToRail(pRow);
}
|
| ︙ | ︙ | |||
513 514 515 516 517 518 519 |
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 = findFreeRail(p, pRow->idx, p->nRow, 0, 0);
if( p->mxRail>=GR_MAX_RAIL ) return;
| | | 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 |
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 = findFreeRail(p, pRow->idx, p->nRow, 0, 0);
if( p->mxRail>=GR_MAX_RAIL ) return;
mask = BIT(iMrail);
pRow->mergeIn[iMrail] = 2;
pRow->mergeDown |= mask;
for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
pLoop->railInUse |= mask;
}
}else{
/* Merge from an on-screen node */
|
| ︙ | ︙ | |||
558 559 560 561 562 563 564 565 566 |
if( mxRail>=GR_MAX_RAIL ) return;
}
/*
** Find the maximum rail number.
*/
find_max_rail(p);
p->nErr = 0;
}
| > > | 561 562 563 564 565 566 567 568 569 570 571 |
if( mxRail>=GR_MAX_RAIL ) return;
}
/*
** Find the maximum rail number.
*/
find_max_rail(p);
p->iRailPitch = 18 - (p->mxRail/3);
if( p->iRailPitch<12 ) p->iRailPitch = 12;
p->nErr = 0;
}
|
Changes to src/timeline.c.
| ︙ | ︙ | |||
485 486 487 488 489 490 491 |
graph_free(pGraph);
pGraph = 0;
}else{
int w;
/* style is not moved to css, because this is
** a technical div for the timeline graph
*/
| < < | | 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 |
graph_free(pGraph);
pGraph = 0;
}else{
int w;
/* style is not moved to css, because this is
** a technical div for the timeline graph
*/
w = (pGraph->mxRail+1)*pGraph->iRailPitch + 10;
@ <tr><td></td><td>
@ <div id="grbtm" style="width:%d(w)px;"></div>
@ </td><td></td></tr>
}
}
@ </table>
if( fchngQueryInit ) db_finalize(&fchngQuery);
|
| ︙ | ︙ |