Fossil SCM

Fix default "fossil timeline -n" value. Merge trunk, and simplify code makeing use of the trunk improvements.

jan.nijtmans 2013-10-21 07:41 UTC timeline_cmd_dash_n_fix-2 merge
Commit 4fdffd7d3ef577458954094c162a8cb20371f6d3
2 files changed +10 -9 +10 -9
+10 -9
--- 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 mxLine. If mxLine is zero or
1500
+** negative there is no limit. The line limit is approximate because
1501
+** it is 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,11 +1523,11 @@
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
1525
- while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
1528
+ while( db_step(q)==SQLITE_ROW && (mxLine<=0 || nLine<=mxLine) ){
15261529
int rid = db_column_int(q, 0);
15271530
const char *zId = db_column_text(q, 1);
15281531
const char *zDate = db_column_text(q, 2);
15291532
const char *zCom = db_column_text(q, 3);
15301533
int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,11 @@
15361539
15371540
sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
15381541
if( memcmp(zDate, zPrevDate, 10) ){
15391542
fossil_print("=== %.10s ===\n", zDate);
15401543
memcpy(zPrevDate, zDate, 10);
1541
- nLine++;
1544
+ nLine++; /* record another line */
15421545
}
15431546
if( zCom==0 ) zCom = "";
15441547
fossil_print("%.8s ", &zDate[11]);
15451548
zPrefix[0] = 0;
15461549
if( nParent>1 ){
@@ -1560,11 +1563,11 @@
15601563
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
15611564
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
15621565
n += strlen(zPrefix);
15631566
}
15641567
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1565
- nLine += comment_print(zFree, 9, 79);
1568
+ nLine += comment_print(zFree, 9, 79); /* record another X lines */
15661569
sqlite3_free(zFree);
15671570
15681571
if(verboseFlag){
15691572
if( !fchngQueryInit ){
15701573
db_prepare(&fchngQuery,
@@ -1589,10 +1592,11 @@
15891592
}else if( isDel ){
15901593
fossil_print(" DELETED %s\n",zFilename);
15911594
}else{
15921595
fossil_print(" EDITED %s\n", zFilename);
15931596
}
1597
+ nLine++; /* record another line */
15941598
}
15951599
db_reset(&fchngQuery);
15961600
}
15971601
}
15981602
if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -1697,11 +1701,11 @@
16971701
zLimit = find_option("count",0,1);
16981702
}
16991703
if( zLimit ){
17001704
n = atoi(zLimit);
17011705
}else{
1702
- n = 20;
1706
+ n = -20;
17031707
}
17041708
if( g.argc>=4 ){
17051709
k = strlen(g.argv[2]);
17061710
if( strncmp(g.argv[2],"before",k)==0 ){
17071711
mode = 1;
@@ -1776,17 +1780,14 @@
17761780
blob_appendf(&sql, " AND event.type=%Q ", zType);
17771781
}
17781782
blob_appendf(&sql, " ORDER BY event.mtime DESC");
17791783
if(n>0){
17801784
blob_appendf(&sql, " LIMIT %d", n);
1781
- n = 9999999;
1782
- }else{
1783
- n = -n;
17841785
}
17851786
db_prepare(&q, blob_str(&sql));
17861787
blob_reset(&sql);
1787
- print_timeline(&q, n, verboseFlag);
1788
+ print_timeline(&q, n<0?-n:0, verboseFlag);
17881789
db_finalize(&q);
17891790
}
17901791
17911792
/*
17921793
** This is a version of the "localtime()" function from the standard
17931794
--- 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,11 +1523,11 @@
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);
1530 int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,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 +1563,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 +1592,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);
@@ -1697,11 +1701,11 @@
1697 zLimit = find_option("count",0,1);
1698 }
1699 if( zLimit ){
1700 n = atoi(zLimit);
1701 }else{
1702 n = 20;
1703 }
1704 if( g.argc>=4 ){
1705 k = strlen(g.argv[2]);
1706 if( strncmp(g.argv[2],"before",k)==0 ){
1707 mode = 1;
@@ -1776,17 +1780,14 @@
1776 blob_appendf(&sql, " AND event.type=%Q ", zType);
1777 }
1778 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1779 if(n>0){
1780 blob_appendf(&sql, " LIMIT %d", n);
1781 n = 9999999;
1782 }else{
1783 n = -n;
1784 }
1785 db_prepare(&q, blob_str(&sql));
1786 blob_reset(&sql);
1787 print_timeline(&q, n, verboseFlag);
1788 db_finalize(&q);
1789 }
1790
1791 /*
1792 ** This is a version of the "localtime()" function from the standard
1793
--- 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 mxLine. If mxLine is zero or
1500 ** negative there is no limit. The line limit is approximate because
1501 ** it is 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,11 +1523,11 @@
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 while( db_step(q)==SQLITE_ROW && (mxLine<=0 || nLine<=mxLine) ){
1529 int rid = db_column_int(q, 0);
1530 const char *zId = db_column_text(q, 1);
1531 const char *zDate = db_column_text(q, 2);
1532 const char *zCom = db_column_text(q, 3);
1533 int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,11 @@
1539
1540 sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
1541 if( memcmp(zDate, zPrevDate, 10) ){
1542 fossil_print("=== %.10s ===\n", zDate);
1543 memcpy(zPrevDate, zDate, 10);
1544 nLine++; /* record another line */
1545 }
1546 if( zCom==0 ) zCom = "";
1547 fossil_print("%.8s ", &zDate[11]);
1548 zPrefix[0] = 0;
1549 if( nParent>1 ){
@@ -1560,11 +1563,11 @@
1563 if( fossil_strcmp(zCurrentUuid,zId)==0 ){
1564 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
1565 n += strlen(zPrefix);
1566 }
1567 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1568 nLine += comment_print(zFree, 9, 79); /* record another X lines */
1569 sqlite3_free(zFree);
1570
1571 if(verboseFlag){
1572 if( !fchngQueryInit ){
1573 db_prepare(&fchngQuery,
@@ -1589,10 +1592,11 @@
1592 }else if( isDel ){
1593 fossil_print(" DELETED %s\n",zFilename);
1594 }else{
1595 fossil_print(" EDITED %s\n", zFilename);
1596 }
1597 nLine++; /* record another line */
1598 }
1599 db_reset(&fchngQuery);
1600 }
1601 }
1602 if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -1697,11 +1701,11 @@
1701 zLimit = find_option("count",0,1);
1702 }
1703 if( zLimit ){
1704 n = atoi(zLimit);
1705 }else{
1706 n = -20;
1707 }
1708 if( g.argc>=4 ){
1709 k = strlen(g.argv[2]);
1710 if( strncmp(g.argv[2],"before",k)==0 ){
1711 mode = 1;
@@ -1776,17 +1780,14 @@
1780 blob_appendf(&sql, " AND event.type=%Q ", zType);
1781 }
1782 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1783 if(n>0){
1784 blob_appendf(&sql, " LIMIT %d", n);
 
 
 
1785 }
1786 db_prepare(&q, blob_str(&sql));
1787 blob_reset(&sql);
1788 print_timeline(&q, n<0?-n:0, verboseFlag);
1789 db_finalize(&q);
1790 }
1791
1792 /*
1793 ** This is a version of the "localtime()" function from the standard
1794
+10 -9
--- 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 mxLine. If mxLine is zero or
1500
+** negative there is no limit. The line limit is approximate because
1501
+** it is 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,11 +1523,11 @@
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
1525
- while( db_step(q)==SQLITE_ROW && nLine<=mxLine ){
1528
+ while( db_step(q)==SQLITE_ROW && (mxLine<=0 || nLine<=mxLine) ){
15261529
int rid = db_column_int(q, 0);
15271530
const char *zId = db_column_text(q, 1);
15281531
const char *zDate = db_column_text(q, 2);
15291532
const char *zCom = db_column_text(q, 3);
15301533
int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,11 @@
15361539
15371540
sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
15381541
if( memcmp(zDate, zPrevDate, 10) ){
15391542
fossil_print("=== %.10s ===\n", zDate);
15401543
memcpy(zPrevDate, zDate, 10);
1541
- nLine++;
1544
+ nLine++; /* record another line */
15421545
}
15431546
if( zCom==0 ) zCom = "";
15441547
fossil_print("%.8s ", &zDate[11]);
15451548
zPrefix[0] = 0;
15461549
if( nParent>1 ){
@@ -1560,11 +1563,11 @@
15601563
if( fossil_strcmp(zCurrentUuid,zId)==0 ){
15611564
sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
15621565
n += strlen(zPrefix);
15631566
}
15641567
zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1565
- nLine += comment_print(zFree, 9, 79);
1568
+ nLine += comment_print(zFree, 9, 79); /* record another X lines */
15661569
sqlite3_free(zFree);
15671570
15681571
if(verboseFlag){
15691572
if( !fchngQueryInit ){
15701573
db_prepare(&fchngQuery,
@@ -1589,10 +1592,11 @@
15891592
}else if( isDel ){
15901593
fossil_print(" DELETED %s\n",zFilename);
15911594
}else{
15921595
fossil_print(" EDITED %s\n", zFilename);
15931596
}
1597
+ nLine++; /* record another line */
15941598
}
15951599
db_reset(&fchngQuery);
15961600
}
15971601
}
15981602
if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -1697,11 +1701,11 @@
16971701
zLimit = find_option("count",0,1);
16981702
}
16991703
if( zLimit ){
17001704
n = atoi(zLimit);
17011705
}else{
1702
- n = 20;
1706
+ n = -20;
17031707
}
17041708
if( g.argc>=4 ){
17051709
k = strlen(g.argv[2]);
17061710
if( strncmp(g.argv[2],"before",k)==0 ){
17071711
mode = 1;
@@ -1776,17 +1780,14 @@
17761780
blob_appendf(&sql, " AND event.type=%Q ", zType);
17771781
}
17781782
blob_appendf(&sql, " ORDER BY event.mtime DESC");
17791783
if(n>0){
17801784
blob_appendf(&sql, " LIMIT %d", n);
1781
- n = 9999999;
1782
- }else{
1783
- n = -n;
17841785
}
17851786
db_prepare(&q, blob_str(&sql));
17861787
blob_reset(&sql);
1787
- print_timeline(&q, n, verboseFlag);
1788
+ print_timeline(&q, n<0?-n:0, verboseFlag);
17881789
db_finalize(&q);
17891790
}
17901791
17911792
/*
17921793
** This is a version of the "localtime()" function from the standard
17931794
--- 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,11 +1523,11 @@
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);
1530 int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,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 +1563,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 +1592,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);
@@ -1697,11 +1701,11 @@
1697 zLimit = find_option("count",0,1);
1698 }
1699 if( zLimit ){
1700 n = atoi(zLimit);
1701 }else{
1702 n = 20;
1703 }
1704 if( g.argc>=4 ){
1705 k = strlen(g.argv[2]);
1706 if( strncmp(g.argv[2],"before",k)==0 ){
1707 mode = 1;
@@ -1776,17 +1780,14 @@
1776 blob_appendf(&sql, " AND event.type=%Q ", zType);
1777 }
1778 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1779 if(n>0){
1780 blob_appendf(&sql, " LIMIT %d", n);
1781 n = 9999999;
1782 }else{
1783 n = -n;
1784 }
1785 db_prepare(&q, blob_str(&sql));
1786 blob_reset(&sql);
1787 print_timeline(&q, n, verboseFlag);
1788 db_finalize(&q);
1789 }
1790
1791 /*
1792 ** This is a version of the "localtime()" function from the standard
1793
--- 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 mxLine. If mxLine is zero or
1500 ** negative there is no limit. The line limit is approximate because
1501 ** it is 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,11 +1523,11 @@
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 while( db_step(q)==SQLITE_ROW && (mxLine<=0 || nLine<=mxLine) ){
1529 int rid = db_column_int(q, 0);
1530 const char *zId = db_column_text(q, 1);
1531 const char *zDate = db_column_text(q, 2);
1532 const char *zCom = db_column_text(q, 3);
1533 int nChild = db_column_int(q, 4);
@@ -1536,11 +1539,11 @@
1539
1540 sqlite3_snprintf(sizeof(zUuid), zUuid, "%.10s", zId);
1541 if( memcmp(zDate, zPrevDate, 10) ){
1542 fossil_print("=== %.10s ===\n", zDate);
1543 memcpy(zPrevDate, zDate, 10);
1544 nLine++; /* record another line */
1545 }
1546 if( zCom==0 ) zCom = "";
1547 fossil_print("%.8s ", &zDate[11]);
1548 zPrefix[0] = 0;
1549 if( nParent>1 ){
@@ -1560,11 +1563,11 @@
1563 if( fossil_strcmp(zCurrentUuid,zId)==0 ){
1564 sqlite3_snprintf(sizeof(zPrefix)-n, &zPrefix[n], "*CURRENT* ");
1565 n += strlen(zPrefix);
1566 }
1567 zFree = sqlite3_mprintf("[%.10s] %s%s", zUuid, zPrefix, zCom);
1568 nLine += comment_print(zFree, 9, 79); /* record another X lines */
1569 sqlite3_free(zFree);
1570
1571 if(verboseFlag){
1572 if( !fchngQueryInit ){
1573 db_prepare(&fchngQuery,
@@ -1589,10 +1592,11 @@
1592 }else if( isDel ){
1593 fossil_print(" DELETED %s\n",zFilename);
1594 }else{
1595 fossil_print(" EDITED %s\n", zFilename);
1596 }
1597 nLine++; /* record another line */
1598 }
1599 db_reset(&fchngQuery);
1600 }
1601 }
1602 if( fchngQueryInit ) db_finalize(&fchngQuery);
@@ -1697,11 +1701,11 @@
1701 zLimit = find_option("count",0,1);
1702 }
1703 if( zLimit ){
1704 n = atoi(zLimit);
1705 }else{
1706 n = -20;
1707 }
1708 if( g.argc>=4 ){
1709 k = strlen(g.argv[2]);
1710 if( strncmp(g.argv[2],"before",k)==0 ){
1711 mode = 1;
@@ -1776,17 +1780,14 @@
1780 blob_appendf(&sql, " AND event.type=%Q ", zType);
1781 }
1782 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1783 if(n>0){
1784 blob_appendf(&sql, " LIMIT %d", n);
 
 
 
1785 }
1786 db_prepare(&q, blob_str(&sql));
1787 blob_reset(&sql);
1788 print_timeline(&q, n<0?-n:0, verboseFlag);
1789 db_finalize(&q);
1790 }
1791
1792 /*
1793 ** This is a version of the "localtime()" function from the standard
1794

Keyboard Shortcuts

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