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.

jan.nijtmans 2013-10-21 05:06 UTC trunk
Commit 0c312bee2017f2fb53000fcc818fe75c5c400ba7
1 file changed +10 -3
+10 -3
--- src/timeline.c
+++ src/timeline.c
@@ -1494,11 +1494,14 @@
14941494
14951495
/*
14961496
** The input query q selects various records. Print a human-readable
14971497
** summary of those records.
14981498
**
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.
15001503
**
15011504
** The query should return these columns:
15021505
**
15031506
** 0. rid
15041507
** 1. uuid
@@ -1520,10 +1523,13 @@
15201523
if( g.localOpen ){
15211524
int rid = db_lget_int("checkout", 0);
15221525
zCurrentUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
15231526
}
15241527
1528
+ if( mxLine<0 ){
1529
+ mxLine = (int)(((unsigned int)-1)>>1);
1530
+ }
15251531
while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
15261532
int rid = db_column_int(q, 0);
15271533
const char *zId = db_column_text(q, 1);
15281534
const char *zDate = db_column_text(q, 2);
15291535
const char *zCom = db_column_text(q, 3);
@@ -1536,11 +1542,11 @@
15361542
15371543
sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
15381544
if( memcmp(zDate, zPrevDate, 10) ){
15391545
fossil_print("=== %.10s ===\n", zDate);
15401546
memcpy(zPrevDate, zDate, 10);
1541
- nLine++;
1547
+ nLine++; /* record another line */
15421548
}
15431549
if( zCom==0 ) zCom = "";
15441550
fossil_print("%.8s ", &zDate[11]);
15451551
zPrefix[0] = 0;
15461552
if( nParent>1 ){
@@ -1560,11 +1566,11 @@
15601566
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
15611567
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
15621568
n += strlen(zPrefix);
15631569
}
15641570
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 */
15661572
sqlite3_free(zFree);
15671573
15681574
if(verboseFlag){
15691575
if( !fchngQueryInit ){
15701576
db_prepare(&fchngQuery,
@@ -1589,10 +1595,11 @@
15891595
}else if( isDel ){
15901596
fossil_print(" DELETED %s\n",zFilename);
15911597
}else{
15921598
fossil_print(" EDITED %s\n", zFilename);
15931599
}
1600
+ nLine++; /* record another line */
15941601
}
15951602
db_reset(&fchngQuery);
15961603
}
15971604
}
15981605
if( fchngQueryInit ) db_finalize(&fchngQuery);
15991606
--- 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

Keyboard Shortcuts

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