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...)

mgagnon 2013-10-16 04:09 UTC trunk
Commit 453a060c191329b291cf1551ef2b4b4b283f8e15
1 file changed +6 -6
+6 -6
--- src/timeline.c
+++ src/timeline.c
@@ -1474,11 +1474,11 @@
14741474
14751475
/*
14761476
** The input query q selects various records. Print a human-readable
14771477
** summary of those records.
14781478
**
1479
-** Limit the number of entries printed to nLine.
1479
+** Limit number of entries printed to N.
14801480
**
14811481
** The query should return these columns:
14821482
**
14831483
** 0. rid
14841484
** 1. uuid
@@ -1487,12 +1487,12 @@
14871487
** 4. Number of non-merge children
14881488
** 5. Number of parents
14891489
** 6. mtime
14901490
** 7. branch
14911491
*/
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;
14941494
char zPrevDate[20];
14951495
const char *zCurrentUuid=0;
14961496
int fchngQueryInit = 0; /* True if fchngQuery is initialized */
14971497
Stmt fchngQuery; /* Query for file changes on check-ins */
14981498
zPrevDate[0] = 0;
@@ -1500,11 +1500,11 @@
15001500
if( g.localOpen ){
15011501
int rid = db_lget_int("checkout", 0);
15021502
zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
15031503
}
15041504
1505
- while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
1505
+ while( db_step(q)==SQLITE_ROW && nEntry<N){
15061506
int rid = db_column_int(q, 0);
15071507
const char *zId = db_column_text(q, 1);
15081508
const char *zDate = db_column_text(q, 2);
15091509
const char *zCom = db_column_text(q, 3);
15101510
int nChild = db_column_int(q, 4);
@@ -1516,11 +1516,10 @@
15161516
15171517
sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
15181518
if( memcmp(zDate, zPrevDate, 10) ){
15191519
fossil_print("=== %.10s ===\n", zDate);
15201520
memcpy(zPrevDate, zDate, 10);
1521
- nLine++;
15221521
}
15231522
if( zCom==0 ) zCom = "";
15241523
fossil_print("%.8s ", &zDate[11]);
15251524
zPrefix[0] = 0;
15261525
if( nParent>1 ){
@@ -1539,12 +1538,13 @@
15391538
}
15401539
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
15411540
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
15421541
n += strlen(zPrefix);
15431542
}
1543
+ nEntry++;
15441544
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1545
- nLine += comment_print(zFree, 9, 79);
1545
+ comment_print(zFree, 9, 79);
15461546
sqlite3_free(zFree);
15471547
15481548
if(verboseFlag){
15491549
if( !fchngQueryInit ){
15501550
db_prepare(&fchngQuery,
15511551
--- 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

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button