Fossil

Check-in [cbda43e7]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment: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.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | technoteattachcli
Files: files | file ages | folders
SHA1:cbda43e71bda52f04c7d5f44c0067340d01542c0
User & Date: dave.vines 2016-04-04 17:30:20
Context
2016-04-12
19:14
add TECHNOTEID to fossil wiki export. Rename --show-artifact-ids to --show-technote-ids on fossil wiki list (and ignore option for wiki pages as the page name uniquely identifies wiki page name). Rename done as tech note ids are not artifact ids (e.g. they cannot be used on fossil artifact) check-in: f486d0f0 user: dave.vines tags: technoteattachcli
2016-04-04
17:30
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. check-in: cbda43e7 user: dave.vines tags: technoteattachcli
2016-04-01
14:47
Remove non tech notes from the list and error checking performed by fossil wiki --technote. Ambiguity of tech note with the same timestamp resolved in favour of the tech note with the highest modification timestamp. check-in: 3d2341a2 user: dave.vines tags: technoteattachcli
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wiki.c.

1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178








1179
1180
1181
1182
1183
1184
1185
....
1317
1318
1319
1320
1321
1322
1323


1324
1325


1326




1327
1328
1329
1330
1331


1332

1333
1334
1335

1336
1337




1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
**         -t|--technote DATETIME      Specifies the timestamp of
**                                     the technote to be created or
**                                     updated.
**         --technote-tags TAGS        The set of tags for a technote.
**         --technote-bgcolor COLOR    The color used for the technote
**                                     on the timeline.
**
**    %fossil wiki list ?--technote?
**    %fossil wiki ls ?--technote?
**
**       Lists all wiki entries, one per line, ordered
**       case-insensitively by name. The --technote flag
**       specifies that technotes will be listed instead of
**       the wiki entries, which will be listed in order
**       timestamp.








**
*/
void wiki_cmd(void){
  int n;
  db_find_and_open_repository(0, 0);
  if( g.argc<3 ){
    goto wiki_cmd_usage;
................................................................................
    if( g.argc!=5 ){
      usage("delete PAGENAME");
    }
    fossil_fatal("delete not yet implemented.");
  }else if(( strncmp(g.argv[2],"list",n)==0 )
          || ( strncmp(g.argv[2],"ls",n)==0 )){
    Stmt q;


    if ( !find_option("technote","t",0) ){
      db_prepare(&q,


        "SELECT substr(tagname, 6) FROM tag WHERE tagname GLOB 'wiki-*'"




        " ORDER BY lower(tagname) /*sort*/"
      );
    }else{
      db_prepare(&q,
        "SELECT datetime(mtime) FROM event WHERE type='e'"


          " AND tagid IS NOT NULL"

        " ORDER BY mtime /*sort*/"
      );
    }

    while( db_step(&q)==SQLITE_ROW ){
      const char *zName = db_column_text(&q, 0);




      fossil_print( "%s\n",zName);
    }
    db_finalize(&q);
  }else{
    goto wiki_cmd_usage;
  }
  return;

wiki_cmd_usage:
  usage("export|create|commit|list ...");
}







|
|


|
|
<
|
>
>
>
>
>
>
>
>







 







>
>


>
>
|
>
>
>
>




|
>
>
|
>
|


>


>
>
>
>











1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176

1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
....
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
**         -t|--technote DATETIME      Specifies the timestamp of
**                                     the technote to be created or
**                                     updated.
**         --technote-tags TAGS        The set of tags for a technote.
**         --technote-bgcolor COLOR    The color used for the technote
**                                     on the timeline.
**
**    %fossil wiki list ?OPTIONS?
**    %fossil wiki ls ?OPTIONS?
**
**       Lists all wiki entries, one per line, ordered
**       case-insensitively by name. 
**

