Fossil SCM

Add a --show-artifact-ids to the 'fossil wiki list' command. Note this commit does not add the ability to select what to update on the 'fossil wiki commit' command, that is to come in a later commit.

dave.vines 2016-04-04 17:30
Commit cbda43e71bda52f04c7d5f44c0067340d01542c0
2 files changed +33 -10 +30 -1
+33 -10
--- src/wiki.c
+++ src/wiki.c
@@ -1166,18 +1166,25 @@
11661166
** updated.
11671167
** --technote-tags TAGS The set of tags for a technote.
11681168
** --technote-bgcolor COLOR The color used for the technote
11691169
** on the timeline.
11701170
**
1171
-** %fossil wiki list ?--technote?
1172
-** %fossil wiki ls ?--technote?
1171
+** %fossil wiki list ?OPTIONS?
1172
+** %fossil wiki ls ?OPTIONS?
11731173
**
11741174
** Lists all wiki entries, one per line, ordered
1175
-** case-insensitively by name. The --technote flag
1176
-** specifies that technotes will be listed instead of
1177
-** the wiki entries, which will be listed in order
1178
-** timestamp.
1175
+** case-insensitively by name.
1176
+**
1177
+** Options:
1178
+** --technote Technotes will be listed instead of
1179
+** pages. The technotes will be in order
1180
+** of timestamp with the most recent
1181
+** first.
1182
+** --show-artifact-ids The artifact id of the wiki page or
1183
+** tech note will be listed along side the
1184
+** page name or timestamp. The artifact id
1185
+** will be the first word on each line.
11791186
**
11801187
*/
11811188
void wiki_cmd(void){
11821189
int n;
11831190
db_find_and_open_repository(0, 0);
@@ -1319,24 +1326,40 @@
13191326
}
13201327
fossil_fatal("delete not yet implemented.");
13211328
}else if(( strncmp(g.argv[2],"list",n)==0 )
13221329
|| ( strncmp(g.argv[2],"ls",n)==0 )){
13231330
Stmt q;
1331
+ int showIds = find_option("show-artifact-ids","s",0)!=0;
1332
+
13241333
if ( !find_option("technote","t",0) ){
13251334
db_prepare(&q,
1326
- "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
1335
+ "SELECT substr(t.tagname, 6), b.uuid"
1336
+ " FROM tag t, tagxref x, blob b"
1337
+ " WHERE tagname GLOB 'wiki-*'"
1338
+ " AND t.tagid=x.tagid AND b.rid=x.rid"
1339
+ " AND x.mtime=(SELECT MAX(xx.mtime)"
1340
+ " FROM tagxref xx"
1341
+ " WHERE xx.tagid=x.tagid)"
13271342
" ORDER BY lower(tagname) /*sort*/"
13281343
);
13291344
}else{
13301345
db_prepare(&q,
1331
- "SELECT datetime(mtime) FROM event WHERE type='e'"
1332
- " AND tagid IS NOT NULL"
1333
- " ORDER BY mtime /*sort*/"
1346
+ "SELECT datetime(e.mtime), substr(t.tagname,7) "
1347
+ " FROM event e, tag t"
1348
+ " WHERE e.type='e'"
1349
+ " AND e.tagid IS NOT NULL"
1350
+ " AND t.tagid=e.tagid"
1351
+ " ORDER BY e.mtime DESC /*sort*/"
13341352
);
13351353
}
1354
+
13361355
while( db_step(&q)==SQLITE_ROW ){
13371356
const char *zName = db_column_text(&q, 0);
1357
+ if (showIds) {
1358
+ const char *zUuid = db_column_text(&q, 1);
1359
+ fossil_print("%s ",zUuid);
1360
+ }
13381361
fossil_print( "%s\n",zName);
13391362
}
13401363
db_finalize(&q);
13411364
}else{
13421365
goto wiki_cmd_usage;
13431366
--- src/wiki.c
+++ src/wiki.c
@@ -1166,18 +1166,25 @@
1166 ** updated.
1167 ** --technote-tags TAGS The set of tags for a technote.
1168 ** --technote-bgcolor COLOR The color used for the technote
1169 ** on the timeline.
1170 **
1171 ** %fossil wiki list ?--technote?
1172 ** %fossil wiki ls ?--technote?
1173 **
1174 ** Lists all wiki entries, one per line, ordered
1175 ** case-insensitively by name. The --technote flag
1176 ** specifies that technotes will be listed instead of
1177 ** the wiki entries, which will be listed in order
1178 ** timestamp.
 
 
 
 
 
 
 
1179 **
1180 */
1181 void wiki_cmd(void){
1182 int n;
1183 db_find_and_open_repository(0, 0);
@@ -1319,24 +1326,40 @@
1319 }
1320 fossil_fatal("delete not yet implemented.");
1321 }else if(( strncmp(g.argv[2],"list",n)==0 )
1322 || ( strncmp(g.argv[2],"ls",n)==0 )){
1323 Stmt q;
 
 
1324 if ( !find_option("technote","t",0) ){
1325 db_prepare(&q,
1326 "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"
 
 
 
 
 
 
1327 " ORDER BY lower(tagname) /*sort*/"
1328 );
1329 }else{
1330 db_prepare(&q,
1331 "SELECT datetime(mtime) FROM event WHERE type='e'"
1332 " AND tagid IS NOT NULL"
1333 " ORDER BY mtime /*sort*/"
 
 
 
1334 );
1335 }
 
1336 while( db_step(&q)==SQLITE_ROW ){
1337 const char *zName = db_column_text(&q, 0);
 
 
 
 
1338 fossil_print( "%s\n",zName);
1339 }
1340 db_finalize(&q);
1341 }else{
1342 goto wiki_cmd_usage;
1343
--- src/wiki.c
+++ src/wiki.c
@@ -1166,18 +1166,25 @@
1166 ** updated.
1167 ** --technote-tags TAGS The set of tags for a technote.
1168 ** --technote-bgcolor COLOR The color used for the technote
1169 ** on the timeline.
1170 **
1171 ** %fossil wiki list ?OPTIONS?
1172 ** %fossil wiki ls ?OPTIONS?
1173 **
1174 ** Lists all wiki entries, one per line, ordered
1175 ** case-insensitively by name.
1176 **
1177 ** Options:
1178 ** --technote Technotes will be listed instead of
1179 ** pages. The technotes will be in order
1180 ** of timestamp with the most recent
1181 ** first.
1182 ** --show-artifact-ids The artifact id of the wiki page or
1183 ** tech note will be listed along side the
1184 ** page name or timestamp. The artifact id
1185 ** will be the first word on each line.
1186 **
1187 */
1188 void wiki_cmd(void){
1189 int n;
1190 db_find_and_open_repository(0, 0);
@@ -1319,24 +1326,40 @@
1326 }
1327 fossil_fatal("delete not yet implemented.");
1328 }else if(( strncmp(g.argv[2],"list",n)==0 )
1329 || ( strncmp(g.argv[2],"ls",n)==0 )){
1330 Stmt q;
1331 int showIds = find_option("show-artifact-ids","s",0)!=0;
1332
1333 if ( !find_option("technote","t",0) ){
1334 db_prepare(&q,
1335 "SELECT substr(t.tagname, 6), b.uuid"
1336 " FROM tag t, tagxref x, blob b"
1337 " WHERE tagname GLOB 'wiki-*'"
1338 " AND t.tagid=x.tagid AND b.rid=x.rid"
1339 " AND x.mtime=(SELECT MAX(xx.mtime)"
1340 " FROM tagxref xx"
1341 " WHERE xx.tagid=x.tagid)"
1342 " ORDER BY lower(tagname) /*sort*/"
1343 );
1344 }else{
1345 db_prepare(&q,
1346 "SELECT datetime(e.mtime), substr(t.tagname,7) "
1347 " FROM event e, tag t"
1348 " WHERE e.type='e'"
1349 " AND e.tagid IS NOT NULL"
1350 " AND t.tagid=e.tagid"
1351 " ORDER BY e.mtime DESC /*sort*/"
1352 );
1353 }
1354
1355 while( db_step(&q)==SQLITE_ROW ){
1356 const char *zName = db_column_text(&q, 0);
1357 if (showIds) {
1358 const char *zUuid = db_column_text(&q, 1);
1359 fossil_print("%s ",zUuid);
1360 }
1361 fossil_print( "%s\n",zName);
1362 }
1363 db_finalize(&q);
1364 }else{
1365 goto wiki_cmd_usage;
1366
+30 -1
--- test/wiki.test
+++ test/wiki.test
@@ -217,11 +217,40 @@
217217
###############################################################################
218218
# Check that we have the expected number of tech notes on the list (and not
219219
# extra ones from other events (such as the attachments) - 7 tech notes
220220
# expected created by tests 9, 17, 19, 29, 31, 32 and 34
221221
fossil wiki list --technote
222
-test wiki-37 {[llength [split $RESULT "\n"]] == 7}
222
+set technotelist [split $RESULT "\n"]
223
+test wiki-37 {[llength $technotelist] == 7}
224
+
225
+###############################################################################
226
+# Check that using the show-artifact-ids shows the same tech notes in the same
227
+# order (with the artifact id as the first word of the line
228
+fossil wiki list --technote --show-artifact-ids
229
+set technoteartifactlist [split $RESULT "\n"]
230
+test wiki-38 {[llength $technoteartifactlist] == 7}
231
+for {set i 0} {$i < [llength $technotelist]} {incr i} {
232
+ set match "*"
233
+ append match [lindex $technotelist $i]
234
+ test "wiki-39-$i" {[string match $match [lindex $technoteartifactlist $i]]}
235
+}
236
+
237
+###############################################################################
238
+# Similarly check that wiki pages can have their artifact ids displayed
239
+# Note: the tests above have only created a single wiki page, hence the list
240
+# should be of length 1 at this point (created by test 1)
241
+fossil wiki list
242
+set wikilist [split $RESULT "\n"]
243
+test wiki-40 {[llength $wikilist] == 1}
244
+fossil wiki list --show-artifact-ids
245
+set wikiartifactlist [split $RESULT "\n"]
246
+test wiki-41 {[llength $wikilist] == [llength $wikiartifactlist]}
247
+for {set i 0} {$i < [llength $wikilist]} {incr i} {
248
+ set match "*"
249
+ append match [lindex $wikilist $i]
250
+ test "wiki-42-$i" {[string match $match [lindex $wikiartifactlist $i]]}
251
+}
223252
224253
###############################################################################
225254
226255
test_cleanup
227256
228257
--- test/wiki.test
+++ test/wiki.test
@@ -217,11 +217,40 @@
217 ###############################################################################
218 # Check that we have the expected number of tech notes on the list (and not
219 # extra ones from other events (such as the attachments) - 7 tech notes
220 # expected created by tests 9, 17, 19, 29, 31, 32 and 34
221 fossil wiki list --technote
222 test wiki-37 {[llength [split $RESULT "\n"]] == 7}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
223
224 ###############################################################################
225
226 test_cleanup
227
228
--- test/wiki.test
+++ test/wiki.test
@@ -217,11 +217,40 @@
217 ###############################################################################
218 # Check that we have the expected number of tech notes on the list (and not
219 # extra ones from other events (such as the attachments) - 7 tech notes
220 # expected created by tests 9, 17, 19, 29, 31, 32 and 34
221 fossil wiki list --technote
222 set technotelist [split $RESULT "\n"]
223 test wiki-37 {[llength $technotelist] == 7}
224
225 ###############################################################################
226 # Check that using the show-artifact-ids shows the same tech notes in the same
227 # order (with the artifact id as the first word of the line
228 fossil wiki list --technote --show-artifact-ids
229 set technoteartifactlist [split $RESULT "\n"]
230 test wiki-38 {[llength $technoteartifactlist] == 7}
231 for {set i 0} {$i < [llength $technotelist]} {incr i} {
232 set match "*"
233 append match [lindex $technotelist $i]
234 test "wiki-39-$i" {[string match $match [lindex $technoteartifactlist $i]]}
235 }
236
237 ###############################################################################
238 # Similarly check that wiki pages can have their artifact ids displayed
239 # Note: the tests above have only created a single wiki page, hence the list
240 # should be of length 1 at this point (created by test 1)
241 fossil wiki list
242 set wikilist [split $RESULT "\n"]
243 test wiki-40 {[llength $wikilist] == 1}
244 fossil wiki list --show-artifact-ids
245 set wikiartifactlist [split $RESULT "\n"]
246 test wiki-41 {[llength $wikilist] == [llength $wikiartifactlist]}
247 for {set i 0} {$i < [llength $wikilist]} {incr i} {
248 set match "*"
249 append match [lindex $wikilist $i]
250 test "wiki-42-$i" {[string match $match [lindex $wikiartifactlist $i]]}
251 }
252
253 ###############################################################################
254
255 test_cleanup
256
257

Keyboard Shortcuts

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