Fossil

Check-in [6fa5570b]
Login

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

Overview
Comment:Add tests for the mimetype on wiki command. Update help text to list valid mimetypes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | technoteattachcli
Files: files | file ages | folders
SHA1:6fa5570b9a2cc6e6b4e7a5c4ad8dfed1d61d7df1
User & Date: dave.vines 2016-05-06 14:08:11
Context
2016-05-14
00:48
Collected improvements to the fossil wiki and attach commands to support technotes as well as wiki pages, including attachments to either and new test cases. Passes all tests. check-in: 05cd9fa2 user: rberteig tags: trunk
2016-05-06
14:08
Add tests for the mimetype on wiki command. Update help text to list valid mimetypes Closed-Leaf check-in: 6fa5570b user: dave.vines tags: technoteattachcli
2016-05-05
18:26
Fix bug detected by wiki-15 and wiki-15.1. Left hand thought that the mtime column was the timestamp of the tech note. Right hand thought that the mtime column was the last modification time of the tech note. Left hand was right and the relevant query has been updated to use the objid (assigned as the new tech note manifest is added) as the indication of the most recently modified version of the tech note check-in: e9d7c5aa user: dave.vines tags: technoteattachcli
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/wiki.c.

1186
1187
1188
1189
1190
1191
1192




1193
1194
1195
1196
1197
1198
1199
**       technote.
**
**       Options:
**         -M|--mimetype TEXT-FORMAT   The mime type of the update.
**                                     Defaults to the type used by
**                                     the previous version of the
**                                     page, or text/x-fossil-wiki.




**         -t|--technote DATETIME      Specifies the timestamp of
**                                     the technote to be created or
**                                     updated. When updating a tech note
**                                     the most recently modified tech note
**                                     with the specified timestamp will be
**                                     updated.
**         -t|--technote TECHNOTE-ID   Specifies the technote to be







>
>
>
>







1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
**       technote.
**
**       Options:
**         -M|--mimetype TEXT-FORMAT   The mime type of the update.
**                                     Defaults to the type used by
**                                     the previous version of the
**                                     page, or text/x-fossil-wiki.
**                                     Valid values are: text/x-fossil-wiki,
**                                     text/markdown and text/plain. fossil,
**                                     markdown or plain can be specified as
**                                     synonyms of these values.
**         -t|--technote DATETIME      Specifies the timestamp of
**                                     the technote to be created or
**                                     updated. When updating a tech note
**                                     the most recently modified tech note
**                                     with the specified timestamp will be
**                                     updated.
**         -t|--technote TECHNOTE-ID   Specifies the technote to be

Changes to test/wiki.test.

27
28
29
30
31
32
33































34
35
36
37
38
39
40
...
331
332
333
334
335
336
337



























338
339
340
341
  regsub -all { +\n} $x \n x
  regsub -all {\n$} $x {} x
  set y [read_file $b]
  regsub -all { +\n} $y \n y
  regsub -all {\n$} $y {} y
  return [expr {$x==$y}]
}
































###############################################################################
# Initially there should be no wiki entries
fossil wiki list
test wiki-0 {[normalize_result] eq {}}

###############################################################################
................................................................................

###############################################################################
# And we get an error for the ambiguous tech note id
fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
test wiki-47 {$CODE != 0}
fossil attachment add fa --technote $duplicateid -expectError
test wiki-48 {$CODE != 0}




























###############################################################################
test_cleanup








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>




27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
...
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
  regsub -all { +\n} $x \n x
  regsub -all {\n$} $x {} x
  set y [read_file $b]
  regsub -all { +\n} $y \n y
  regsub -all {\n$} $y {} y
  return [expr {$x==$y}]
}

# Return the mime type in the manifest for a given wiki page
# Defaults to "error: some text" if the manifest can't be located and
# "text/x-fossil-wiki" (the default mimetype for rendering)
# if the N card is omitted in the manifest.
# Note: Makes fossil calls, so $CODE and $RESULT will be corrupted
proc get_mime_type {name} {
  global CODE RESULT
  fossil http << "GET /wiki?name=$name"
  if {$CODE != 0} {
    return error: /wiki?name=$name $CODE $RESULT"
  }
  set CODE [regexp {href="/info/([0-9a-f]+)"} $RESULT match info]
  if {$CODE == 0} {
    return "error: No info link found for wiki page $name"
  }
  fossil http << "GET /artifact/$info"
  if {$CODE != 0} {
    return "error: /artifact/$info $CODE $RESULT"
  }
  set CODE [regexp {<pre>(.*)</pre>} $RESULT match pre]
  if {$CODE == 0} {
    return "error: No pre block in /artifact/$info"
  }
  set CODE [regexp -line {^N (.*)$} $pre match mimetype]
  if {$CODE == 0} {
    return "text/x-fossil-wiki"
  }
  return $mimetype
}


###############################################################################
# Initially there should be no wiki entries
fossil wiki list
test wiki-0 {[normalize_result] eq {}}

###############################################################################
................................................................................

###############################################################################
# And we get an error for the ambiguous tech note id
fossil wiki commit {Old tech note} f15 --technote $duplicateid -expectError
test wiki-47 {$CODE != 0}
fossil attachment add fa --technote $duplicateid -expectError
test wiki-48 {$CODE != 0}

###############################################################################
# Check the default mimetype is text/x-fossil-wiki
test wiki-49 {[get_mime_type tcltest] == "text/x-fossil-wiki"}

###############################################################################
# Check long form of the mimetypes are recorded correctly
fossil wiki create tcltest-x-fossil f1 -mimetype text/x-fossil-wiki
test wiki-50 {[get_mime_type tcltest-x-fossil] == "text/x-fossil-wiki"}
fossil wiki create tcltest-x-markdown f1 -mimetype text/x-markdown
test wiki-51 {[get_mime_type tcltest-x-markdown] == "text/x-markdown"}
fossil wiki create tcltest-plain f1 -mimetype text/plain
test wiki-52 {[get_mime_type tcltest-plain] == "text/plain"}
fossil wiki create tcltest-x-random f1 -mimetype text/x-random
test wiki-53 {[get_mime_type tcltest-x-random] == "text/x-fossil-wiki"}

###############################################################################
# Check short form of the mimetypes are recorded correctly
fossil wiki create tcltest-x-fossil-short f1 -mimetype wiki
test wiki-54 {[get_mime_type tcltest-x-fossil-short] == "text/x-fossil-wiki"}
fossil wiki create tcltest-x-markdown-short f1 -mimetype markdown
test wiki-55 {[get_mime_type tcltest-x-markdown-short] == "text/x-markdown"}
fossil wiki create tcltest-plain-short f1 -mimetype plain
test wiki-56 {[get_mime_type tcltest-plain-short] == "text/plain"}
fossil wiki create tcltest-x-random-short f1 -mimetype random
test wiki-57 {[get_mime_type tcltest-x-random-short] == "text/x-fossil-wiki"}


###############################################################################
test_cleanup