Fossil SCM

Add option -W|--width to the "fossil timeline" and "fossil finfo" commands. Defaults to 79.

jan.nijtmans 2013-10-29 10:55 trunk
Commit 2eb492e28242bada2cc26cc7a78cbe69d4d09bf6
+6 -6
--- src/comformat.c
+++ src/comformat.c
@@ -36,12 +36,15 @@
3636
int doIndent = 0;
3737
char *zBuf;
3838
char zBuffer[400];
3939
int lineCnt = 0;
4040
41
- if( lineLength > sizeof(zBuffer) ){
42
- zBuf = fossil_malloc(lineLength);
41
+ if( tlen<=0 ){
42
+ tlen = strlen(zText);
43
+ }
44
+ if( tlen >= (sizeof(zBuffer)) ){
45
+ zBuf = fossil_malloc(tlen+1);
4346
}else{
4447
zBuf = zBuffer;
4548
}
4649
for(;;){
4750
while( fossil_isspace(zText[0]) ){ zText++; }
@@ -74,19 +77,16 @@
7477
fossil_print("%*s", indent, "");
7578
}
7679
doIndent = 1;
7780
if( sk>0 && zText[i] ){
7881
zText += si;
79
- zBuf[sk++] = '\n';
8082
zBuf[sk] = 0;
81
- fossil_print("%s", zBuf);
8283
}else{
8384
zText += i;
84
- zBuf[k++] = '\n';
8585
zBuf[k] = 0;
86
- fossil_print("%s", zBuf);
8786
}
87
+ fossil_print("%s\n", zBuf);
8888
lineCnt++;
8989
}
9090
}
9191
9292
/*
9393
--- src/comformat.c
+++ src/comformat.c
@@ -36,12 +36,15 @@
36 int doIndent = 0;
37 char *zBuf;
38 char zBuffer[400];
39 int lineCnt = 0;
40
41 if( lineLength > sizeof(zBuffer) ){
42 zBuf = fossil_malloc(lineLength);
 
 
 
43 }else{
44 zBuf = zBuffer;
45 }
46 for(;;){
47 while( fossil_isspace(zText[0]) ){ zText++; }
@@ -74,19 +77,16 @@
74 fossil_print("%*s", indent, "");
75 }
76 doIndent = 1;
77 if( sk>0 && zText[i] ){
78 zText += si;
79 zBuf[sk++] = '\n';
80 zBuf[sk] = 0;
81 fossil_print("%s", zBuf);
82 }else{
83 zText += i;
84 zBuf[k++] = '\n';
85 zBuf[k] = 0;
86 fossil_print("%s", zBuf);
87 }
 
88 lineCnt++;
89 }
90 }
91
92 /*
93
--- src/comformat.c
+++ src/comformat.c
@@ -36,12 +36,15 @@
36 int doIndent = 0;
37 char *zBuf;
38 char zBuffer[400];
39 int lineCnt = 0;
40
41 if( tlen<=0 ){
42 tlen = strlen(zText);
43 }
44 if( tlen >= (sizeof(zBuffer)) ){
45 zBuf = fossil_malloc(tlen+1);
46 }else{
47 zBuf = zBuffer;
48 }
49 for(;;){
50 while( fossil_isspace(zText[0]) ){ zText++; }
@@ -74,19 +77,16 @@
77 fossil_print("%*s", indent, "");
78 }
79 doIndent = 1;
80 if( sk>0 && zText[i] ){
81 zText += si;
 
82 zBuf[sk] = 0;
 
83 }else{
84 zText += i;
 
85 zBuf[k] = 0;
 
86 }
87 fossil_print("%s\n", zBuf);
88 lineCnt++;
89 }
90 }
91
92 /*
93
+9 -2
--- src/finfo.c
+++ src/finfo.c
@@ -49,10 +49,11 @@
4949
** --offset P skip P changes
5050
** -p|--print select print mode
5151
** -r|--revision R print the given revision (or ckout, if none is given)
5252
** to stdout (only in print mode)
5353
** -s|--status select status mode (print a status indicator for FILE)
54
+** -W|--width <num> With of lines (default 79). Must be >22 or 0.
5455
**
5556
** See also: artifact, cat, descendants, info, leaves
5657
*/
5758
void finfo_cmd(void){
5859
capture_case_sensitive_option();
@@ -134,21 +135,27 @@
134135
Stmt q;
135136
Blob fname;
136137
int rid;
137138
const char *zFilename;
138139
const char *zLimit;
140
+ const char *zWidth;
139141
const char *zOffset;
140
- int iLimit, iOffset, iBrief;
142
+ int iLimit, iOffset, iBrief, iWidth;
141143
142144
if( find_option("log","l",0) ){
143145
/* this is the default, no-op */
144146
}
145147
zLimit = find_option("limit","n",1);
148
+ zWidth = find_option("width","W",1);
146149
iLimit = zLimit ? atoi(zLimit) : -1;
150
+ iWidth = zWidth ? atoi(zWidth) : 79;
147151
zOffset = find_option("offset",0,1);
148152
iOffset = zOffset ? atoi(zOffset) : 0;
149153
iBrief = (find_option("brief","b",0) == 0);
154
+ if( (iWidth!=0) && (iWidth<=22) ){
155
+ fossil_fatal("--width|-W value must be >22 or 0");
156
+ }
150157
if( g.argc!=3 ){
151158
usage("?-l|--log? ?-b|--brief? FILENAME");
152159
}
153160
file_tree_name(g.argv[2], &fname, 1);
154161
rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
@@ -188,11 +195,11 @@
188195
if( iBrief ){
189196
fossil_print("%s ", zDate);
190197
zOut = sqlite3_mprintf(
191198
"[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
192199
zCiUuid, zCom, zUser, zFileUuid, zBr);
193
- comment_print(zOut, 11, 79);
200
+ comment_print(zOut, 11, iWidth);
194201
sqlite3_free(zOut);
195202
}else{
196203
blob_reset(&line);
197204
blob_appendf(&line, "%.10s ", zCiUuid);
198205
blob_appendf(&line, "%.10s ", zDate);
199206
--- src/finfo.c
+++ src/finfo.c
@@ -49,10 +49,11 @@
49 ** --offset P skip P changes
50 ** -p|--print select print mode
51 ** -r|--revision R print the given revision (or ckout, if none is given)
52 ** to stdout (only in print mode)
53 ** -s|--status select status mode (print a status indicator for FILE)
 
54 **
55 ** See also: artifact, cat, descendants, info, leaves
56 */
57 void finfo_cmd(void){
58 capture_case_sensitive_option();
@@ -134,21 +135,27 @@
134 Stmt q;
135 Blob fname;
136 int rid;
137 const char *zFilename;
138 const char *zLimit;
 
139 const char *zOffset;
140 int iLimit, iOffset, iBrief;
141
142 if( find_option("log","l",0) ){
143 /* this is the default, no-op */
144 }
145 zLimit = find_option("limit","n",1);
 
146 iLimit = zLimit ? atoi(zLimit) : -1;
 
147 zOffset = find_option("offset",0,1);
148 iOffset = zOffset ? atoi(zOffset) : 0;
149 iBrief = (find_option("brief","b",0) == 0);
 
 
 
150 if( g.argc!=3 ){
151 usage("?-l|--log? ?-b|--brief? FILENAME");
152 }
153 file_tree_name(g.argv[2], &fname, 1);
154 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
@@ -188,11 +195,11 @@
188 if( iBrief ){
189 fossil_print("%s ", zDate);
190 zOut = sqlite3_mprintf(
191 "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
192 zCiUuid, zCom, zUser, zFileUuid, zBr);
193 comment_print(zOut, 11, 79);
194 sqlite3_free(zOut);
195 }else{
196 blob_reset(&line);
197 blob_appendf(&line, "%.10s ", zCiUuid);
198 blob_appendf(&line, "%.10s ", zDate);
199
--- src/finfo.c
+++ src/finfo.c
@@ -49,10 +49,11 @@
49 ** --offset P skip P changes
50 ** -p|--print select print mode
51 ** -r|--revision R print the given revision (or ckout, if none is given)
52 ** to stdout (only in print mode)
53 ** -s|--status select status mode (print a status indicator for FILE)
54 ** -W|--width <num> With of lines (default 79). Must be >22 or 0.
55 **
56 ** See also: artifact, cat, descendants, info, leaves
57 */
58 void finfo_cmd(void){
59 capture_case_sensitive_option();
@@ -134,21 +135,27 @@
135 Stmt q;
136 Blob fname;
137 int rid;
138 const char *zFilename;
139 const char *zLimit;
140 const char *zWidth;
141 const char *zOffset;
142 int iLimit, iOffset, iBrief, iWidth;
143
144 if( find_option("log","l",0) ){
145 /* this is the default, no-op */
146 }
147 zLimit = find_option("limit","n",1);
148 zWidth = find_option("width","W",1);
149 iLimit = zLimit ? atoi(zLimit) : -1;
150 iWidth = zWidth ? atoi(zWidth) : 79;
151 zOffset = find_option("offset",0,1);
152 iOffset = zOffset ? atoi(zOffset) : 0;
153 iBrief = (find_option("brief","b",0) == 0);
154 if( (iWidth!=0) && (iWidth<=22) ){
155 fossil_fatal("--width|-W value must be >22 or 0");
156 }
157 if( g.argc!=3 ){
158 usage("?-l|--log? ?-b|--brief? FILENAME");
159 }
160 file_tree_name(g.argv[2], &fname, 1);
161 rid = db_int(0, "SELECT rid FROM vfile WHERE pathname=%B %s",
@@ -188,11 +195,11 @@
195 if( iBrief ){
196 fossil_print("%s ", zDate);
197 zOut = sqlite3_mprintf(
198 "[%.10s] %s (user: %s, artifact: [%.10s], branch: %s)",
199 zCiUuid, zCom, zUser, zFileUuid, zBr);
200 comment_print(zOut, 11, iWidth);
201 sqlite3_free(zOut);
202 }else{
203 blob_reset(&line);
204 blob_appendf(&line, "%.10s ", zCiUuid);
205 blob_appendf(&line, "%.10s ", zDate);
206
+14 -3
--- src/timeline.c
+++ src/timeline.c
@@ -1675,15 +1675,17 @@
16751675
** t = tickets only
16761676
** w = wiki commits only
16771677
** -v|--verbose Output the list of files changed by each commit
16781678
** and the type of each change (edited, deleted,
16791679
** etc.) after the checkin comment.
1680
+** -W|--width <num> With of lines (default 79). Must be >20 or 0.
16801681
*/
16811682
void timeline_cmd(void){
16821683
Stmt q;
1683
- int n, k;
1684
+ int n, k, width;
16841685
const char *zLimit;
1686
+ const char *zWidth;
16851687
const char *zType;
16861688
char *zOrigin;
16871689
char *zDate;
16881690
Blob sql;
16891691
int objid = 0;
@@ -1694,18 +1696,27 @@
16941696
if( !verboseFlag){
16951697
verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
16961698
}
16971699
db_find_and_open_repository(0, 0);
16981700
zLimit = find_option("limit","n",1);
1701
+ zWidth = find_option("width","W",1);
16991702
zType = find_option("type","t",1);
17001703
if ( !zLimit ){
17011704
zLimit = find_option("count",0,1);
17021705
}
17031706
if( zLimit ){
17041707
n = atoi(zLimit);
17051708
}else{
17061709
n = 20;
1710
+ }
1711
+ if( zWidth ){
1712
+ width = atoi(zWidth);
1713
+ if( (width!=0) && (width<=20) ){
1714
+ fossil_fatal("--width|-W value must be >20 or 0");
1715
+ }
1716
+ }else{
1717
+ width = 79;
17071718
}
17081719
if( g.argc>=4 ){
17091720
k = strlen(g.argv[2]);
17101721
if( strncmp(g.argv[2],"before",k)==0 ){
17111722
mode = 1;
@@ -1718,11 +1729,11 @@
17181729
}else if( strncmp(g.argv[2],"ancestors",k)==0 && k>1 ){
17191730
mode = 4;
17201731
}else if( strncmp(g.argv[2],"parents",k)==0 ){
17211732
mode = 4;
17221733
}else if(!zType && !zLimit){
1723
- usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit N? ?-t|--type TYPE?");
1734
+ usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit N? ?-t|--type TYPE? ?-W|--width WIDTH?");
17241735
}
17251736
if( '-' != *g.argv[3] ){
17261737
zOrigin = g.argv[3];
17271738
}else{
17281739
zOrigin = "now";
@@ -1780,11 +1791,11 @@
17801791
blob_appendf(&sql, " AND event.type=%Q ", zType);
17811792
}
17821793
blob_appendf(&sql, " ORDER BY event.mtime DESC");
17831794
db_prepare(&q, blob_str(&sql));
17841795
blob_reset(&sql);
1785
- print_timeline(&q, n, 79, verboseFlag);
1796
+ print_timeline(&q, n, width, verboseFlag);
17861797
db_finalize(&q);
17871798
}
17881799
17891800
/*
17901801
** This is a version of the "localtime()" function from the standard
17911802
--- src/timeline.c
+++ src/timeline.c
@@ -1675,15 +1675,17 @@
1675 ** t = tickets only
1676 ** w = wiki commits only
1677 ** -v|--verbose Output the list of files changed by each commit
1678 ** and the type of each change (edited, deleted,
1679 ** etc.) after the checkin comment.
 
1680 */
1681 void timeline_cmd(void){
1682 Stmt q;
1683 int n, k;
1684 const char *zLimit;
 
1685 const char *zType;
1686 char *zOrigin;
1687 char *zDate;
1688 Blob sql;
1689 int objid = 0;
@@ -1694,18 +1696,27 @@
1694 if( !verboseFlag){
1695 verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
1696 }
1697 db_find_and_open_repository(0, 0);
1698 zLimit = find_option("limit","n",1);
 
1699 zType = find_option("type","t",1);
1700 if ( !zLimit ){
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;
@@ -1718,11 +1729,11 @@
1718 }else if( strncmp(g.argv[2],"ancestors",k)==0 && k>1 ){
1719 mode = 4;
1720 }else if( strncmp(g.argv[2],"parents",k)==0 ){
1721 mode = 4;
1722 }else if(!zType && !zLimit){
1723 usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit N? ?-t|--type TYPE?");
1724 }
1725 if( '-' != *g.argv[3] ){
1726 zOrigin = g.argv[3];
1727 }else{
1728 zOrigin = "now";
@@ -1780,11 +1791,11 @@
1780 blob_appendf(&sql, " AND event.type=%Q ", zType);
1781 }
1782 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1783 db_prepare(&q, blob_str(&sql));
1784 blob_reset(&sql);
1785 print_timeline(&q, n, 79, verboseFlag);
1786 db_finalize(&q);
1787 }
1788
1789 /*
1790 ** This is a version of the "localtime()" function from the standard
1791
--- src/timeline.c
+++ src/timeline.c
@@ -1675,15 +1675,17 @@
1675 ** t = tickets only
1676 ** w = wiki commits only
1677 ** -v|--verbose Output the list of files changed by each commit
1678 ** and the type of each change (edited, deleted,
1679 ** etc.) after the checkin comment.
1680 ** -W|--width <num> With of lines (default 79). Must be >20 or 0.
1681 */
1682 void timeline_cmd(void){
1683 Stmt q;
1684 int n, k, width;
1685 const char *zLimit;
1686 const char *zWidth;
1687 const char *zType;
1688 char *zOrigin;
1689 char *zDate;
1690 Blob sql;
1691 int objid = 0;
@@ -1694,18 +1696,27 @@
1696 if( !verboseFlag){
1697 verboseFlag = find_option("showfiles","f", 0)!=0; /* deprecated */
1698 }
1699 db_find_and_open_repository(0, 0);
1700 zLimit = find_option("limit","n",1);
1701 zWidth = find_option("width","W",1);
1702 zType = find_option("type","t",1);
1703 if ( !zLimit ){
1704 zLimit = find_option("count",0,1);
1705 }
1706 if( zLimit ){
1707 n = atoi(zLimit);
1708 }else{
1709 n = 20;
1710 }
1711 if( zWidth ){
1712 width = atoi(zWidth);
1713 if( (width!=0) && (width<=20) ){
1714 fossil_fatal("--width|-W value must be >20 or 0");
1715 }
1716 }else{
1717 width = 79;
1718 }
1719 if( g.argc>=4 ){
1720 k = strlen(g.argv[2]);
1721 if( strncmp(g.argv[2],"before",k)==0 ){
1722 mode = 1;
@@ -1718,11 +1729,11 @@
1729 }else if( strncmp(g.argv[2],"ancestors",k)==0 && k>1 ){
1730 mode = 4;
1731 }else if( strncmp(g.argv[2],"parents",k)==0 ){
1732 mode = 4;
1733 }else if(!zType && !zLimit){
1734 usage("?WHEN? ?BASELINE|DATETIME? ?-n|--limit N? ?-t|--type TYPE? ?-W|--width WIDTH?");
1735 }
1736 if( '-' != *g.argv[3] ){
1737 zOrigin = g.argv[3];
1738 }else{
1739 zOrigin = "now";
@@ -1780,11 +1791,11 @@
1791 blob_appendf(&sql, " AND event.type=%Q ", zType);
1792 }
1793 blob_appendf(&sql, " ORDER BY event.mtime DESC");
1794 db_prepare(&q, blob_str(&sql));
1795 blob_reset(&sql);
1796 print_timeline(&q, n, width, verboseFlag);
1797 db_finalize(&q);
1798 }
1799
1800 /*
1801 ** This is a version of the "localtime()" function from the standard
1802
--- www/changes.wiki
+++ www/changes.wiki
@@ -18,10 +18,12 @@
1818
supply REQUEST_URI.
1919
* Add options --dirsonly, --emptydirs, and --allckouts to the
2020
"[/help?cmd=clean | fossil clean]" command.
2121
* Ten-fold performance improvement in large "fossil blame" or
2222
"fossil annotate" commands.
23
+ * Add option -W|--width to the "[/help?cmd=timeline | fossil timeline]"
24
+ and "[/help?cmd=finfo | fossil finfo]" commands.
2325
2426
<h2>Changes For Version 1.27 (2013-09-11)</h2>
2527
* Enhance the [/help?cmd=changes | fossil changes],
2628
[/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
2729
[/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
2830
--- www/changes.wiki
+++ www/changes.wiki
@@ -18,10 +18,12 @@
18 supply REQUEST_URI.
19 * Add options --dirsonly, --emptydirs, and --allckouts to the
20 "[/help?cmd=clean | fossil clean]" command.
21 * Ten-fold performance improvement in large "fossil blame" or
22 "fossil annotate" commands.
 
 
23
24 <h2>Changes For Version 1.27 (2013-09-11)</h2>
25 * Enhance the [/help?cmd=changes | fossil changes],
26 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
27 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
28
--- www/changes.wiki
+++ www/changes.wiki
@@ -18,10 +18,12 @@
18 supply REQUEST_URI.
19 * Add options --dirsonly, --emptydirs, and --allckouts to the
20 "[/help?cmd=clean | fossil clean]" command.
21 * Ten-fold performance improvement in large "fossil blame" or
22 "fossil annotate" commands.
23 * Add option -W|--width to the "[/help?cmd=timeline | fossil timeline]"
24 and "[/help?cmd=finfo | fossil finfo]" commands.
25
26 <h2>Changes For Version 1.27 (2013-09-11)</h2>
27 * Enhance the [/help?cmd=changes | fossil changes],
28 [/help?cmd=clean | fossil clean], [/help?cmd=extras | fossil extras],
29 [/help?cmd=ls | fossil ls] and [/help?cmd=status | fossil status] commands
30

Keyboard Shortcuts

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