Fossil SCM

Retain original finfo behavior by introducing a new "mode" for artifact-id.

andybradford 2021-04-13 13:53 trunk
Commit 5015043b2d3e06fbbd274e103968ec6c5fac9ef3936b1af5d5aecae112f17412
1 file changed +8 -3
+8 -3
--- src/finfo.c
+++ src/finfo.c
@@ -31,10 +31,13 @@
3131
** For the -l|--log mode: If "-b|--brief" is specified one line per revision
3232
** is printed, otherwise the full comment is printed. The "-n|--limit N"
3333
** and "--offset P" options limits the output to the first N changes
3434
** after skipping P changes.
3535
**
36
+** The -i mode will print the artifact ID of FILENAME given the REVISION
37
+** provided by the -r flag (which is required).
38
+
3639
** In the -s mode prints the status as <status> <revision>. This is
3740
** a quick status and does not check for up-to-date-ness of the file.
3841
**
3942
** In the -p mode, there's an optional flag "-r|--revision REVISION".
4043
** The specified version (or the latest checked out version) is printed
@@ -42,10 +45,11 @@
4245
**
4346
** Options:
4447
** -b|--brief Display a brief (one line / revision) summary
4548
** --case-sensitive B Enable or disable case-sensitive filenames. B is a
4649
** boolean: "yes", "no", "true", "false", etc.
50
+** -i|--id Print the artifact ID (requires -r)
4751
** -l|--log Select log mode (the default)
4852
** -n|--limit N Display the first N changes (default unlimited).
4953
** N less than 0 means no limit.
5054
** --offset P Skip P changes
5155
** -p|--print Select print mode
@@ -56,12 +60,10 @@
5660
** more than 22 or else 0 to indicate no limit.
5761
**
5862
** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
5963
*/
6064
void finfo_cmd(void){
61
- const char *zRevision = find_option("revision", "r", 1);
62
-
6365
db_must_be_within_tree();
6466
if( find_option("status","s",0) ){
6567
Stmt q;
6668
Blob line;
6769
Blob fname;
@@ -118,10 +120,11 @@
118120
blob_reset(&fname);
119121
blob_reset(&line);
120122
}else if( find_option("print","p",0) ){
121123
Blob record;
122124
Blob fname;
125
+ const char *zRevision = find_option("revision", "r", 1);
123126
124127
/* We should be done with options.. */
125128
verify_all_options();
126129
127130
file_tree_name(g.argv[2], &fname, 0, 1);
@@ -136,15 +139,17 @@
136139
content_get(rid, &record);
137140
}
138141
blob_write_to_file(&record, "-");
139142
blob_reset(&record);
140143
blob_reset(&fname);
141
- }else if( zRevision && zRevision[0] ){
144
+ }else if( find_option("id","i",0) ){
142145
Blob fname;
146
+ const char *zRevision = find_option("revision", "r", 1);
143147
144148
verify_all_options();
145149
150
+ if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
146151
if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
147152
file_tree_name(g.argv[2], &fname, 0, 1);
148153
int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
149154
" (SELECT uuid FROM files_of_checkin(%Q)"
150155
" WHERE filename=%B %s)",
151156
--- src/finfo.c
+++ src/finfo.c
@@ -31,10 +31,13 @@
31 ** For the -l|--log mode: If "-b|--brief" is specified one line per revision
32 ** is printed, otherwise the full comment is printed. The "-n|--limit N"
33 ** and "--offset P" options limits the output to the first N changes
34 ** after skipping P changes.
35 **
 
 
 
36 ** In the -s mode prints the status as <status> <revision>. This is
37 ** a quick status and does not check for up-to-date-ness of the file.
38 **
39 ** In the -p mode, there's an optional flag "-r|--revision REVISION".
40 ** The specified version (or the latest checked out version) is printed
@@ -42,10 +45,11 @@
42 **
43 ** Options:
44 ** -b|--brief Display a brief (one line / revision) summary
45 ** --case-sensitive B Enable or disable case-sensitive filenames. B is a
46 ** boolean: "yes", "no", "true", "false", etc.
 
47 ** -l|--log Select log mode (the default)
48 ** -n|--limit N Display the first N changes (default unlimited).
49 ** N less than 0 means no limit.
50 ** --offset P Skip P changes
51 ** -p|--print Select print mode
@@ -56,12 +60,10 @@
56 ** more than 22 or else 0 to indicate no limit.
57 **
58 ** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
59 */
60 void finfo_cmd(void){
61 const char *zRevision = find_option("revision", "r", 1);
62
63 db_must_be_within_tree();
64 if( find_option("status","s",0) ){
65 Stmt q;
66 Blob line;
67 Blob fname;
@@ -118,10 +120,11 @@
118 blob_reset(&fname);
119 blob_reset(&line);
120 }else if( find_option("print","p",0) ){
121 Blob record;
122 Blob fname;
 
123
124 /* We should be done with options.. */
125 verify_all_options();
126
127 file_tree_name(g.argv[2], &fname, 0, 1);
@@ -136,15 +139,17 @@
136 content_get(rid, &record);
137 }
138 blob_write_to_file(&record, "-");
139 blob_reset(&record);
140 blob_reset(&fname);
141 }else if( zRevision && zRevision[0] ){
142 Blob fname;
 
143
144 verify_all_options();
145
 
146 if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
147 file_tree_name(g.argv[2], &fname, 0, 1);
148 int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
149 " (SELECT uuid FROM files_of_checkin(%Q)"
150 " WHERE filename=%B %s)",
151
--- src/finfo.c
+++ src/finfo.c
@@ -31,10 +31,13 @@
31 ** For the -l|--log mode: If "-b|--brief" is specified one line per revision
32 ** is printed, otherwise the full comment is printed. The "-n|--limit N"
33 ** and "--offset P" options limits the output to the first N changes
34 ** after skipping P changes.
35 **
36 ** The -i mode will print the artifact ID of FILENAME given the REVISION
37 ** provided by the -r flag (which is required).
38
39 ** In the -s mode prints the status as <status> <revision>. This is
40 ** a quick status and does not check for up-to-date-ness of the file.
41 **
42 ** In the -p mode, there's an optional flag "-r|--revision REVISION".
43 ** The specified version (or the latest checked out version) is printed
@@ -42,10 +45,11 @@
45 **
46 ** Options:
47 ** -b|--brief Display a brief (one line / revision) summary
48 ** --case-sensitive B Enable or disable case-sensitive filenames. B is a
49 ** boolean: "yes", "no", "true", "false", etc.
50 ** -i|--id Print the artifact ID (requires -r)
51 ** -l|--log Select log mode (the default)
52 ** -n|--limit N Display the first N changes (default unlimited).
53 ** N less than 0 means no limit.
54 ** --offset P Skip P changes
55 ** -p|--print Select print mode
@@ -56,12 +60,10 @@
60 ** more than 22 or else 0 to indicate no limit.
61 **
62 ** See also: [[artifact]], [[cat]], [[descendants]], [[info]], [[leaves]]
63 */
64 void finfo_cmd(void){
 
 
65 db_must_be_within_tree();
66 if( find_option("status","s",0) ){
67 Stmt q;
68 Blob line;
69 Blob fname;
@@ -118,10 +120,11 @@
120 blob_reset(&fname);
121 blob_reset(&line);
122 }else if( find_option("print","p",0) ){
123 Blob record;
124 Blob fname;
125 const char *zRevision = find_option("revision", "r", 1);
126
127 /* We should be done with options.. */
128 verify_all_options();
129
130 file_tree_name(g.argv[2], &fname, 0, 1);
@@ -136,15 +139,17 @@
139 content_get(rid, &record);
140 }
141 blob_write_to_file(&record, "-");
142 blob_reset(&record);
143 blob_reset(&fname);
144 }else if( find_option("id","i",0) ){
145 Blob fname;
146 const char *zRevision = find_option("revision", "r", 1);
147
148 verify_all_options();
149
150 if( zRevision==0 ) usage("-i|--id also requires -r|--revision");
151 if( g.argc!=3 ) usage("-r|--revision REVISION FILENAME");
152 file_tree_name(g.argv[2], &fname, 0, 1);
153 int rid = db_int(0, "SELECT rid FROM blob WHERE uuid ="
154 " (SELECT uuid FROM files_of_checkin(%Q)"
155 " WHERE filename=%B %s)",
156

Keyboard Shortcuts

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