Fossil SCM
Fix the timeline command so that it work with --repository and -R.
Commit
c1e85e4da5d2bc81a8ddd533ce3101969750ea03
Parent
e976aa6fcbc4a0e…
1 file changed
+7
-10
+7
-10
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -487,20 +487,15 @@ | ||
| 487 | 487 | */ |
| 488 | 488 | void print_timeline(Stmt *q, int mxLine){ |
| 489 | 489 | int nLine = 0; |
| 490 | 490 | char zPrevDate[20]; |
| 491 | 491 | const char *zCurrentUuid=0; |
| 492 | - Stmt currentQ; | |
| 493 | - int rid = db_lget_int("checkout", 0); | |
| 494 | 492 | zPrevDate[0] = 0; |
| 495 | 493 | |
| 496 | - db_prepare(¤tQ, | |
| 497 | - "SELECT uuid" | |
| 498 | - " FROM blob WHERE rid=%d", rid | |
| 499 | - ); | |
| 500 | - if( db_step(¤tQ)==SQLITE_ROW ){ | |
| 501 | - zCurrentUuid = db_column_text(¤tQ, 0); | |
| 494 | + if( g.localOpen ){ | |
| 495 | + int rid = db_lget_int("checkout", 0); | |
| 496 | + zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); | |
| 502 | 497 | } |
| 503 | 498 | |
| 504 | 499 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 505 | 500 | const char *zId = db_column_text(q, 1); |
| 506 | 501 | const char *zDate = db_column_text(q, 2); |
| @@ -527,19 +522,18 @@ | ||
| 527 | 522 | } |
| 528 | 523 | if( nChild>1 ){ |
| 529 | 524 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* "); |
| 530 | 525 | n = strlen(zPrefix); |
| 531 | 526 | } |
| 532 | - if( strcmp(zCurrentUuid,zId)==0 ){ | |
| 527 | + if( zCurrentUuid && strcmp(zCurrentUuid,zId)==0 ){ | |
| 533 | 528 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 534 | 529 | n += strlen(zPrefix); |
| 535 | 530 | } |
| 536 | 531 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 537 | 532 | nLine += comment_print(zFree, 9, 79); |
| 538 | 533 | sqlite3_free(zFree); |
| 539 | 534 | } |
| 540 | - db_finalize(¤tQ); | |
| 541 | 535 | } |
| 542 | 536 | |
| 543 | 537 | /* |
| 544 | 538 | ** Return a pointer to a static string that forms the basis for |
| 545 | 539 | ** a timeline query for display on a TTY. |
| @@ -627,10 +621,13 @@ | ||
| 627 | 621 | if( mode==3 || mode==4 ){ |
| 628 | 622 | fossil_fatal("cannot compute descendants or ancestors of a date"); |
| 629 | 623 | } |
| 630 | 624 | zDate = mprintf("(SELECT datetime('now'))"); |
| 631 | 625 | }else if( strncmp(zOrigin, "current", k)==0 ){ |
| 626 | + if( !g.localOpen ){ | |
| 627 | + fossil_fatal("must be within a local checkout to use 'current'"); | |
| 628 | + } | |
| 632 | 629 | objid = db_lget_int("checkout",0); |
| 633 | 630 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 634 | 631 | }else if( name_to_uuid(&uuid, 0)==0 ){ |
| 635 | 632 | objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid); |
| 636 | 633 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 637 | 634 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -487,20 +487,15 @@ | |
| 487 | */ |
| 488 | void print_timeline(Stmt *q, int mxLine){ |
| 489 | int nLine = 0; |
| 490 | char zPrevDate[20]; |
| 491 | const char *zCurrentUuid=0; |
| 492 | Stmt currentQ; |
| 493 | int rid = db_lget_int("checkout", 0); |
| 494 | zPrevDate[0] = 0; |
| 495 | |
| 496 | db_prepare(¤tQ, |
| 497 | "SELECT uuid" |
| 498 | " FROM blob WHERE rid=%d", rid |
| 499 | ); |
| 500 | if( db_step(¤tQ)==SQLITE_ROW ){ |
| 501 | zCurrentUuid = db_column_text(¤tQ, 0); |
| 502 | } |
| 503 | |
| 504 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 505 | const char *zId = db_column_text(q, 1); |
| 506 | const char *zDate = db_column_text(q, 2); |
| @@ -527,19 +522,18 @@ | |
| 527 | } |
| 528 | if( nChild>1 ){ |
| 529 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* "); |
| 530 | n = strlen(zPrefix); |
| 531 | } |
| 532 | if( strcmp(zCurrentUuid,zId)==0 ){ |
| 533 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 534 | n += strlen(zPrefix); |
| 535 | } |
| 536 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 537 | nLine += comment_print(zFree, 9, 79); |
| 538 | sqlite3_free(zFree); |
| 539 | } |
| 540 | db_finalize(¤tQ); |
| 541 | } |
| 542 | |
| 543 | /* |
| 544 | ** Return a pointer to a static string that forms the basis for |
| 545 | ** a timeline query for display on a TTY. |
| @@ -627,10 +621,13 @@ | |
| 627 | if( mode==3 || mode==4 ){ |
| 628 | fossil_fatal("cannot compute descendants or ancestors of a date"); |
| 629 | } |
| 630 | zDate = mprintf("(SELECT datetime('now'))"); |
| 631 | }else if( strncmp(zOrigin, "current", k)==0 ){ |
| 632 | objid = db_lget_int("checkout",0); |
| 633 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 634 | }else if( name_to_uuid(&uuid, 0)==0 ){ |
| 635 | objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid); |
| 636 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 637 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -487,20 +487,15 @@ | |
| 487 | */ |
| 488 | void print_timeline(Stmt *q, int mxLine){ |
| 489 | int nLine = 0; |
| 490 | char zPrevDate[20]; |
| 491 | const char *zCurrentUuid=0; |
| 492 | zPrevDate[0] = 0; |
| 493 | |
| 494 | if( g.localOpen ){ |
| 495 | int rid = db_lget_int("checkout", 0); |
| 496 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 497 | } |
| 498 | |
| 499 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 500 | const char *zId = db_column_text(q, 1); |
| 501 | const char *zDate = db_column_text(q, 2); |
| @@ -527,19 +522,18 @@ | |
| 522 | } |
| 523 | if( nChild>1 ){ |
| 524 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*FORK* "); |
| 525 | n = strlen(zPrefix); |
| 526 | } |
| 527 | if( zCurrentUuid && strcmp(zCurrentUuid,zId)==0 ){ |
| 528 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 529 | n += strlen(zPrefix); |
| 530 | } |
| 531 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 532 | nLine += comment_print(zFree, 9, 79); |
| 533 | sqlite3_free(zFree); |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | /* |
| 538 | ** Return a pointer to a static string that forms the basis for |
| 539 | ** a timeline query for display on a TTY. |
| @@ -627,10 +621,13 @@ | |
| 621 | if( mode==3 || mode==4 ){ |
| 622 | fossil_fatal("cannot compute descendants or ancestors of a date"); |
| 623 | } |
| 624 | zDate = mprintf("(SELECT datetime('now'))"); |
| 625 | }else if( strncmp(zOrigin, "current", k)==0 ){ |
| 626 | if( !g.localOpen ){ |
| 627 | fossil_fatal("must be within a local checkout to use 'current'"); |
| 628 | } |
| 629 | objid = db_lget_int("checkout",0); |
| 630 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 631 | }else if( name_to_uuid(&uuid, 0)==0 ){ |
| 632 | objid = db_int(0, "SELECT rid FROM blob WHERE uuid=%B", &uuid); |
| 633 | zDate = mprintf("(SELECT mtime FROM plink WHERE cid=%d)", objid); |
| 634 |