Fossil SCM
Make "fossil timeline -n" more accurate in counting lines in verbose mode. Allow print_timeline() to be used without limits, assuming that the query already contains a suitable limitation. Improde documentation.
Commit
0c312bee2017f2fb53000fcc818fe75c5c400ba7
Parent
18d9f5af0467d4b…
1 file changed
+10
-3
+10
-3
| --- src/timeline.c | ||
| +++ src/timeline.c | ||
| @@ -1494,11 +1494,14 @@ | ||
| 1494 | 1494 | |
| 1495 | 1495 | /* |
| 1496 | 1496 | ** The input query q selects various records. Print a human-readable |
| 1497 | 1497 | ** summary of those records. |
| 1498 | 1498 | ** |
| 1499 | -** Limit the number of entries printed to nLine. | |
| 1499 | +** Limit the number of lines printed to nLine. If nLimit is negative | |
| 1500 | +** there is no limit. The line limit is approximate because it is | |
| 1501 | +** only checked on a per-entry basis. In verbose mode, the file | |
| 1502 | +** name details are considered to be part of the entry. | |
| 1500 | 1503 | ** |
| 1501 | 1504 | ** The query should return these columns: |
| 1502 | 1505 | ** |
| 1503 | 1506 | ** 0. rid |
| 1504 | 1507 | ** 1. uuid |
| @@ -1520,10 +1523,13 @@ | ||
| 1520 | 1523 | if( g.localOpen ){ |
| 1521 | 1524 | int rid = db_lget_int("checkout", 0); |
| 1522 | 1525 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1523 | 1526 | } |
| 1524 | 1527 | |
| 1528 | + if( mxLine<0 ){ | |
| 1529 | + mxLine = (int)(((unsigned int)-1)>>1); | |
| 1530 | + } | |
| 1525 | 1531 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 1526 | 1532 | int rid = db_column_int(q, 0); |
| 1527 | 1533 | const char *zId = db_column_text(q, 1); |
| 1528 | 1534 | const char *zDate = db_column_text(q, 2); |
| 1529 | 1535 | const char *zCom = db_column_text(q, 3); |
| @@ -1536,11 +1542,11 @@ | ||
| 1536 | 1542 | |
| 1537 | 1543 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1538 | 1544 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1539 | 1545 | fossil_print("=== %.10s ===\n", zDate); |
| 1540 | 1546 | memcpy(zPrevDate, zDate, 10); |
| 1541 | - nLine++; | |
| 1547 | + nLine++; /* record another line */ | |
| 1542 | 1548 | } |
| 1543 | 1549 | if( zCom==0 ) zCom = ""; |
| 1544 | 1550 | fossil_print("%.8s ", &zDate[11]); |
| 1545 | 1551 | zPrefix[0] = 0; |
| 1546 | 1552 | if( nParent>1 ){ |
| @@ -1560,11 +1566,11 @@ | ||
| 1560 | 1566 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1561 | 1567 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1562 | 1568 | n += strlen(zPrefix); |
| 1563 | 1569 | } |
| 1564 | 1570 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1565 | - nLine += comment_print(zFree, 9, 79); | |
| 1571 | + nLine += comment_print(zFree, 9, 79); /* record another X lines */ | |
| 1566 | 1572 | sqlite3_free(zFree); |
| 1567 | 1573 | |
| 1568 | 1574 | if(verboseFlag){ |
| 1569 | 1575 | if( !fchngQueryInit ){ |
| 1570 | 1576 | db_prepare(&fchngQuery, |
| @@ -1589,10 +1595,11 @@ | ||
| 1589 | 1595 | }else if( isDel ){ |
| 1590 | 1596 | fossil_print(" DELETED %s\n",zFilename); |
| 1591 | 1597 | }else{ |
| 1592 | 1598 | fossil_print(" EDITED %s\n", zFilename); |
| 1593 | 1599 | } |
| 1600 | + nLine++; /* record another line */ | |
| 1594 | 1601 | } |
| 1595 | 1602 | db_reset(&fchngQuery); |
| 1596 | 1603 | } |
| 1597 | 1604 | } |
| 1598 | 1605 | if( fchngQueryInit ) db_finalize(&fchngQuery); |
| 1599 | 1606 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1494,11 +1494,14 @@ | |
| 1494 | |
| 1495 | /* |
| 1496 | ** The input query q selects various records. Print a human-readable |
| 1497 | ** summary of those records. |
| 1498 | ** |
| 1499 | ** Limit the number of entries printed to nLine. |
| 1500 | ** |
| 1501 | ** The query should return these columns: |
| 1502 | ** |
| 1503 | ** 0. rid |
| 1504 | ** 1. uuid |
| @@ -1520,10 +1523,13 @@ | |
| 1520 | if( g.localOpen ){ |
| 1521 | int rid = db_lget_int("checkout", 0); |
| 1522 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1523 | } |
| 1524 | |
| 1525 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 1526 | int rid = db_column_int(q, 0); |
| 1527 | const char *zId = db_column_text(q, 1); |
| 1528 | const char *zDate = db_column_text(q, 2); |
| 1529 | const char *zCom = db_column_text(q, 3); |
| @@ -1536,11 +1542,11 @@ | |
| 1536 | |
| 1537 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1538 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1539 | fossil_print("=== %.10s ===\n", zDate); |
| 1540 | memcpy(zPrevDate, zDate, 10); |
| 1541 | nLine++; |
| 1542 | } |
| 1543 | if( zCom==0 ) zCom = ""; |
| 1544 | fossil_print("%.8s ", &zDate[11]); |
| 1545 | zPrefix[0] = 0; |
| 1546 | if( nParent>1 ){ |
| @@ -1560,11 +1566,11 @@ | |
| 1560 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1561 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1562 | n += strlen(zPrefix); |
| 1563 | } |
| 1564 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1565 | nLine += comment_print(zFree, 9, 79); |
| 1566 | sqlite3_free(zFree); |
| 1567 | |
| 1568 | if(verboseFlag){ |
| 1569 | if( !fchngQueryInit ){ |
| 1570 | db_prepare(&fchngQuery, |
| @@ -1589,10 +1595,11 @@ | |
| 1589 | }else if( isDel ){ |
| 1590 | fossil_print(" DELETED %s\n",zFilename); |
| 1591 | }else{ |
| 1592 | fossil_print(" EDITED %s\n", zFilename); |
| 1593 | } |
| 1594 | } |
| 1595 | db_reset(&fchngQuery); |
| 1596 | } |
| 1597 | } |
| 1598 | if( fchngQueryInit ) db_finalize(&fchngQuery); |
| 1599 |
| --- src/timeline.c | |
| +++ src/timeline.c | |
| @@ -1494,11 +1494,14 @@ | |
| 1494 | |
| 1495 | /* |
| 1496 | ** The input query q selects various records. Print a human-readable |
| 1497 | ** summary of those records. |
| 1498 | ** |
| 1499 | ** Limit the number of lines printed to nLine. If nLimit is negative |
| 1500 | ** there is no limit. The line limit is approximate because it is |
| 1501 | ** only checked on a per-entry basis. In verbose mode, the file |
| 1502 | ** name details are considered to be part of the entry. |
| 1503 | ** |
| 1504 | ** The query should return these columns: |
| 1505 | ** |
| 1506 | ** 0. rid |
| 1507 | ** 1. uuid |
| @@ -1520,10 +1523,13 @@ | |
| 1523 | if( g.localOpen ){ |
| 1524 | int rid = db_lget_int("checkout", 0); |
| 1525 | zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid); |
| 1526 | } |
| 1527 | |
| 1528 | if( mxLine<0 ){ |
| 1529 | mxLine = (int)(((unsigned int)-1)>>1); |
| 1530 | } |
| 1531 | while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){ |
| 1532 | int rid = db_column_int(q, 0); |
| 1533 | const char *zId = db_column_text(q, 1); |
| 1534 | const char *zDate = db_column_text(q, 2); |
| 1535 | const char *zCom = db_column_text(q, 3); |
| @@ -1536,11 +1542,11 @@ | |
| 1542 | |
| 1543 | sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId); |
| 1544 | if( memcmp(zDate, zPrevDate, 10) ){ |
| 1545 | fossil_print("=== %.10s ===\n", zDate); |
| 1546 | memcpy(zPrevDate, zDate, 10); |
| 1547 | nLine++; /* record another line */ |
| 1548 | } |
| 1549 | if( zCom==0 ) zCom = ""; |
| 1550 | fossil_print("%.8s ", &zDate[11]); |
| 1551 | zPrefix[0] = 0; |
| 1552 | if( nParent>1 ){ |
| @@ -1560,11 +1566,11 @@ | |
| 1566 | if( fossil_strcmp(zCurrentUuid,zId)==0 ){ |
| 1567 | sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* "); |
| 1568 | n += strlen(zPrefix); |
| 1569 | } |
| 1570 | zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom); |
| 1571 | nLine += comment_print(zFree, 9, 79); /* record another X lines */ |
| 1572 | sqlite3_free(zFree); |
| 1573 | |
| 1574 | if(verboseFlag){ |
| 1575 | if( !fchngQueryInit ){ |
| 1576 | db_prepare(&fchngQuery, |
| @@ -1589,10 +1595,11 @@ | |
| 1595 | }else if( isDel ){ |
| 1596 | fossil_print(" DELETED %s\n",zFilename); |
| 1597 | }else{ |
| 1598 | fossil_print(" EDITED %s\n", zFilename); |
| 1599 | } |
| 1600 | nLine++; /* record another line */ |
| 1601 | } |
| 1602 | db_reset(&fchngQuery); |
| 1603 | } |
| 1604 | } |
| 1605 | if( fchngQueryInit ) db_finalize(&fchngQuery); |
| 1606 |