Fossil SCM
Fix behavior of "--limit | -n" argument of the timeline command to fit description from usage, which is also the behavior of the "n=" parameter of the /timeline webpage. Now -n <n> define the number of entries while before, it was limiting the number of lines. (pending review...)
Commit
453a060c191329b291cf1551ef2b4b4b283f8e15
Parent
44bd9ae243db2c0…
1 file changed
+6
-6
+6
-6
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1474,11 +1474,11 @@ | ||
| 1474 | 1474 | |
| 1475 | 1475 | /* |
| 1476 | 1476 | ** The input query q selects various records. Print a human-readable |
| 1477 | 1477 | ** summary of those records. |
| 1478 | 1478 | ** |
| 1479 | -** Limit the number of entries printed to nLine. | |
| 1479 | +** Limit number of entries printed to N. | |
| 1480 | 1480 | ** |
| 1481 | 1481 | ** The query should return these columns: |
| 1482 | 1482 | ** |
| 1483 | 1483 | ** 0. rid |
| 1484 | 1484 | ** 1. uuid |
| @@ -1487,12 +1487,12 @@ | ||
| 1487 | 1487 | ** 4. Number of non-merge children |
| 1488 | 1488 | ** 5. Number of parents |
| 1489 | 1489 | ** 6. mtime |
| 1490 | 1490 | ** 7. branch |
| 1491 | 1491 | */ |
| 1492 | -void print_timeline(Stmt *q, int mxLine, int verboseFlag){ | |
| 1493 | - int nLine = 0; | |
| 1492 | +void print_timeline(Stmt *q, int N, int verboseFlag){ | |
| 1493 | + int nEntry = 0; | |
| 1494 | 1494 | char zPrevDate[20]; |
| 1495 | 1495 | const char *zCurrentUuid=0; |
| 1496 | 1496 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 1497 | 1497 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 1498 | 1498 | zPrevDate[0] = 0; |
| @@ -1500,11 +1500,11 @@ | ||
| 1500 | 1500 | if( g.localOpen ){ |
| 1501 | 1501 | int rid = db_lget_int("checkout", 0); |
| 1502 | 1502 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1503 | 1503 | } |
| 1504 | 1504 | |
| 1505 | - while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ | |
| 1505 | + while( db_step(q)==SQLITE_ROW && nEntry<N){ | |
| 1506 | 1506 | int rid = db_column_int(q, 0); |
| 1507 | 1507 | const char *zId = db_column_text(q, 1); |
| 1508 | 1508 | const char *zDate = db_column_text(q, 2); |
| 1509 | 1509 | const char *zCom = db_column_text(q, 3); |
| 1510 | 1510 | int nChild = db_column_int(q, 4); |
| @@ -1516,11 +1516,10 @@ | ||
| 1516 | 1516 | |
| 1517 | 1517 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1518 | 1518 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1519 | 1519 | fossil_print("=== %.10s ===\n", zDate); |
| 1520 | 1520 | memcpy(zPrevDate, zDate, 10); |
| 1521 | - nLine++; | |
| 1522 | 1521 | } |
| 1523 | 1522 | if( zCom==0 ) zCom = ""; |
| 1524 | 1523 | fossil_print("%.8s ", &zDate[11]); |
| 1525 | 1524 | zPrefix[0] = 0; |
| 1526 | 1525 | if( nParent>1 ){ |
| @@ -1539,12 +1538,13 @@ | ||
| 1539 | 1538 | } |
| 1540 | 1539 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1541 | 1540 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1542 | 1541 | n += strlen(zPrefix); |
| 1543 | 1542 | } |
| 1543 | + nEntry++; | |
| 1544 | 1544 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1545 | - nLine += comment_print(zFree, 9, 79); | |
| 1545 | + comment_print(zFree, 9, 79); | |
| 1546 | 1546 | sqlite3_free(zFree); |
| 1547 | 1547 | |
| 1548 | 1548 | if(verboseFlag){ |
| 1549 | 1549 | if( !fchngQueryInit ){ |
| 1550 | 1550 | db_prepare(&fchngQuery, |
| 1551 | 1551 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1474,11 +1474,11 @@ | |
| 1474 | |
| 1475 | /* |
| 1476 | ** The input query q selects various records. Print a human-readable |
| 1477 | ** summary of those records. |
| 1478 | ** |
| 1479 | ** Limit the number of entries printed to nLine. |
| 1480 | ** |
| 1481 | ** The query should return these columns: |
| 1482 | ** |
| 1483 | ** 0. rid |
| 1484 | ** 1. uuid |
| @@ -1487,12 +1487,12 @@ | |
| 1487 | ** 4. Number of non-merge children |
| 1488 | ** 5. Number of parents |
| 1489 | ** 6. mtime |
| 1490 | ** 7. branch |
| 1491 | */ |
| 1492 | void print_timeline(Stmt *q, int mxLine, int verboseFlag){ |
| 1493 | int nLine = 0; |
| 1494 | char zPrevDate[20]; |
| 1495 | const char *zCurrentUuid=0; |
| 1496 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 1497 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 1498 | zPrevDate[0] = 0; |
| @@ -1500,11 +1500,11 @@ | |
| 1500 | if( g.localOpen ){ |
| 1501 | int rid = db_lget_int("checkout", 0); |
| 1502 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1503 | } |
| 1504 | |
| 1505 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 1506 | int rid = db_column_int(q, 0); |
| 1507 | const char *zId = db_column_text(q, 1); |
| 1508 | const char *zDate = db_column_text(q, 2); |
| 1509 | const char *zCom = db_column_text(q, 3); |
| 1510 | int nChild = db_column_int(q, 4); |
| @@ -1516,11 +1516,10 @@ | |
| 1516 | |
| 1517 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1518 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1519 | fossil_print("=== %.10s ===\n", zDate); |
| 1520 | memcpy(zPrevDate, zDate, 10); |
| 1521 | nLine++; |
| 1522 | } |
| 1523 | if( zCom==0 ) zCom = ""; |
| 1524 | fossil_print("%.8s ", &zDate[11]); |
| 1525 | zPrefix[0] = 0; |
| 1526 | if( nParent>1 ){ |
| @@ -1539,12 +1538,13 @@ | |
| 1539 | } |
| 1540 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1541 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1542 | n += strlen(zPrefix); |
| 1543 | } |
| 1544 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1545 | nLine += comment_print(zFree, 9, 79); |
| 1546 | sqlite3_free(zFree); |
| 1547 | |
| 1548 | if(verboseFlag){ |
| 1549 | if( !fchngQueryInit ){ |
| 1550 | db_prepare(&fchngQuery, |
| 1551 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1474,11 +1474,11 @@ | |
| 1474 | |
| 1475 | /* |
| 1476 | ** The input query q selects various records. Print a human-readable |
| 1477 | ** summary of those records. |
| 1478 | ** |
| 1479 | ** Limit number of entries printed to N. |
| 1480 | ** |
| 1481 | ** The query should return these columns: |
| 1482 | ** |
| 1483 | ** 0. rid |
| 1484 | ** 1. uuid |
| @@ -1487,12 +1487,12 @@ | |
| 1487 | ** 4. Number of non-merge children |
| 1488 | ** 5. Number of parents |
| 1489 | ** 6. mtime |
| 1490 | ** 7. branch |
| 1491 | */ |
| 1492 | void print_timeline(Stmt *q, int N, int verboseFlag){ |
| 1493 | int nEntry = 0; |
| 1494 | char zPrevDate[20]; |
| 1495 | const char *zCurrentUuid=0; |
| 1496 | int fchngQueryInit = 0; /* True if fchngQuery is initialized */ |
| 1497 | Stmt fchngQuery; /* Query for file changes on check-ins */ |
| 1498 | zPrevDate[0] = 0; |
| @@ -1500,11 +1500,11 @@ | |
| 1500 | if( g.localOpen ){ |
| 1501 | int rid = db_lget_int("checkout", 0); |
| 1502 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1503 | } |
| 1504 | |
| 1505 | while( db_step(q)==SQLITE_ROW && nEntry<N){ |
| 1506 | int rid = db_column_int(q, 0); |
| 1507 | const char *zId = db_column_text(q, 1); |
| 1508 | const char *zDate = db_column_text(q, 2); |
| 1509 | const char *zCom = db_column_text(q, 3); |
| 1510 | int nChild = db_column_int(q, 4); |
| @@ -1516,11 +1516,10 @@ | |
| 1516 | |
| 1517 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1518 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1519 | fossil_print("=== %.10s ===\n", zDate); |
| 1520 | memcpy(zPrevDate, zDate, 10); |
| 1521 | } |
| 1522 | if( zCom==0 ) zCom = ""; |
| 1523 | fossil_print("%.8s ", &zDate[11]); |
| 1524 | zPrefix[0] = 0; |
| 1525 | if( nParent>1 ){ |
| @@ -1539,12 +1538,13 @@ | |
| 1538 | } |
| 1539 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1540 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1541 | n += strlen(zPrefix); |
| 1542 | } |
| 1543 | nEntry++; |
| 1544 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1545 | comment_print(zFree, 9, 79); |
| 1546 | sqlite3_free(zFree); |
| 1547 | |
| 1548 | if(verboseFlag){ |
| 1549 | if( !fchngQueryInit ){ |
| 1550 | db_prepare(&fchngQuery, |
| 1551 |