**       Options:
**         --technote                  Technotes will be listed instead of
**                                     pages. The technotes will be in order
**                                     of timestamp with the most recent
**                                     first.
**         --show-artifact-ids         The artifact id of the wiki page or 
**                                     tech note will be listed along side the
**                                     page name or timestamp. The artifact id
**                                     will be the first word on each line.
**
*/
void wiki_cmd(void){
  int n;
  db_find_and_open_repository(0, 0);
  if( g.argc<3 ){
    goto wiki_cmd_usage;
................................................................................
    if( g.argc!=5 ){
      usage("delete PAGENAME");
    }
    fossil_fatal("delete not yet implemented.");
  }else if(( strncmp(g.argv[2],"list",n)==0 )
          || ( strncmp(g.argv[2],"ls",n)==0 )){
    Stmt q;
    int showIds = find_option("show-artifact-ids","s",0)!=0;

    if ( !find_option("technote","t",0) ){
      db_prepare(&q,
        "SELECT substr(t.tagname, 6), b.uuid" 
         " FROM tag t, tagxref x, blob b"
        " WHERE tagname GLOB 'wiki-*'"
          " AND t.tagid=x.tagid AND b.rid=x.rid"
          " AND x.mtime=(SELECT MAX(xx.mtime)"
                         " FROM tagxref xx"
                        " WHERE xx.tagid=x.tagid)"
        " ORDER BY lower(tagname) /*sort*/"
      );
    }else{
      db_prepare(&q,
        "SELECT datetime(e.mtime), substr(t.tagname,7) "
         " FROM event e, tag t"
        " WHERE e.type='e'"
          " AND e.tagid IS NOT NULL"
          " AND t.tagid=e.tagid"
        " ORDER BY e.mtime DESC /*sort*/"
      );
    }
  
    while( db_step(&q)==SQLITE_ROW ){
      const char *zName = db_column_text(&q, 0);
      if (showIds) {
        const char *zUuid = db_column_text(&q, 1);
        fossil_print("%s ",zUuid);
      }
      fossil_print( "%s\n",zName);
    }
    db_finalize(&q);
  }else{
    goto wiki_cmd_usage;
  }
  return;

wiki_cmd_usage:
  usage("export|create|commit|list ...");
}

Changes to test/wiki.test.

215
216
217
218
219
220
221

222




























223
224
225
226
227
test wiki-36-2 {$CODE == 0}

###############################################################################
# Check that we have the expected number of tech notes on the list (and not 
# extra ones from other events (such as the attachments) - 7 tech notes 
# expected created by tests 9, 17, 19, 29, 31, 32 and 34 
fossil wiki list --technote

test wiki-37 {[llength [split $RESULT "\n"]] == 7}





























###############################################################################

test_cleanup








>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>





215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
test wiki-36-2 {$CODE == 0}

###############################################################################
# Check that we have the expected number of tech notes on the list (and not 
# extra ones from other events (such as the attachments) - 7 tech notes 
# expected created by tests 9, 17, 19, 29, 31, 32 and 34 
fossil wiki list --technote
set technotelist [split $RESULT "\n"] 
test wiki-37 {[llength $technotelist] == 7}

###############################################################################
# Check that using the show-artifact-ids shows the same tech notes in the same
# order (with the artifact id as the first word of the line
fossil wiki list --technote --show-artifact-ids
set technoteartifactlist [split $RESULT "\n"]
test wiki-38 {[llength $technoteartifactlist] == 7}
for {set i 0} {$i < [llength $technotelist]} {incr i} {
  set match "*"
  append match [lindex $technotelist $i]
  test "wiki-39-$i" {[string match $match [lindex $technoteartifactlist $i]]} 
}

###############################################################################
# Similarly check that wiki pages can have their artifact ids displayed
# Note: the tests above have only created a single wiki page, hence the list
# should be of length 1 at this point (created by test 1)
fossil wiki list
set wikilist [split $RESULT "\n"]
test wiki-40 {[llength $wikilist] == 1}
fossil wiki list --show-artifact-ids
set wikiartifactlist [split $RESULT "\n"]
test wiki-41 {[llength $wikilist] == [llength $wikiartifactlist]}
for {set i 0} {$i < [llength $wikilist]} {incr i} {
  set match "*"
  append match [lindex $wikilist $i]
  test "wiki-42-$i" {[string match $match [lindex $wikiartifactlist $i]]}
}

###############################################################################

test_cleanup