|
1
|
# |
|
2
|
# Copyright (c) 2026 Dan Mestas |
|
3
|
# |
|
4
|
# This program is free software; you can redistribute it and/or |
|
5
|
# modify it under the terms of the Simplified BSD License (also |
|
6
|
# known as the "2-Clause License" or "FreeBSD License".) |
|
7
|
# |
|
8
|
# This program is distributed in the hope that it will be useful, |
|
9
|
# but without any warranty; without even the implied warranty of |
|
10
|
# merchantability or fitness for a particular purpose. |
|
11
|
# |
|
12
|
############################################################################ |
|
13
|
# |
|
14
|
# How a name typed by a user or taken from a URL becomes an artifact: |
|
15
|
# src/name.c. One small repository holds check-ins on two branches with |
|
16
|
# a merge between them, tags, a wiki page, a ticket, a technote, a forum |
|
17
|
# post, an attachment, a cluster, phantoms and pairs of artifacts whose |
|
18
|
# hashes begin alike. Every kind of name is then given to |
|
19
|
# "fossil test-name-to-id", "fossil whatis" and other commands, and to |
|
20
|
# web pages through "fossil http --in". |
|
21
|
# |
|
22
|
|
|
23
|
# The first sections run at every level, and the rest need |
|
24
|
# -assurance stress. |
|
25
|
require_no_open_checkout |
|
26
|
|
|
27
|
test_setup "" |
|
28
|
|
|
29
|
set nameRepo [file join [pwd] name.fossil] |
|
30
|
fossil new --admin-user alice --date-override "2025-01-01 00:00:00" $nameRepo |
|
31
|
fossil open $nameRepo |
|
32
|
fossil user default alice |
|
33
|
fossil set mtime-changes off |
|
34
|
|
|
35
|
# The hash of the check-in whose comment is COMMENT. |
|
36
|
# |
|
37
|
proc name_checkin {comment} { |
|
38
|
return [fossil_sql "SELECT uuid FROM event, blob |
|
39
|
WHERE objid=rid AND type='ci' AND comment='$comment'"] |
|
40
|
} |
|
41
|
|
|
42
|
# Check in the checkout as it stands with COMMENT and DATE. ARGS are |
|
43
|
# more options. Return the hash of the check-in. |
|
44
|
# |
|
45
|
proc name_commit {comment date args} { |
|
46
|
fossil commit -m $comment --date-override $date --user-override alice \ |
|
47
|
--no-warnings {*}$args |
|
48
|
return [name_checkin $comment] |
|
49
|
} |
|
50
|
|
|
51
|
set nameSeq 0 |
|
52
|
|
|
53
|
# Store the artifact whose cards, without the Z card, are BODY and |
|
54
|
# crosslink it. Return its hash. |
|
55
|
# |
|
56
|
proc name_put {body} { |
|
57
|
global nameSeq RESULT |
|
58
|
set fn artifact-[incr nameSeq].txt |
|
59
|
set fd [open $fn wb] |
|
60
|
puts -nonewline $fd $body |
|
61
|
close $fd |
|
62
|
fossil md5sum $fn |
|
63
|
set sum [lindex $RESULT 0] |
|
64
|
set fd [open $fn ab] |
|
65
|
puts -nonewline $fd "Z $sum\n" |
|
66
|
close $fd |
|
67
|
fossil test-content-put --crosslink $fn |
|
68
|
file delete $fn |
|
69
|
if {![regexp {inserted as record (\d+)} $RESULT all rid]} { return "" } |
|
70
|
return [fossil_sql "SELECT uuid FROM blob WHERE rid=$rid"] |
|
71
|
} |
|
72
|
|
|
73
|
# The strings in WANTED that TEXT does not hold, and those that begin |
|
74
|
# with "!" that it does hold. |
|
75
|
# |
|
76
|
proc name_missing {text wanted} { |
|
77
|
set missing [list] |
|
78
|
foreach string $wanted { |
|
79
|
if {![holds_strings $text [list $string]]} { lappend missing $string } |
|
80
|
} |
|
81
|
return $missing |
|
82
|
} |
|
83
|
|
|
84
|
# What "fossil test-name-to-id" answers for NAME: a hash, or the text of |
|
85
|
# an error. TYPE is the kind of artifact wanted. |
|
86
|
# |
|
87
|
proc name_id {name {type ""}} { |
|
88
|
global RESULT |
|
89
|
if {$type eq ""} { |
|
90
|
fossil test-name-to-id $name |
|
91
|
} else { |
|
92
|
fossil test-name-to-id --type $type $name |
|
93
|
} |
|
94
|
set at [string first " -> " $RESULT] |
|
95
|
return [string range $RESULT [expr {$at + 4}] end] |
|
96
|
} |
|
97
|
|
|
98
|
############################################################################### |
|
99
|
# The repository. |
|
100
|
# |
|
101
|
# 2025-01-01 c0 first check-in of trunk |
|
102
|
# 2025-01-02 c1 trunk; tags rel, rel1, decade |
|
103
|
# 2025-01-03 c2 trunk |
|
104
|
# 2025-01-04 b1 first check-in of branch br, from c2 |
|
105
|
# 2025-01-05 c3 trunk |
|
106
|
# 2025-01-06 b2 br, with c3 merged in |
|
107
|
# 2025-01-07 b3 br |
|
108
|
# |
|
109
|
# The checkout is left at c2. |
|
110
|
|
|
111
|
set nameC0 [fossil_sql "SELECT uuid FROM event, blob |
|
112
|
WHERE objid=rid AND type='ci'"] |
|
113
|
|
|
114
|
# The hashes of p.txt and q.txt begin with the same five characters. |
|
115
|
write_file f.txt "one\n" |
|
116
|
write_file p.txt "name collide 1177\n" |
|
117
|
write_file q.txt "name collide 1426\n" |
|
118
|
set nameBig "" |
|
119
|
for {set nameI 0} {$nameI < 150} {incr nameI} { |
|
120
|
append nameBig "line $nameI of a file long enough to be kept as a delta\n" |
|
121
|
} |
|
122
|
write_file big.txt $nameBig |
|
123
|
fossil add f.txt p.txt q.txt big.txt |
|
124
|
set nameC1 [name_commit c1 "2025-01-02 10:00:00" --tag rel --tag rel1] |
|
125
|
fossil sha3sum p.txt q.txt |
|
126
|
set nameP [lindex $RESULT 0] |
|
127
|
set nameQ [lindex $RESULT 2] |
|
128
|
set nameTwin [string range $nameP 0 4] |
|
129
|
test name-setup-twins {[string length $nameP] == 64 && $nameP ne $nameQ |
|
130
|
&& [string match $nameTwin* $nameQ]} |
|
131
|
|
|
132
|
write_file f.txt "one\ntwo\n" |
|
133
|
write_file big.txt "${nameBig}one more line\n" |
|
134
|
set nameC2 [name_commit c2 "2025-01-03 10:00:00"] |
|
135
|
write_file f.txt "one\ntwo\nbranch\n" |
|
136
|
set nameB1 [name_commit b1 "2025-01-04 10:00:00" --branch br] |
|
137
|
fossil update trunk |
|
138
|
write_file g.txt "g\n" |
|
139
|
fossil add g.txt |
|
140
|
set nameC3 [name_commit c3 "2025-01-05 10:00:00"] |
|
141
|
fossil update br |
|
142
|
fossil merge trunk |
|
143
|
set nameB2 [name_commit b2 "2025-01-06 10:00:00"] |
|
144
|
write_file f.txt "one\ntwo\nbranch\nmore\n" |
|
145
|
set nameB3 [name_commit b3 "2025-01-07 10:00:00"] |
|
146
|
|
|
147
|
# A private check-in after b3 that is dated before it. |
|
148
|
write_file h.txt "private\n" |
|
149
|
fossil add h.txt |
|
150
|
set namePriv [name_commit hidden "2025-01-07 09:00:00" --private \ |
|
151
|
--allow-older] |
|
152
|
fossil update $nameC2 |
|
153
|
fossil tag add decade $nameC1 --date-override "2025-01-08 10:00:00" \ |
|
154
|
--user-override alice |
|
155
|
fossil tag add gone $nameC1 --date-override "2025-01-08 11:00:00" \ |
|
156
|
--user-override alice |
|
157
|
fossil tag cancel gone $nameC1 --date-override "2025-01-08 12:00:00" \ |
|
158
|
--user-override alice |
|
159
|
set nameG1 [fossil_sql "SELECT uuid FROM event, blob |
|
160
|
WHERE objid=rid AND type='g' AND comment LIKE '%\"decade\"%'"] |
|
161
|
|
|
162
|
test name-setup-checkins {[llength [lsort -unique [list $nameC0 $nameC1 \ |
|
163
|
$nameC2 $nameC3 $nameB1 $nameB2 $nameB3 $nameG1]]] == 8 |
|
164
|
&& [string length $nameG1] == 64} |
|
165
|
|
|
166
|
# A wiki page with two versions, then two versions of another page |
|
167
|
# whose hashes begin with the same four characters. |
|
168
|
set nameW1 [name_put "D 2025-01-09T10:00:00.000 |
|
169
|
L WikiOne |
|
170
|
U alice |
|
171
|
W 5 |
|
172
|
first |
|
173
|
"] |
|
174
|
set nameW2 [name_put "D 2025-01-09T11:00:00.000 |
|
175
|
L WikiOne |
|
176
|
P $nameW1 |
|
177
|
U alice |
|
178
|
W 6 |
|
179
|
second |
|
180
|
"] |
|
181
|
set nameWa [name_put "D 2025-01-09T10:00:00.130 |
|
182
|
L Twin |
|
183
|
U alice |
|
184
|
W 4 |
|
185
|
twin |
|
186
|
"] |
|
187
|
set nameWb [name_put "D 2025-01-09T10:00:00.414 |
|
188
|
L Twin |
|
189
|
U alice |
|
190
|
W 4 |
|
191
|
twin |
|
192
|
"] |
|
193
|
set nameWtwin [string range $nameWa 0 3] |
|
194
|
test name-setup-wiki-twins {$nameWa ne "" && $nameWa ne $nameWb |
|
195
|
&& [string match $nameWtwin* $nameWb]} |
|
196
|
|
|
197
|
# A ticket whose name begins like the hash of c1, and one whose name |
|
198
|
# begins like nothing else. |
|
199
|
set nameTktLike [string range $nameC1 0 5][string repeat 0 34] |
|
200
|
set nameTktOnly [string repeat 7e 20] |
|
201
|
set nameT1 [name_put "D 2025-01-10T10:00:00.000 |
|
202
|
J status Open |
|
203
|
J title Like\\sa\\scheck-in |
|
204
|
K $nameTktLike |
|
205
|
U alice |
|
206
|
"] |
|
207
|
set nameT2 [name_put "D 2025-01-10T11:00:00.000 |
|
208
|
J status Open |
|
209
|
J title Alone |
|
210
|
K $nameTktOnly |
|
211
|
U alice |
|
212
|
"] |
|
213
|
|
|
214
|
# A technote, and a second one whose name begins like the hash of c3. |
|
215
|
set nameEid [string repeat e1 20] |
|
216
|
set nameEidLike [string range $nameC3 0 5][string repeat 1 34] |
|
217
|
set nameE1 [name_put "C A\\snote |
|
218
|
D 2025-01-11T10:00:00.000 |
|
219
|
E 2025-01-11T09:00:00 $nameEid |
|
220
|
U alice |
|
221
|
W 4 |
|
222
|
note |
|
223
|
"] |
|
224
|
set nameE2 [name_put "C Like\\sa\\scheck-in |
|
225
|
D 2025-01-11T11:00:00.000 |
|
226
|
E 2025-01-11T09:30:00 $nameEidLike |
|
227
|
U alice |
|
228
|
W 4 |
|
229
|
note |
|
230
|
"] |
|
231
|
|
|
232
|
# A forum post. |
|
233
|
set nameF1 [name_put "D 2025-01-12T10:00:00.000 |
|
234
|
H A\\sthread |
|
235
|
U alice |
|
236
|
W 4 |
|
237
|
post |
|
238
|
"] |
|
239
|
|
|
240
|
# A file attached to the wiki page and another attached to a ticket. |
|
241
|
write_file att1.txt "attached to wiki\n" |
|
242
|
write_file att2.txt "attached to ticket\n" |
|
243
|
fossil test-content-put att1.txt |
|
244
|
fossil test-content-put att2.txt |
|
245
|
fossil sha3sum att1.txt att2.txt |
|
246
|
set nameAtt1 [lindex $RESULT 0] |
|
247
|
set nameAtt2 [lindex $RESULT 2] |
|
248
|
set nameA1 [name_put "A att1.txt WikiOne $nameAtt1 |
|
249
|
C on\\sthe\\spage |
|
250
|
D 2025-01-13T10:00:00.000 |
|
251
|
U alice |
|
252
|
"] |
|
253
|
set nameA2 [name_put "A att2.txt $nameTktOnly $nameAtt2 |
|
254
|
C on\\sthe\\sticket |
|
255
|
D 2025-01-13T11:00:00.000 |
|
256
|
U alice |
|
257
|
"] |
|
258
|
|
|
259
|
# An artifact kept under its SHA1 name. |
|
260
|
write_file sha1.txt "kept under a SHA1 name\n" |
|
261
|
fossil hash-policy sha1 |
|
262
|
fossil test-content-put sha1.txt |
|
263
|
fossil hash-policy sha3 |
|
264
|
fossil sha1sum sha1.txt |
|
265
|
set nameSha1 [lindex $RESULT 0] |
|
266
|
|
|
267
|
# A ticket with the same name as that artifact. |
|
268
|
set nameT3 [name_put "D 2025-01-10T12:00:00.000 |
|
269
|
J status Open |
|
270
|
J title Same\\sname |
|
271
|
K $nameSha1 |
|
272
|
U alice |
|
273
|
"] |
|
274
|
|
|
275
|
# Artifacts that name others the repository does not hold: the parent |
|
276
|
# of a wiki edit, a file and a merge parent of a check-in on branch |
|
277
|
# side, the target of a tag, and a member of a cluster. The first of |
|
278
|
# them has a name that reads as the date 2025-01-05. |
|
279
|
set nameGhostParent 20250105[string repeat a 32] |
|
280
|
set nameGhostFile [string repeat f1 20] |
|
281
|
set nameGhostMerge [string repeat f2 20] |
|
282
|
set nameGhostTarget [string repeat f3 20] |
|
283
|
set nameGhostMember [string repeat f4 20] |
|
284
|
set nameW3 [name_put "D 2025-01-14T10:00:00.000 |
|
285
|
L Orphan |
|
286
|
P $nameGhostParent |
|
287
|
U alice |
|
288
|
W 6 |
|
289
|
orphan |
|
290
|
"] |
|
291
|
set nameSide [name_put "C side |
|
292
|
D 2025-01-06T12:00:00.000 |
|
293
|
F lost.txt $nameGhostFile |
|
294
|
P $nameC0 $nameGhostMerge |
|
295
|
T *branch * side |
|
296
|
T *sym-side * |
|
297
|
T -sym-trunk * |
|
298
|
U alice |
|
299
|
"] |
|
300
|
# Two check-ins whose hashes begin with the same four characters. |
|
301
|
set nameCa [name_put "C twin |
|
302
|
D 2025-01-06T13:00:00.324 |
|
303
|
T *branch * twins |
|
304
|
T *sym-twins * |
|
305
|
U alice |
|
306
|
"] |
|
307
|
set nameCb [name_put "C twin |
|
308
|
D 2025-01-06T13:00:00.401 |
|
309
|
T *branch * twins |
|
310
|
T *sym-twins * |
|
311
|
U alice |
|
312
|
"] |
|
313
|
set nameCtwin [string range $nameCa 0 3] |
|
314
|
fossil tag add --raw closed $nameCa --date-override "2025-01-08 08:00:00" \ |
|
315
|
--user-override alice |
|
316
|
fossil tag add --raw hidden $nameCa --date-override "2025-01-08 09:00:00" \ |
|
317
|
--user-override alice |
|
318
|
test name-setup-checkin-twins {$nameCa ne "" && $nameCa ne $nameCb |
|
319
|
&& [string match $nameCtwin* $nameCb]} |
|
320
|
set nameG2 [name_put "D 2025-01-14T11:00:00.000 |
|
321
|
T +sym-ghost $nameGhostTarget |
|
322
|
U alice |
|
323
|
"] |
|
324
|
set nameCluster [name_put "M [join [lsort [list $nameC0 $nameC1 \ |
|
325
|
$nameGhostMember]] "\nM "]\n"] |
|
326
|
|
|
327
|
test name-setup-more {[llength [lsort -unique [list $namePriv $nameA1 \ |
|
328
|
$nameA2 $nameW3 $nameSide $nameG2 $nameCluster $nameAtt1 $nameAtt2]]] == 9 |
|
329
|
&& [string length $nameCluster] == 64 && [string length $nameSha1] == 40 |
|
330
|
&& [fossil_sql "SELECT count(*) FROM phantom"] == 5 |
|
331
|
&& [fossil_sql "SELECT count(*) FROM delta"] > 0 |
|
332
|
&& [fossil_sql "SELECT count(*) FROM blob WHERE uuid='$nameSha1'"] == 1} |
|
333
|
|
|
334
|
test name-setup-artifacts {[llength [lsort -unique [list $nameW1 $nameW2 \ |
|
335
|
$nameT1 $nameT2 $nameE1 $nameE2 $nameF1]]] == 7 |
|
336
|
&& [string length $nameF1] == 64} |
|
337
|
|
|
338
|
############################################################################### |
|
339
|
# Names of check-ins, given in the checkout. |
|
340
|
|
|
341
|
foreach {nameCase nameName nameType nameWant} [list \ |
|
342
|
tip tip {} $nameB3 \ |
|
343
|
tip-ci tip ci $nameB3 \ |
|
344
|
tip-wiki tip w {ERROR: cannot resolve name: tip} \ |
|
345
|
current current {} $nameC2 \ |
|
346
|
prev prev {} $nameC1 \ |
|
347
|
previous previous ci $nameC1 \ |
|
348
|
next next {} $nameC3 \ |
|
349
|
current-wiki current w \ |
|
350
|
{ERROR: cannot resolve name: current} \ |
|
351
|
ckout ckout ci+ $nameC2 \ |
|
352
|
ckout-ci ckout ci {ERROR: cannot resolve name: ckout} \ |
|
353
|
ckout-any ckout {} {ERROR: cannot resolve name: ckout} \ |
|
354
|
current-ciplus current ci+ $nameC2 \ |
|
355
|
trunk-ciplus trunk ci+ $nameC3 \ |
|
356
|
branch br {} $nameB3 \ |
|
357
|
branch-start br br $nameB1 \ |
|
358
|
trunk trunk ci $nameC3 \ |
|
359
|
tag rel1 {} $nameC1 \ |
|
360
|
tag-prefix tag:rel1 {} $nameC1 \ |
|
361
|
tag-hex decade {} $nameC1 \ |
|
362
|
tag-hex-prefix tag:decade {} $nameC1 \ |
|
363
|
tag-start tag:br br $nameB1 \ |
|
364
|
tag-cancelled gone {} {ERROR: cannot resolve name: gone} \ |
|
365
|
tag-none tag:nosuch {} \ |
|
366
|
{ERROR: cannot resolve name: tag:nosuch} \ |
|
367
|
tag-empty tag: {} {ERROR: cannot resolve name: tag:} \ |
|
368
|
tag-percent tag:% {} {ERROR: cannot resolve name: tag:%} \ |
|
369
|
tag-underscore re_1 {} {ERROR: cannot resolve name: re_1} \ |
|
370
|
tag-star rel* {} {ERROR: cannot resolve name: rel*} \ |
|
371
|
tag-wiki-type rel1 w {ERROR: cannot resolve name: rel1} \ |
|
372
|
root root:br {} $nameC2 \ |
|
373
|
start start:br {} $nameB1 \ |
|
374
|
merge-in merge-in:br {} $nameC3 \ |
|
375
|
root-trunk root:trunk {} $nameC0 \ |
|
376
|
start-trunk start:trunk {} $nameC0 \ |
|
377
|
merge-in-trunk merge-in:trunk {} $nameC3 \ |
|
378
|
root-first root:$nameC0 {} $nameC0 \ |
|
379
|
merge-in-first merge-in:$nameC0 {} $nameC0 \ |
|
380
|
merge-in-plain merge-in:$nameB1 {} $nameC2 \ |
|
381
|
root-of-root root:root:br {} $nameC0 \ |
|
382
|
root-none root:nosuch {} \ |
|
383
|
{ERROR: cannot resolve name: root:nosuch} \ |
|
384
|
start-none start:nosuch {} \ |
|
385
|
{ERROR: cannot resolve name: start:nosuch} \ |
|
386
|
merge-in-none merge-in:nosuch {} \ |
|
387
|
{ERROR: cannot resolve name: merge-in:nosuch} \ |
|
388
|
root-empty root: {} {ERROR: cannot resolve name: root:} \ |
|
389
|
] { |
|
390
|
test_eq name-checkin-$nameCase [name_id $nameName $nameType] $nameWant |
|
391
|
} |
|
392
|
|
|
393
|
if {[test_assurance] ne "stress"} { |
|
394
|
test_skip "the tests after the first sections need -assurance stress" |
|
395
|
} |
|
396
|
|
|
397
|
############################################################################### |
|
398
|
# Dates. The timeline of the repository is in UTC. A date names the |
|
399
|
# latest artifact of the wanted kind at or before the end of the day, |
|
400
|
# minute, second or millisecond given. |
|
401
|
|
|
402
|
set nameNoDate {ERROR: cannot resolve name: } |
|
403
|
foreach {nameCase nameName nameType nameWant} [list \ |
|
404
|
day {date:2025-01-03} {} $nameC2 \ |
|
405
|
day-ci {date:2025-01-03} ci $nameC2 \ |
|
406
|
day-wiki {date:2025-01-03} w - \ |
|
407
|
day-wiki-later {date:2025-01-09} w $nameW2 \ |
|
408
|
compact-day {date:20250103} {} $nameC2 \ |
|
409
|
compact-minute {date:202501031000} {} $nameC2 \ |
|
410
|
compact-second {date:20250103095959} {} $nameC1 \ |
|
411
|
compact-second-2 {date:20250103100000} {} $nameC2 \ |
|
412
|
compact-zulu-day {date:20250103Z} {} $nameC2 \ |
|
413
|
compact-zulu-min {date:202501031000z} {} $nameC2 \ |
|
414
|
compact-zulu-sec {date:20250103095959Z} {} $nameC1 \ |
|
415
|
minute {date:2025-01-03T09:59} {} $nameC1 \ |
|
416
|
minute-2 {date:2025-01-03 10:00} {} $nameC2 \ |
|
417
|
second {date:2025-01-03 09:59:59} {} $nameC1 \ |
|
418
|
second-2 {date:2025-01-03 10:00:00} {} $nameC2 \ |
|
419
|
tenth {date:2025-01-03 09:59:59.9} {} $nameC1 \ |
|
420
|
hundredth {date:2025-01-03 09:59:59.99} {} $nameC1 \ |
|
421
|
milli-998 {date:2025-01-03 09:59:59.998} {} $nameC1 \ |
|
422
|
milli-989 {date:2025-01-03 09:59:59.989} {} $nameC1 \ |
|
423
|
milli-899 {date:2025-01-03 09:59:59.899} {} $nameC1 \ |
|
424
|
milli-999 {date:2025-01-03 09:59:59.999} {} $nameC1 \ |
|
425
|
milli-000 {date:2025-01-03 10:00:00.000} {} $nameC2 \ |
|
426
|
zulu-day {date:2025-01-03z} {} $nameC2 \ |
|
427
|
zulu-minute {date:2025-01-03 10:00Z} {} $nameC2 \ |
|
428
|
zulu-second {date:2025-01-03 09:59:59Z} {} $nameC1 \ |
|
429
|
zulu-milli {date:2025-01-03 10:00:00.000z} {} $nameC2 \ |
|
430
|
zulu-short {date:2025-01-0z} {} - \ |
|
431
|
before-all {date:2024-12-31} {} - \ |
|
432
|
empty {date:} {} - \ |
|
433
|
zero {date:0000-00-00} {} - \ |
|
434
|
negative {date:-1} {} - \ |
|
435
|
year-99999 {date:99999-01-01} {} - \ |
|
436
|
words {date:yesterday} {} - \ |
|
437
|
plain-day {2025-01-03} {} $nameC2 \ |
|
438
|
plain-minute {2025-01-03 09:00} {} $nameC1 \ |
|
439
|
plain-wiki {2025-01-09} w $nameW2 \ |
|
440
|
plain-before-all {2024-12-31} {} - \ |
|
441
|
plain-zero {0000-00-00} {} - \ |
|
442
|
plain-month-13 {2025-13-01} {} - \ |
|
443
|
not-date-5 {2025-x1-01} {} - \ |
|
444
|
not-date-6 {2025-0x-01} {} - \ |
|
445
|
not-date-7 {2025-01x01} {} - \ |
|
446
|
not-date-8 {2025-01-x1} {} - \ |
|
447
|
not-date-9 {2025-01-0x} {} - \ |
|
448
|
local {local:2025-01-03 23:00} {} $nameC2 \ |
|
449
|
local-none {local:} {} - \ |
|
450
|
utc {utc:2025-01-03 10:00} {} $nameC2 \ |
|
451
|
utc-day {utc:2025-01-02} {} $nameC1 \ |
|
452
|
utc-none {utc:%} {} - \ |
|
453
|
number-day {20250103} {} $nameC2 \ |
|
454
|
number-minute {202501031000} {} $nameC2 \ |
|
455
|
number-second {20250103095959} {} $nameC1 \ |
|
456
|
number-ci {20250109} ci $nameB3 \ |
|
457
|
number-wiki {20250103} w - \ |
|
458
|
number-10-digits {2025010310} {} - \ |
|
459
|
number-not-digit {2025010x} {} - \ |
|
460
|
number-zulu-bad {2025010xZ} {} - \ |
|
461
|
number-year-1969 {19691231} {} - \ |
|
462
|
number-year-2101 {21010101} {} - \ |
|
463
|
number-month-0 {20250003} {} - \ |
|
464
|
number-month-13 {20251303} {} - \ |
|
465
|
number-day-0 {20250100} {} - \ |
|
466
|
number-day-32 {20250132} {} - \ |
|
467
|
number-hour-25 {202501032500} {} - \ |
|
468
|
number-minute-61 {202501031061} {} - \ |
|
469
|
number-second-61 {20250103100061} {} - \ |
|
470
|
tag-day {trunk:2025-01-04} {} $nameC2 \ |
|
471
|
tag-day-branch {br:2025-01-05} {} $nameB1 \ |
|
472
|
tag-day-early {br:2025-01-03} {} - \ |
|
473
|
tag-compact {trunk:20250104} {} $nameC2 \ |
|
474
|
tag-minute {trunk:2025-01-03 09:59} {} $nameC1 \ |
|
475
|
tag-utc {trunk:2025-01-04 12:00utc} {} $nameC2 \ |
|
476
|
tag-UTC {trunk:2025-01-02 12:00UTC} {} $nameC1 \ |
|
477
|
tag-day-wiki {trunk:2025-01-04} w - \ |
|
478
|
tag-none {nosuch:2025-01-04} {} - \ |
|
479
|
tag-empty {:2025-01-04} {} - \ |
|
480
|
tag-not-date {trunk:2025} {} - \ |
|
481
|
tag-colon-only {:} {} - \ |
|
482
|
tag-two-colons {::} {} - \ |
|
483
|
] { |
|
484
|
if {$nameWant eq "-"} { set nameWant $nameNoDate$nameName } |
|
485
|
test_eq name-date-$nameCase [name_id $nameName $nameType] $nameWant |
|
486
|
} |
|
487
|
|
|
488
|
############################################################################### |
|
489
|
# Hashes and their beginnings, tags that look like hashes, record |
|
490
|
# numbers, and names with punctuation after them. |
|
491
|
|
|
492
|
set nameC1x [string range $nameC1 0 9] |
|
493
|
set nameTwice {ERROR: ambiguous name: } |
|
494
|
foreach {nameCase nameName nameType nameWant} [list \ |
|
495
|
full $nameC1 {} $nameC1 \ |
|
496
|
prefix $nameC1x {} $nameC1 \ |
|
497
|
upper [string toupper $nameC1x] {} $nameC1 \ |
|
498
|
prefix-ci $nameC1x ci $nameC1 \ |
|
499
|
prefix-wiki $nameC1x w - \ |
|
500
|
brackets "\[$nameC1x\]" {} $nameC1 \ |
|
501
|
bracket-left "\[$nameC1x" {} $nameC1 \ |
|
502
|
bracket-right "$nameC1x\]" {} $nameC1 \ |
|
503
|
bracket-alone "\[" {} - \ |
|
504
|
bracket-pair "\[\]" {} - \ |
|
505
|
three [string range $nameC1 0 2] {} - \ |
|
506
|
too-long ${nameC1}0 {} - \ |
|
507
|
not-hex [string range $nameC1 0 8]g {} - \ |
|
508
|
unknown [string repeat 5a 5] {} - \ |
|
509
|
twins $nameTwin {} = \ |
|
510
|
twins-ci $nameTwin ci - \ |
|
511
|
twin-longer [string range $nameP 0 5] {} $nameP \ |
|
512
|
wiki-twins $nameWtwin w = \ |
|
513
|
wiki [string range $nameW1 0 9] w $nameW1 \ |
|
514
|
wiki-page WikiOne w $nameW2 \ |
|
515
|
wiki-page-none NoPage w - \ |
|
516
|
wiki-page-any WikiOne {} - \ |
|
517
|
ticket [string range $nameT1 0 9] t $nameT1 \ |
|
518
|
technote [string range $nameE1 0 9] e $nameE1 \ |
|
519
|
forum [string range $nameF1 0 9] f $nameF1 \ |
|
520
|
tag-change [string range $nameG1 0 9] g $nameG1 \ |
|
521
|
tag-change-ci [string range $nameG1 0 9] ci - \ |
|
522
|
type-cx $nameC1x cx - \ |
|
523
|
tip-type-cx tip cx - \ |
|
524
|
rid rid:1 {} $nameC0 \ |
|
525
|
rid-ci rid:1 ci $nameC0 \ |
|
526
|
rid-wiki rid:1 w - \ |
|
527
|
rid-not-number rid:1x {} - \ |
|
528
|
rid-empty rid: {} - \ |
|
529
|
rid-zero rid:0 {} - \ |
|
530
|
dot rel1. {} $nameC1 \ |
|
531
|
underscore rel1_ {} $nameC1 \ |
|
532
|
paren rel1) {} $nameC1 \ |
|
533
|
greater rel1> {} $nameC1 \ |
|
534
|
bang rel1! {} $nameC1 \ |
|
535
|
question rel1? {} $nameC1 \ |
|
536
|
comma rel1, {} $nameC1 \ |
|
537
|
two-marks rel1.) {} $nameC1 \ |
|
538
|
three-marks rel1... {} - \ |
|
539
|
mark-short rel. {} - \ |
|
540
|
two-marks-short rel.. {} - \ |
|
541
|
mark-inside rel1.x {} - \ |
|
542
|
hash-and-mark $nameC1x. {} $nameC1 \ |
|
543
|
semicolon {rel1;} {} - \ |
|
544
|
empty {} {} - \ |
|
545
|
dash - {} - \ |
|
546
|
long [string repeat x 5000] {} - \ |
|
547
|
long-colons [string repeat : 5000] {} - \ |
|
548
|
long-date date:[string repeat 9 5000] {} - \ |
|
549
|
] { |
|
550
|
if {$nameWant eq "-"} { set nameWant $nameNoDate$nameName } |
|
551
|
if {$nameWant eq "="} { set nameWant $nameTwice$nameName } |
|
552
|
test_eq name-hash-$nameCase [name_id $nameName $nameType] $nameWant |
|
553
|
} |
|
554
|
|
|
555
|
############################################################################### |
|
556
|
# "fossil whatis". |
|
557
|
|
|
558
|
# Test NAME passes if the output of "fossil whatis ARGS" holds every |
|
559
|
# string in WANTED and none of those that begin with "!". |
|
560
|
# |
|
561
|
proc name_whatis {name wanted args} { |
|
562
|
global RESULT |
|
563
|
fossil whatis {*}$args |
|
564
|
test_eq name-whatis-$name [name_missing $RESULT $wanted] {} |
|
565
|
} |
|
566
|
|
|
567
|
fossil whatis tip |
|
568
|
test_eq name-whatis-checkin $RESULT "name: tip |
|
569
|
artifact: $nameB3 |
|
570
|
size: [fossil_sql "SELECT size FROM blob WHERE uuid='$nameB3'"] bytes |
|
571
|
tags: br |
|
572
|
type: Check-in by alice on 2025-01-07 10:00:00 |
|
573
|
comment: b3" |
|
574
|
fossil whatis -h tip |
|
575
|
test_eq name-whatis-hash-only $RESULT $nameB3 |
|
576
|
fossil whatis -v -h tip |
|
577
|
test_eq name-whatis-hash-only-verbose $RESULT $nameB3 |
|
578
|
|
|
579
|
set nameRidC1 [fossil_sql "SELECT rid FROM blob WHERE uuid='$nameC1'"] |
|
580
|
name_whatis verbose [list "artifact: $nameC1 ($nameRidC1)" \ |
|
581
|
"received: " "tags: decade, rel, rel1, trunk"] -v rel1 |
|
582
|
name_whatis raw-tags [list "tags: twins" "closed, hidden" \ |
|
583
|
"Check-in by alice on 2025-01-06 13:00:00"] $nameCa |
|
584
|
name_whatis private [list "tags: private" "comment: hidden"] $namePriv |
|
585
|
name_whatis wiki [list "artifact: $nameW2" \ |
|
586
|
"type: Wiki-edit by alice on 2025-01-09 11:00:00"] --type w WikiOne |
|
587
|
name_whatis wiki-any-type [list "unknown: WikiOne"] WikiOne |
|
588
|
name_whatis technote [list "type: Technote by alice on"] $nameE1 |
|
589
|
name_whatis forum [list "type: Forum-post by alice on"] $nameF1 |
|
590
|
name_whatis tag-change [list "type: Tag-change by alice on"] $nameG1 |
|
591
|
name_whatis ticket-change [list "type: Ticket-change by alice on" \ |
|
592
|
"ticket-id: $nameTktLike"] $nameT1 |
|
593
|
name_whatis file [list "file: p.txt" \ |
|
594
|
"part of \[[string range $nameC1 0 9]\] on branch trunk by alice on"] $nameP |
|
595
|
name_whatis file-on-branch [list "file: f.txt" "on branch br by alice" \ |
|
596
|
"!on branch trunk"] [fossil_sql "SELECT uuid FROM blob, mlink |
|
597
|
WHERE rid=fid AND mid=(SELECT rid FROM blob WHERE uuid='$nameB1')"] |
|
598
|
name_whatis attachment-wiki [list "attachment: att1.txt" \ |
|
599
|
"attached to wiki WikiOne" "via $nameA1\n" \ |
|
600
|
"by user alice on 2025-01-13 10:00:00" "on the page"] $nameAtt1 |
|
601
|
name_whatis attachment-ticket [list "attachment: att2.txt" \ |
|
602
|
"attached to ticket $nameTktOnly" \ |
|
603
|
"via $nameA2 ([fossil_sql "SELECT rid FROM blob WHERE uuid='$nameA2'"])"] \ |
|
604
|
-v $nameAtt2 |
|
605
|
name_whatis cluster [list "artifact: $nameCluster" "cluster"] $nameCluster |
|
606
|
name_whatis sha1-name [list "hash: $nameSha1 (ambiguous)" \ |
|
607
|
"artifact: $nameSha1" "artifact: $nameT3"] $nameSha1 |
|
608
|
|
|
609
|
# An artifact the repository does not hold is described by what names it. |
|
610
|
name_whatis phantom-parent [list "phantom: parent of check-in" \ |
|
611
|
"!artifact:"] $nameGhostParent |
|
612
|
name_whatis phantom-merge [list "phantom: merge parent of check-in\ |
|
613
|
[string range $nameSide 0 15]"] $nameGhostMerge |
|
614
|
name_whatis phantom-file [list "file: lost.txt" "on branch side"] \ |
|
615
|
$nameGhostFile |
|
616
|
name_whatis phantom-target [list "tags: ghost" \ |
|
617
|
"phantom: check-in referenced by \"sym-ghost\" tag\ |
|
618
|
[string range $nameG2 0 15]"] $nameGhostTarget |
|
619
|
name_whatis phantom-member [list "phantom: referenced by cluster\ |
|
620
|
[string range $nameCluster 0 15]"] $nameGhostMember |
|
621
|
|
|
622
|
# Names that fit nothing, or more than one artifact. |
|
623
|
fossil whatis nosuch |
|
624
|
test_eq name-whatis-unknown $RESULT "unknown: nosuch" |
|
625
|
fossil whatis -q nosuch |
|
626
|
test_eq name-whatis-unknown-quiet $RESULT "" |
|
627
|
fossil whatis -h nosuch |
|
628
|
test_eq name-whatis-unknown-hash-only $RESULT "" |
|
629
|
name_whatis quiet [list "repository: $nameRepo" "name: tip"] -q tip |
|
630
|
name_whatis twins [list "hash: $nameTwin (ambiguous)" \ |
|
631
|
"artifact: $nameP" "---- meaning #2 ----" "artifact: $nameQ" \ |
|
632
|
"file: p.txt" "file: q.txt" "!repository:"] $nameTwin |
|
633
|
name_whatis twins-quiet [list "repository: $nameRepo" "(ambiguous)"] \ |
|
634
|
-q $nameTwin |
|
635
|
name_whatis twins-hash-only [list $nameP $nameQ "!size:"] -h $nameTwin |
|
636
|
name_whatis twins-wiki [list "(ambiguous)" $nameWa $nameWb] \ |
|
637
|
--type w $nameWtwin |
|
638
|
name_whatis two-names [list "name: tip" [string repeat - 79] \ |
|
639
|
"name: rel1" "comment: c1"] tip rel1 |
|
640
|
|
|
641
|
# A ticket is found by the beginning of its name. When that is also |
|
642
|
# the beginning of a hash, both are shown. |
|
643
|
name_whatis ticket-name [list "artifact: $nameT2" \ |
|
644
|
"ticket-id: $nameTktOnly"] [string range $nameTktOnly 0 7] |
|
645
|
name_whatis ticket-name-upper [list "artifact: $nameT2"] \ |
|
646
|
[string toupper [string range $nameTktOnly 0 7]] |
|
647
|
name_whatis ticket-and-hash [list "(ambiguous)" "artifact: $nameC1" \ |
|
648
|
"artifact: $nameT1" "---- meaning"] [string range $nameC1 0 5] |
|
649
|
name_whatis three-characters [list "unknown: [string range $nameC1 0 2]"] \ |
|
650
|
[string range $nameC1 0 2] |
|
651
|
|
|
652
|
# The file named, not the artifact named. |
|
653
|
name_whatis by-file [list "name: f.txt" "file: f.txt" \ |
|
654
|
"on branch trunk"] -f f.txt |
|
655
|
name_whatis by-file-unknown [list "name: name.fossil" "unknown: "] \ |
|
656
|
-f name.fossil |
|
657
|
name_whatis by-file-sha1 [list \ |
|
658
|
"name: sha1.txt\nhash: $nameSha1 (ambiguous)" \ |
|
659
|
"artifact: $nameSha1" "artifact: $nameT3"] -f sha1.txt |
|
660
|
name_whatis by-file-twin [list "name: p.txt" "artifact: $nameP" \ |
|
661
|
"!ambiguous"] -f p.txt |
|
662
|
fossil whatis -f nosuchfile -expectError |
|
663
|
test name-whatis-by-file-missing {[string match "*no such file*" $RESULT]} |
|
664
|
fossil whatis -expectError |
|
665
|
test name-whatis-usage {[string match "*Usage:*whatis NAME*" $RESULT]} |
|
666
|
|
|
667
|
# Outside a checkout the names "current", "prev" and "next" mean nothing. |
|
668
|
cd .. |
|
669
|
fossil whatis -R $nameRepo current prev next ckout tip |
|
670
|
test name-whatis-no-checkout {[holds_strings $RESULT [list \ |
|
671
|
"unknown: current" "unknown: prev" "unknown: next" \ |
|
672
|
"unknown: ckout" "artifact: $nameB3"]]} |
|
673
|
|
|
674
|
# A repository with no check-in has no tip. |
|
675
|
file copy $nameRepo noci.fossil |
|
676
|
fossil sql -R noci.fossil "DELETE FROM event WHERE type='ci'" |
|
677
|
fossil whatis -R noci.fossil tip |
|
678
|
test_eq name-whatis-no-tip $RESULT "unknown: tip" |
|
679
|
file delete noci.fossil |
|
680
|
cd [file dirname $nameRepo] |
|
681
|
|
|
682
|
# The same as JSON, from the command and from the SQL function. |
|
683
|
foreach {nameCase nameArgs nameWant} [list \ |
|
684
|
checkin [list tip] \ |
|
685
|
[list "\{\"rid\":" "\"artifact\":\"$nameB3\"" \ |
|
686
|
"\"type\":\"Check-in by alice on 2025-01-07 10:00:00\"" \ |
|
687
|
"\"comment\":\"b3\"\}"] \ |
|
688
|
raw-tags [list $nameCa] \ |
|
689
|
[list "\[\"twins\"\]" "\"raw-tags\":\[\"closed\",\"hidden\"\]"] \ |
|
690
|
many-tags [list rel1] \ |
|
691
|
[list "\[\"decade\",\"rel\",\"rel1\",\"trunk\"\]"] \ |
|
692
|
file [list $nameP] \ |
|
693
|
[list "\"file\":\"p.txt\",\"part-of\":\"$nameC1\"\}"] \ |
|
694
|
ticket [list $nameT1] \ |
|
695
|
[list "\"ticket-id\":\"$nameTktLike\""] \ |
|
696
|
attachment [list $nameAtt1] \ |
|
697
|
[list "\"attachment\":\"att1.txt\",\"attached-to\":\"wiki WikiOne\"\}"] \ |
|
698
|
unknown [list nosuch] \ |
|
699
|
[list "\{\"unknown\":\"nosuch\"\}"] \ |
|
700
|
twins [list $nameTwin] \ |
|
701
|
[list "\{\"ambiguous\":\[\{\"rid\":" "\},\{\"rid\":" \ |
|
702
|
"\"artifact\":\"$nameQ\"" "\"file\":\"p.txt\"" "\}\]\}"] \ |
|
703
|
ticket-and-hash [list [string range $nameC1 0 5]] \ |
|
704
|
[list "\{\"ambiguous\":\[" "\"artifact\":\"$nameC1\"" \ |
|
705
|
"\"artifact\":\"$nameT1\"" "\}\]\}"] \ |
|
706
|
phantom [list $nameGhostParent] \ |
|
707
|
[list "\"artifact\":null\}"] \ |
|
708
|
by-file [list -f f.txt] \ |
|
709
|
[list "\"file\":\"f.txt\"" "!\"name\""] \ |
|
710
|
hash-only [list -h tip] \ |
|
711
|
[list "\"artifact\":\"$nameB3\"" "\"comment\":\"b3\""] \ |
|
712
|
two-names [list tip nosuch] \ |
|
713
|
[list "\"comment\":\"b3\"\}\n[string repeat - 79]\n\{\"unknown\""] \ |
|
714
|
] { |
|
715
|
name_whatis json-$nameCase $nameWant --json {*}$nameArgs |
|
716
|
} |
|
717
|
|
|
718
|
test_eq name-whatis-sql-name [fossil_sql "SELECT whatis('nosuch')"] \ |
|
719
|
"\{\"unknown\":\"nosuch\"\}" |
|
720
|
test name-whatis-sql-rid {[holds_strings \ |
|
721
|
[fossil_sql "SELECT whatis($nameRidC1)"] \ |
|
722
|
[list "\{\"rid\":$nameRidC1,\"artifact\":\"$nameC1\"" \ |
|
723
|
"\"comment\":\"c1\"\}"]]} |
|
724
|
test_eq name-whatis-sql-rid-none [fossil_sql "SELECT whatis(99999)"] \ |
|
725
|
"\{\"rid\":99999,\"artifact\":null\}" |
|
726
|
test_eq name-whatis-sql-other [fossil_sql "SELECT typeof(whatis(1.5))"] null |
|
727
|
|
|
728
|
############################################################################### |
|
729
|
# Other commands that take a name. |
|
730
|
|
|
731
|
fossil test-name-to-id --type ci $nameCtwin |
|
732
|
test_eq name-command-checkin-twins $RESULT \ |
|
733
|
"$nameCtwin -> ERROR: ambiguous name: $nameCtwin" |
|
734
|
fossil test-name-to-id --count 1 rel1 nosuch |
|
735
|
test_eq name-command-count $RESULT "rel1 -> $nameC1 |
|
736
|
rel1 -> $nameC1 |
|
737
|
nosuch -> ERROR: cannot resolve name: nosuch" |
|
738
|
fossil test-name-to-id rel1 --count |
|
739
|
test_eq name-command-count-last $RESULT "rel1 -> $nameC1 |
|
740
|
--count -> ERROR: cannot resolve name: --count" |
|
741
|
|
|
742
|
fossil_raw update -n rel1 |
|
743
|
test name-command-update {$CODE == 0 && [string match \ |
|
744
|
"*updated-to:*[string range $nameC1 0 39] 2025-01-02 10:00:00 UTC*" \ |
|
745
|
$RESULT]} |
|
746
|
fossil update -n $nameCtwin -expectError |
|
747
|
test name-command-update-twins \ |
|
748
|
{[string match "*ambiguous name: $nameCtwin*" $RESULT]} |
|
749
|
fossil update -n nosuch -expectError |
|
750
|
test name-command-update-none \ |
|
751
|
{[string match "*cannot resolve name: nosuch*" $RESULT]} |
|
752
|
fossil branch close nosuch -expectError |
|
753
|
test name-command-branch-close-none \ |
|
754
|
{[string match "*Cannot resolve name: nosuch*" $RESULT]} |
|
755
|
fossil branch close $nameCtwin -expectError |
|
756
|
test name-command-branch-close-twins \ |
|
757
|
{[string match "*Ambiguous name: $nameCtwin*" $RESULT]} |
|
758
|
|
|
759
|
# The header of a diff shows each version and its time. A date as the |
|
760
|
# first version is taken at its start, as the second at its end. |
|
761
|
fossil diff --versions --from rel1 --to trunk |
|
762
|
test name-command-diff-names {[holds_strings $RESULT [list \ |
|
763
|
"Fossil-Diff-From: [string range $nameC1 0 9] 2025-01-02 10:00:00 UTC" \ |
|
764
|
"Fossil-Diff-To: [string range $nameC3 0 9] 2025-01-05 10:00:00 UTC"]]} |
|
765
|
fossil diff --versions --from 2025-01-03 --to 2025-01-04 |
|
766
|
test name-command-diff-dates {[holds_strings $RESULT [list \ |
|
767
|
"Fossil-Diff-From: [string range $nameC2 0 9] 2025-01-03 00:00:00 UTC" \ |
|
768
|
"Fossil-Diff-To: [string range $nameB1 0 9] 2025-01-04 00:00:00 UTC"]]} |
|
769
|
fossil diff --versions --from 20250103 --to 20250104 |
|
770
|
test name-command-diff-numbers {[holds_strings $RESULT [list \ |
|
771
|
"Fossil-Diff-From: [string range $nameC2 0 9] 2025-01-03 00:00:00 UTC" \ |
|
772
|
"Fossil-Diff-To: [string range $nameB1 0 9] 2025-01-05 00:00:00 UTC"]]} |
|
773
|
|
|
774
|
# "fossil finfo --id" describes the artifact that holds a file. |
|
775
|
fossil finfo --id f.txt |
|
776
|
test name-command-finfo-id {[holds_strings $RESULT [list \ |
|
777
|
"mtime: 2025-01-03 10:00:00" "file: f.txt" \ |
|
778
|
"part of \[[string range $nameC2 0 9]\] on branch trunk"]]} |
|
779
|
fossil finfo --id -r br f.txt |
|
780
|
test name-command-finfo-id-revision {[holds_strings $RESULT [list \ |
|
781
|
"mtime: 2025-01-07 10:00:00" "on branch br"]]} |
|
782
|
fossil finfo --id -v -r rel1 p.txt |
|
783
|
test name-command-finfo-id-verbose {[holds_strings $RESULT [list \ |
|
784
|
"artifact: $nameP" "file: p.txt" "!mtime:"]]} |
|
785
|
|
|
786
|
# Lists of the beginnings that more than one name shares. |
|
787
|
fossil test-ambiguous |
|
788
|
test_eq name-command-ambiguous [lsort $RESULT] [lsort [list \ |
|
789
|
[string range $nameC1 0 5] [string range $nameC3 0 5] $nameTwin \ |
|
790
|
$nameWtwin $nameCtwin]] |
|
791
|
fossil test-ambiguous --minsize 5 |
|
792
|
test_eq name-command-ambiguous-minsize [lsort $RESULT] [lsort [list \ |
|
793
|
[string range $nameC1 0 5] [string range $nameC3 0 5] $nameTwin]] |
|
794
|
fossil test-ambiguous --minsize 0 |
|
795
|
test_eq name-command-ambiguous-minsize-0 [llength $RESULT] 5 |
|
796
|
fossil test-ambiguous --minsize 7 |
|
797
|
test_eq name-command-ambiguous-minsize-7 $RESULT "" |
|
798
|
|
|
799
|
# One line for each artifact. |
|
800
|
fossil test-describe-artifacts |
|
801
|
set nameAll $RESULT |
|
802
|
test_eq name-command-describe [name_missing $nameAll [list \ |
|
803
|
[join [list \ |
|
804
|
" [string range $nameC0 0 15] check-in to trunk by alice " \ |
|
805
|
"on 2025-01-01 00:00 "] ""] \ |
|
806
|
[join [list \ |
|
807
|
" [string range $nameB3 0 15] check-in to br by alice on " \ |
|
808
|
"2025-01-07 10:00 "] ""] \ |
|
809
|
[join [list \ |
|
810
|
" [string range $namePriv 0 15] check-in to private by " \ |
|
811
|
"alice on 2025-01-07 09:00 (private)"] ""] \ |
|
812
|
" [string range $nameP 0 15] file p.txt " \ |
|
813
|
" [string range $nameG1 0 15] tag [string range $nameC1 0 15] " \ |
|
814
|
" [string range $nameCluster 0 15] cluster " \ |
|
815
|
" [string range $nameT1 0 15] ticket [string range $nameTktLike 0 20] " \ |
|
816
|
" [string range $nameW3 0 15] wiki \"Orphan\" " \ |
|
817
|
" [string range $nameE1 0 15] event $nameEid " \ |
|
818
|
" [string range $nameA1 0 15] attachment-control for att1.txt " \ |
|
819
|
" [string range $nameAtt1 0 15] attachment att1.txt " \ |
|
820
|
" [string range $nameF1 0 15] forum-post [string range $nameF1 0 13] " \ |
|
821
|
" [string range $nameSha1 0 15] unknown " \ |
|
822
|
" [string range $nameGhostParent 0 15] parent of check-in $nameW3" \ |
|
823
|
" [string range $nameGhostMerge 0 15] merge parent of check-in $nameSide" \ |
|
824
|
" [string range $nameGhostFile 0 15] file lost.txt " \ |
|
825
|
[join [list \ |
|
826
|
" [string range $nameGhostTarget 0 15] check-in referenced " \ |
|
827
|
"by \"sym-ghost\" tag $nameG2"] ""] \ |
|
828
|
[join [list \ |
|
829
|
" [string range $nameGhostMember 0 15] referenced by " \ |
|
830
|
"cluster $nameCluster"] ""]]] {} |
|
831
|
test_eq name-command-describe-count [llength [split $nameAll \n]] \ |
|
832
|
[fossil_sql "SELECT count(*) FROM blob"] |
|
833
|
fossil test-describe-artifacts --from 3 --count 2 |
|
834
|
test_eq name-command-describe-range [llength [split $RESULT \n]] 2 |
|
835
|
fossil test-unsent |
|
836
|
test name-command-unsent {[holds_strings $RESULT [list \ |
|
837
|
" [string range $nameC1 0 15] check-in to trunk" \ |
|
838
|
"![string range $nameCluster 0 15]"]]} |
|
839
|
fossil test-unclustered |
|
840
|
test name-command-unclustered {[holds_strings $RESULT [list \ |
|
841
|
" [string range $nameC2 0 15] check-in to trunk" \ |
|
842
|
" [string range $nameCluster 0 15] cluster" \ |
|
843
|
"![string range $nameC0 0 15]"]]} |
|
844
|
fossil test-phantoms |
|
845
|
test name-command-phantoms {[llength [split $RESULT \n]] == 5 |
|
846
|
&& [holds_strings $RESULT [list \ |
|
847
|
" [string range $nameGhostFile 0 15] file lost.txt " \ |
|
848
|
" [string range $nameGhostMember 0 15] referenced by cluster"]]} |
|
849
|
fossil test-phantoms --list |
|
850
|
test name-command-phantoms-list {[holds_strings $RESULT [list \ |
|
851
|
"[string range $nameGhostFile 0 9] (" "20250105aa (" \ |
|
852
|
"Phantoms: 5 Delta-phantoms: 0"]]} |
|
853
|
fossil test-phantoms --count |
|
854
|
test_eq name-command-phantoms-count $RESULT "Phantoms: 5 Delta-phantoms: 0" |
|
855
|
fossil test-phantoms --delta |
|
856
|
test_eq name-command-phantoms-delta $RESULT "" |
|
857
|
fossil test-whatis-all |
|
858
|
test name-command-whatis-all {[holds_strings $RESULT [list \ |
|
859
|
"artifact: $nameC0 (1)" "artifact: $nameF1 (" \ |
|
860
|
"file: q.txt" [string repeat - 79]]] |
|
861
|
&& [regexp -all {artifact: } $RESULT] |
|
862
|
== [fossil_sql "SELECT count(*) FROM blob WHERE size>=0"]} |
|
863
|
|
|
864
|
# A repository with no phantoms. |
|
865
|
fossil new nophantom.fossil |
|
866
|
fossil test-phantoms -R nophantom.fossil --count |
|
867
|
test_eq name-command-phantoms-count-none $RESULT "" |
|
868
|
file delete nophantom.fossil |
|
869
|
|
|
870
|
############################################################################### |
|
871
|
# Web pages. Each request goes to a copy of the repository as user |
|
872
|
# "nobody", who is given the capabilities the case names; "admin" is a |
|
873
|
# request from the local administrator. |
|
874
|
|
|
875
|
file copy $nameRepo web.fossil |
|
876
|
set nameWeb [file join [pwd] web.fossil] |
|
877
|
set nameCapsNow ? |
|
878
|
|
|
879
|
# Send a GET request for PATH and return the reply. |
|
880
|
# |
|
881
|
proc name_get {path {caps gjorz}} { |
|
882
|
global nameWeb nameCapsNow |
|
883
|
set options [list --ipaddr 127.0.0.1] |
|
884
|
if {$caps eq "admin"} { |
|
885
|
lappend options --localauth |
|
886
|
} elseif {$caps ne $nameCapsNow} { |
|
887
|
fossil sql -R $nameWeb "UPDATE user SET cap='$caps' WHERE login='nobody'" |
|
888
|
set nameCapsNow $caps |
|
889
|
} |
|
890
|
return [fossil_http $nameWeb [request_get $path] {*}$options] |
|
891
|
} |
|
892
|
|
|
893
|
# Test NAME passes if the reply to a request for PATH holds every string |
|
894
|
# in WANTED and none of those that begin with "!". |
|
895
|
# |
|
896
|
proc name_page {name path wanted {caps gjorz}} { |
|
897
|
set reply [name_get $path $caps] |
|
898
|
test_eq name-page-$name [name_missing $reply $wanted] {} |
|
899
|
} |
|
900
|
|
|
901
|
set nameHref {<a href="/info/} |
|
902
|
|
|
903
|
# A name that could mean more than one thing gets the page that lists |
|
904
|
# them, or a redirect to it. |
|
905
|
name_page info-twins /info/$nameTwin [list "HTTP/1.0 200 OK" \ |
|
906
|
"The artifact hash prefix <b>$nameTwin</b> is ambiguous" \ |
|
907
|
"$nameHref[string range $nameP 0 15]\">" $nameQ p.txt q.txt] |
|
908
|
name_page info-ticket-and-hash /info/[string range $nameC1 0 5] [list \ |
|
909
|
"is ambiguous" $nameC1 "$nameHref[string range $nameTktLike 0 15]\">" \ |
|
910
|
"Ticket\n" "Like a check-in"] |
|
911
|
name_page info-technote-and-hash /info/[string range $nameC3 0 5] [list \ |
|
912
|
"is ambiguous" $nameC3 "$nameHref[string range $nameEidLike 0 15]\">"] |
|
913
|
name_page info-three /info/[string range $nameP 0 2] [list \ |
|
914
|
"!is ambiguous" "No such object: [string range $nameP 0 2]"] |
|
915
|
name_page info-too-long /info/${nameC1}0 [list "!is ambiguous" \ |
|
916
|
"No such object: ${nameC1}0"] |
|
917
|
name_page info-not-hex /info/trunk [list "!is ambiguous" "HTTP/1.0 200 OK" \ |
|
918
|
$nameC3] admin |
|
919
|
name_page info-prefix /info/[string range $nameC1 0 9] [list \ |
|
920
|
"!is ambiguous" "HTTP/1.0 200 OK" $nameC1] admin |
|
921
|
name_page info-date /info/date:2025-01-03 [list "HTTP/1.0 200 OK" $nameC2] admin |
|
922
|
name_page info-date-zulu /info/date:20250103Z [list "HTTP/1.0 200 OK" \ |
|
923
|
$nameC2] admin |
|
924
|
name_page info-escape /info/re%6c1 [list "HTTP/1.0 200 OK" $nameC1] admin |
|
925
|
name_page info-percent /info/% [list "No such object: %"] |
|
926
|
name_page info-bad-escape /info/%zz [list "No such object: "] |
|
927
|
name_page info-nul /info/rel1%00x [list "HTTP/1.0 200 OK" $nameC1] admin |
|
928
|
name_page info-long /info/[string repeat a 5000] [list "No such object: aaaa"] |
|
929
|
name_page hexdump-twins /hexdump/$nameTwin [list \ |
|
930
|
"HTTP/1.0 302 Moved Temporarily" \ |
|
931
|
"Location: http://x/ambiguous/$nameTwin?src=hexdump"] |
|
932
|
name_page hexdump-no-name /hexdump [list "HTTP/1.0 302 Moved Temporarily" \ |
|
933
|
"Location: http://x/index"] admin |
|
934
|
name_page hexdump-empty-name /hexdump?name= [list \ |
|
935
|
"HTTP/1.0 302 Moved Temporarily" "Location: http://x/index"] admin |
|
936
|
name_page artifact-twins /artifact/$nameTwin [list \ |
|
937
|
"HTTP/1.0 400 Bad Request" "ambiguous name: $nameTwin"] admin |
|
938
|
name_page ambiguous /ambiguous?name=$nameTwin&src=artifact [list \ |
|
939
|
"HTTP/1.0 200 OK" "<a href=\"/artifact/[string range $nameP 0 15]\">" \ |
|
940
|
"<a href=\"/artifact/[string range $nameQ 0 15]\">"] |
|
941
|
name_page ambiguous-upper /ambiguous/[string toupper $nameTwin] [list \ |
|
942
|
$nameP $nameQ] |
|
943
|
name_page ambiguous-none /ambiguous/[string repeat 5a 5] [list \ |
|
944
|
"HTTP/1.0 200 OK" "<ol>\n</ol>"] |
|
945
|
name_page ambiguous-no-name /ambiguous [list \ |
|
946
|
"HTTP/1.0 302 Moved Temporarily" "Location: http://x/index"] |
|
947
|
name_page ambiguous-empty-name /ambiguous?name= [list \ |
|
948
|
"HTTP/1.0 302 Moved Temporarily" "Location: http://x/index"] |
|
949
|
name_page ambiguous-empty-source /ambiguous?name=$nameTwin&src= [list \ |
|
950
|
"HTTP/1.0 302 Moved Temporarily" "Location: http://x/index"] |
|
951
|
|
|
952
|
# The page that shows the tags of an artifact says what kind it is. |
|
953
|
foreach {nameCase nameName nameWant} [list \ |
|
954
|
checkin $nameC1 Check-in \ |
|
955
|
wiki $nameW1 Wiki-edit \ |
|
956
|
technote $nameE1 Technote \ |
|
957
|
forum $nameF1 Forum-post \ |
|
958
|
ticket $nameT1 Ticket-change \ |
|
959
|
tag $nameG1 Tag-change \ |
|
960
|
file $nameP Artifact \ |
|
961
|
] { |
|
962
|
name_page ci-tags-$nameCase /ci_tags/$nameName [list \ |
|
963
|
"<h1>Tags and Properties for $nameWant <a "] admin |
|
964
|
} |
|
965
|
|
|
966
|
# The timeline takes a second name to use when the first one names |
|
967
|
# nothing. |
|
968
|
name_page timeline-first /timeline?p=rel1&p2=tip [list "HTTP/1.0 200 OK" \ |
|
969
|
"ancestor of" rel1 c1 "!>b3<"] admin |
|
970
|
name_page timeline-second /timeline?p=nosuch&p2=tip [list "HTTP/1.0 200 OK" \ |
|
971
|
"ancestors of" b3] admin |
|
972
|
name_page timeline-neither /timeline?p=nosuch&p2=nosuch2 [list \ |
|
973
|
"HTTP/1.0 400 Bad Request" "cannot resolve name: nosuch2"] admin |
|
974
|
name_page timeline-no-second /timeline?p=nosuch [list \ |
|
975
|
"HTTP/1.0 400 Bad Request" "cannot resolve name: nosuch"] admin |
|
976
|
name_page timeline-empty-second /timeline?p=nosuch&p2= [list \ |
|
977
|
"HTTP/1.0 400 Bad Request" "cannot resolve name: nosuch"] admin |
|
978
|
name_page timeline-empty-first /timeline?p=&p2=tip [list "HTTP/1.0 200 OK" \ |
|
979
|
"!ancestors of"] admin |
|
980
|
name_page timeline-twins /timeline?p=$nameCtwin&p2=tip [list \ |
|
981
|
"HTTP/1.0 400 Bad Request" "ambiguous name: $nameCtwin"] admin |
|
982
|
|
|
983
|
# Times on the timeline: a date, a date without punctuation, a name. |
|
984
|
name_page timeline-date /timeline?c=2025-01-04&n=2 [list \ |
|
985
|
"occurring around 2025-01-04." b1] admin |
|
986
|
name_page timeline-number /timeline?c=20250104&n=2 [list \ |
|
987
|
"occurring around 2025-01-04." b1] admin |
|
988
|
name_page timeline-number-after "/timeline?a=202501041000Z&n=2" [list \ |
|
989
|
"occurring on or after 2025-01-04 10:00Z." b1 c3] admin |
|
990
|
name_page timeline-number-after-z "/timeline?a=20250104100000z&n=1" [list \ |
|
991
|
"occurring on or after 2025-01-04 10:00:00Z." b1 "!>c3<"] admin |
|
992
|
name_page timeline-number-zulu-day "/timeline?a=20250104Z&n=1" [list \ |
|
993
|
"HTTP/1.0 200 OK" "occurring on or after 20250104Z." b1 "!>c3<"] admin |
|
994
|
name_page timeline-number-is-hash /timeline?c=20250105 [list \ |
|
995
|
"HTTP/1.0 200 OK" "!occurring around 2025-01-05"] admin |
|
996
|
name_page timeline-tag /timeline?c=rel1&n=1 [list \ |
|
997
|
"occurring around rel1." c1] admin |
|
998
|
name_page timeline-technote "/timeline?c=[string range $nameEid 0 7]&n=1" \ |
|
999
|
[list "occurring around [string range $nameEid 0 7]."] admin |
|
1000
|
name_page timeline-bad-date /timeline?c=2025-13-45 [list "HTTP/1.0 200 OK" \ |
|
1001
|
"!occurring around"] admin |
|
1002
|
name_page timeline-minute-60 /timeline?c=202501031060 [list "HTTP/1.0 200 OK" \ |
|
1003
|
"!occurring around"] admin |
|
1004
|
name_page timeline-no-such-name /timeline?c=nosuch [list "HTTP/1.0 200 OK" \ |
|
1005
|
"!occurring around"] admin |
|
1006
|
name_page timeline-back-to /timeline?p=tip&bt=rel1 [list "HTTP/1.0 200 OK" \ |
|
1007
|
c2 "!initial empty check-in"] admin |
|
1008
|
name_page timeline-back-to-tag /timeline?p=tip&bt=tag:rel1 [list \ |
|
1009
|
"HTTP/1.0 200 OK" c2 "!initial empty check-in"] admin |
|
1010
|
name_page timeline-back-to-hash \ |
|
1011
|
"/timeline?p=tip&bt=[string range $nameC2 0 9]" \ |
|
1012
|
[list "HTTP/1.0 200 OK" b1 "!>c1<"] admin |
|
1013
|
name_page timeline-forward-to /timeline?d=rel1&ft=br [list "HTTP/1.0 200 OK" \ |
|
1014
|
"descendants of" ">br</a>"] admin |
|
1015
|
name_page timeline-forward-to-tag /timeline?d=rel1&ft=tag:br [list \ |
|
1016
|
"HTTP/1.0 200 OK" "descendants of" ">tag:br</a>"] admin |
|
1017
|
name_page timeline-forward-to-hash \ |
|
1018
|
"/timeline?d=rel1&ft=[string range $nameB1 0 9]" [list "HTTP/1.0 200 OK" \ |
|
1019
|
"descendants of" ">[string range $nameB1 0 9]</a>"] admin |
|
1020
|
name_page timeline-forward-to-none /timeline?d=rel1&ft=nosuch [list \ |
|
1021
|
"HTTP/1.0 200 OK" "descendants of" "!cannot resolve"] admin |
|
1022
|
|
|
1023
|
# A page that is given no name at all. |
|
1024
|
name_page forum-edit-no-name /forumedit [list \ |
|
1025
|
"Missing or invalid fpid query parameter"] admin |
|
1026
|
|
|
1027
|
############################################################################### |
|
1028
|
# Pages that list artifacts. |
|
1029
|
|
|
1030
|
set nameHead {<tr><th>RID<th>Hash<th>Received<th>Description<th>Ref<th>Remarks} |
|
1031
|
set nameRidMax [fossil_sql "SELECT max(rid) FROM blob"] |
|
1032
|
set nameRidDelta [fossil_sql "SELECT rid FROM delta LIMIT 1"] |
|
1033
|
|
|
1034
|
# What each kind of user is shown. |
|
1035
|
foreach {nameCase namePath nameCaps nameWant} [list \ |
|
1036
|
bloblist-admin /bloblist admin \ |
|
1037
|
[list "HTTP/1.0 200 OK" $nameHead \ |
|
1038
|
"check-in to trunk by alice on 2025-01-01 00:00" "<td>phantom</td>" \ |
|
1039
|
"<td>private</td>" "<a href='/rcvfrom?rcvid=" "href=\"bloblist?priv\">" \ |
|
1040
|
"href=\"rcvfromlist\">" "href=\"artifact_stats\">" \ |
|
1041
|
"href=\"bloblist?phan\">" "href=\"bloblist?unclustered\">" \ |
|
1042
|
"href=\"bloblist?n=250&recent\">" "!Select a range" \ |
|
1043
|
"!href=\"bloblist\">" "!background-color"] \ |
|
1044
|
bloblist-reader /bloblist gjorz \ |
|
1045
|
[list $nameHead "file p.txt" "<td>phantom</td>" "!<td>private</td>" \ |
|
1046
|
"!check-in to private" "!rcvfrom" "!href=\"bloblist?priv\">" \ |
|
1047
|
"!href=\"artifact_stats\">"] \ |
|
1048
|
bloblist-reader-private /bloblist?priv gjorz \ |
|
1049
|
[list $nameHead "file p.txt" "!Private Artifacts" "!check-in to private"] \ |
|
1050
|
bloblist-private-user /bloblist ox \ |
|
1051
|
[list "check-in to private" "<td>private</td>" \ |
|
1052
|
"href=\"bloblist?priv\">" "!rcvfrom"] \ |
|
1053
|
bloblist-admin-user /bloblist oa \ |
|
1054
|
[list "check-in to private" "href=\"bloblist?priv\">" \ |
|
1055
|
"href=\"rcvfromlist\">"] \ |
|
1056
|
bloblist-writer /bloblist oi \ |
|
1057
|
[list "href=\"artifact_stats\">" "!check-in to private"] \ |
|
1058
|
bloblist-no-read /bloblist {} \ |
|
1059
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=bloblist"] \ |
|
1060
|
bloblist-ranges /bloblist?n=10 admin \ |
|
1061
|
[list "Select a range of artifacts to view" \ |
|
1062
|
"<a href=\"/bloblist?s=1&n=10\">\n1..10</a>" \ |
|
1063
|
"<a href=\"/bloblist?s=11&n=10\">\n11..20</a>" \ |
|
1064
|
"..$nameRidMax</a>" "250 most recent</a>" "All unclustered</a>" \ |
|
1065
|
"!$nameHead" "!href=\"bloblist\">"] \ |
|
1066
|
bloblist-range /bloblist?s=11&n=10 admin \ |
|
1067
|
[list $nameHead "<td align=\"right\">11</td>" \ |
|
1068
|
"<td align=\"right\">20</td>" \ |
|
1069
|
"!<td align=\"right\">10</td>" "!<td align=\"right\">21</td>" \ |
|
1070
|
"href=\"bloblist\">"] \ |
|
1071
|
bloblist-private /bloblist?priv admin \ |
|
1072
|
[list "<h2>Private Artifacts</h2>" "check-in to private" "file h.txt" \ |
|
1073
|
"!check-in to trunk" "href=\"bloblist\">" "!href=\"bloblist?priv\">"] \ |
|
1074
|
bloblist-private-short /bloblist?priv&n=10 admin \ |
|
1075
|
[list "<h2>Private Artifacts</h2>" "!Select a range"] \ |
|
1076
|
bloblist-phantoms /bloblist?phan admin \ |
|
1077
|
[list "<h2>Phantom Artifacts</h2>" \ |
|
1078
|
"<td align=\"left\">parent of check-in</td>" \ |
|
1079
|
"<a href=\"/info/[string range $nameW3 0 15]\">" \ |
|
1080
|
"<td align=\"left\">file lost.txt</td>\n<td> \n<td> \n</tr>" \ |
|
1081
|
"!check-in to trunk" "href=\"bloblist\">" "!href=\"bloblist?phan\">"] \ |
|
1082
|
bloblist-phantoms-short /bloblist?phan&n=10 admin \ |
|
1083
|
[list "<h2>Phantom Artifacts</h2>" "!Select a range"] \ |
|
1084
|
bloblist-unclustered /bloblist?unclustered&n=10 admin \ |
|
1085
|
[list "<h2>Unclustered Artifacts</h2>" "!Select a range" \ |
|
1086
|
"check-in to br" "!on 2025-01-01 00:00" \ |
|
1087
|
"!href=\"bloblist?unclustered\">"] \ |
|
1088
|
bloblist-recent /bloblist?recent&n=10 admin \ |
|
1089
|
[list "<h2>10 Most Recent Artifacts</h2>" "!Select a range" \ |
|
1090
|
"<td align=\"right\">$nameRidMax</td>" "!<td align=\"right\">1</td>" \ |
|
1091
|
"href=\"bloblist?n=250&recent\">"] \ |
|
1092
|
bloblist-recent-250 /bloblist?recent&n=250 admin \ |
|
1093
|
[list "<h2>250 Most Recent Artifacts</h2>" \ |
|
1094
|
"!href=\"bloblist?n=250&recent\">"] \ |
|
1095
|
bloblist-colors /bloblist?hclr admin \ |
|
1096
|
[list "<tr style='background-color:#b0ffb0;'><td align=\"right\">1</td>" \ |
|
1097
|
"<tr style='background-color:#ebffb0;'>"] \ |
|
1098
|
bloblist-colors-dark /bloblist?hclr&skin=darkmode admin \ |
|
1099
|
[list "<tr style='background-color:#177117;'><td align=\"right\">1</td>" \ |
|
1100
|
"<tr style='background-color:#714417;'>"] \ |
|
1101
|
phantoms-admin /phantoms admin \ |
|
1102
|
[list "<tr><th>RID<th>Description<th>Source<th>Age" \ |
|
1103
|
"$nameGhostParent<br>parent of check-in</td>" \ |
|
1104
|
"<a href=\"/info/[string range $nameW3 0 15]\">[string range $nameW3 0 15]</a>" \ |
|
1105
|
"$nameGhostFile<br>file lost.txt</td>\n<td> <td> " \ |
|
1106
|
"href=\"rcvfromlist\">" "href=\"bloblist\">" \ |
|
1107
|
"href=\"artifact_stats\">"] \ |
|
1108
|
phantoms-reader /phantoms gjorz \ |
|
1109
|
[list "$nameGhostMerge<br>merge parent of check-in</td>" \ |
|
1110
|
"!href=\"rcvfromlist\">" "!href=\"artifact_stats\">"] \ |
|
1111
|
phantoms-no-read /phantoms {} \ |
|
1112
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=phantoms"] \ |
|
1113
|
audit-phantoms /secaudit0 admin \ |
|
1114
|
[list "$nameGhostParent<br>parent of check-in</td>"] \ |
|
1115
|
largest /bigbloblist?n=3 admin \ |
|
1116
|
[list "3 Largest Artifacts" "<th align=\"right\">From<th>Hash" \ |
|
1117
|
"file big.txt" "href=\"rcvfromlist\">" "href=\"artifact_stats\">" \ |
|
1118
|
"href=\"bloblist\">"] \ |
|
1119
|
largest-default /bigbloblist gjorz \ |
|
1120
|
[list "250 Largest Artifacts" "file big.txt" "check-in to trunk" \ |
|
1121
|
"!href=\"rcvfromlist\">" "!href=\"artifact_stats\">"] \ |
|
1122
|
largest-no-read /bigbloblist {} \ |
|
1123
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=bigbloblist"] \ |
|
1124
|
delta-chain /deltachain/$nameRidDelta admin \ |
|
1125
|
[list "Delta Chain Containing Artifact $nameRidDelta" \ |
|
1126
|
"<tr><td align=\"right\">0</td>" "<tr><td align=\"right\">1</td>" \ |
|
1127
|
"<td align=\"right\"><b>$nameRidDelta</b></td>" "file big.txt" \ |
|
1128
|
"Bytes of content" "Bytes stored in repository"] \ |
|
1129
|
delta-chain-no-name /deltachain gjorz \ |
|
1130
|
[list "Delta Chain Containing Artifact 0" "!<b>0</b>" \ |
|
1131
|
"<td align=\"right\">0</td></tr>"] \ |
|
1132
|
delta-chain-not-number /deltachain/tip gjorz \ |
|
1133
|
[list "Delta Chain Containing Artifact 0"] \ |
|
1134
|
delta-chain-no-read /deltachain/1 {} \ |
|
1135
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=deltachain"] \ |
|
1136
|
collisions /hash-collisions admin \ |
|
1137
|
[list "<h1>Hash Prefix Collisions on Check-ins</h1>" \ |
|
1138
|
[join [list \ |
|
1139
|
"<p>Collisions of length 4:\n" \ |
|
1140
|
"<a href=\"/ambiguous/$nameCtwin\">$nameCtwin</a>"] ""] \ |
|
1141
|
"<h1>Hash Prefix Collisions on All Artifacts</h1>" \ |
|
1142
|
[join [list \ |
|
1143
|
"<p>Collisions of length 5:\n" \ |
|
1144
|
"<a href=\"/ambiguous/$nameTwin\">$nameTwin</a>"] ""] \ |
|
1145
|
"<a href=\"/ambiguous/$nameWtwin\">$nameWtwin</a>" \ |
|
1146
|
"<p>Total number of hashes: [expr {$nameRidMax}]</p>" \ |
|
1147
|
"!First 25 collisions"] \ |
|
1148
|
collisions-no-read /hash-collisions {} \ |
|
1149
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=hash-collisions"] \ |
|
1150
|
clusters-admin /clusterlist admin \ |
|
1151
|
[list "<th>Compressed Size\n<th>User<th>IP-Address" \ |
|
1152
|
[join [list \ |
|
1153
|
"<tr><td align=\"right\">1\n" \ |
|
1154
|
"<td><a href=\"/info/[string range $nameCluster 0 9]\">"] ""] \ |
|
1155
|
"<td>alice\n<td> \n</tr>" "Total size of all clusters: " \ |
|
1156
|
"href=\"rcvfromlist\">" "href=\"artifact_stats\">"] \ |
|
1157
|
clusters-reader /clusterlist gjorz \ |
|
1158
|
[list "<th>Compressed Size\n<tr>" "!<td>alice" \ |
|
1159
|
"!href=\"rcvfromlist\">" "!href=\"artifact_stats\">"] \ |
|
1160
|
clusters-no-read /clusterlist {} \ |
|
1161
|
[list "HTTP/1.0 302 Moved Temporarily" "/login?g=clusterlist"] \ |
|
1162
|
] { |
|
1163
|
name_page $nameCase $namePath $nameWant $nameCaps |
|
1164
|
} |
|
1165
|
|
|
1166
|
# The most recent artifacts come latest first. |
|
1167
|
regexp {<tr><td align="right">(\d+)</td>} \ |
|
1168
|
[name_get /bloblist?recent&n=10 admin] nameAll nameFirst |
|
1169
|
test_eq name-page-bloblist-recent-order $nameFirst $nameRidMax |
|
1170
|
regexp {<tr><td align="right">(\d+)</td>} [name_get /bloblist admin] \ |
|
1171
|
nameAll nameFirst |
|
1172
|
test_eq name-page-bloblist-order $nameFirst 1 |
|
1173
|
|
|
1174
|
# The same pages after changes made to the copy by hand: a phantom that |
|
1175
|
# is private, a cluster with an address and then with no record of its |
|
1176
|
# arrival, and a phantom named by an artifact with no such record. |
|
1177
|
fossil sql -R $nameWeb "INSERT INTO private |
|
1178
|
SELECT rid FROM blob WHERE uuid='$nameGhostMember'; |
|
1179
|
UPDATE rcvfrom SET ipaddr='192.0.2.7' WHERE rcvid= |
|
1180
|
(SELECT rcvid FROM blob WHERE uuid='$nameCluster');" |
|
1181
|
name_page bloblist-private-phantom /bloblist?phan [list \ |
|
1182
|
"<td>private,phantom</td>" "<td>phantom</td>"] admin |
|
1183
|
name_page bloblist-private-phantom-reader /bloblist?phan [list \ |
|
1184
|
"<td>private,phantom</td>"] gjorz |
|
1185
|
name_page clusters-address /clusterlist [list \ |
|
1186
|
"<td>alice\n<td>192.0.2.7\n</tr>"] admin |
|
1187
|
fossil sql -R $nameWeb "UPDATE blob SET rcvid=99999 |
|
1188
|
WHERE uuid IN ('$nameCluster','$nameW3')" |
|
1189
|
name_page clusters-no-record /clusterlist [list \ |
|
1190
|
"<td> \n<td align=\"right\">" "<td> \n<td> \n</tr>" \ |
|
1191
|
"!<td>alice"] admin |
|
1192
|
name_page phantoms-no-record /phantoms [list \ |
|
1193
|
"[string range $nameW3 0 15]</a>\n<td> \n</tr>"] admin |
|
1194
|
|
|
1195
|
# An artifact kept as a delta from a phantom. |
|
1196
|
fossil sql -R $nameWeb "INSERT INTO delta(rid,srcid) VALUES( |
|
1197
|
(SELECT rid FROM blob WHERE uuid='$nameSha1'), |
|
1198
|
(SELECT rid FROM blob WHERE uuid='$nameGhostFile'))" |
|
1199
|
fossil test-phantoms -R $nameWeb --list |
|
1200
|
test name-command-phantoms-list-delta {[holds_strings $RESULT [list \ |
|
1201
|
"[string range $nameGhostFile 0 9] (" \ |
|
1202
|
"\n [string range $nameSha1 0 9] (" \ |
|
1203
|
"Phantoms: 5 Delta-phantoms: 1"]]} |
|
1204
|
fossil test-phantoms -R $nameWeb --count |
|
1205
|
test_eq name-command-phantoms-count-delta $RESULT \ |
|
1206
|
"Phantoms: 5 Delta-phantoms: 1" |
|
1207
|
fossil test-phantoms -R $nameWeb --delta |
|
1208
|
test_eq name-command-phantoms-delta-one $RESULT \ |
|
1209
|
" [string range $nameSha1 0 15] unknown " |
|
1210
|
|
|
1211
|
# A timeline entry of a kind that is not known. |
|
1212
|
fossil sql -R $nameWeb "UPDATE event SET type='x' WHERE objid= |
|
1213
|
(SELECT rid FROM blob WHERE uuid='$nameF1')" |
|
1214
|
name_page ci-tags-unknown-kind /ci_tags/$nameF1 [list \ |
|
1215
|
"<h1>Tags and Properties for Artifact <a "] admin |
|
1216
|
fossil whatis -R $nameWeb $nameF1 |
|
1217
|
test name-whatis-unknown-kind {[holds_strings $RESULT [list \ |
|
1218
|
"type: Unknown by alice on 2025-01-12 10:00:00"]]} |
|
1219
|
|
|
1220
|
# Thirty pairs of names that share four characters, then 210 pairs that |
|
1221
|
# share five. |
|
1222
|
fossil sql -R $nameWeb "WITH RECURSIVE c(i) AS |
|
1223
|
(VALUES(0) UNION ALL SELECT i+1 FROM c WHERE i<29) |
|
1224
|
INSERT INTO blob(rcvid,size,uuid) |
|
1225
|
SELECT 0, -1, printf('c%03x%d%059d',i,k,0) |
|
1226
|
FROM c, (SELECT 0 AS k UNION ALL SELECT 1)" |
|
1227
|
name_page collisions-many /hash-collisions [list \ |
|
1228
|
"<p>First 25 collisions of length 4:\n" \ |
|
1229
|
"<a href=\"/ambiguous/c000\">c000</a>" \ |
|
1230
|
"<a href=\"/ambiguous/c016\">c016</a>" "!<a href=\"/ambiguous/c017\">" \ |
|
1231
|
"<p>Collisions of length 5:\n<a href=\"/ambiguous/$nameTwin\">"] admin |
|
1232
|
fossil sql -R $nameWeb "WITH RECURSIVE c(i) AS |
|
1233
|
(VALUES(0) UNION ALL SELECT i+1 FROM c WHERE i<209) |
|
1234
|
INSERT INTO blob(rcvid,size,uuid) |
|
1235
|
SELECT 0, -1, printf('d%04x%d%058d',i,k,0) |
|
1236
|
FROM c, (SELECT 0 AS k UNION ALL SELECT 1)" |
|
1237
|
name_page collisions-too-many /hash-collisions [list \ |
|
1238
|
"<tr><td>5<td>211<td>" "!collisions of length 4:" \ |
|
1239
|
"<p>Collisions of length 4:\n<a href=\"/ambiguous/$nameCtwin\">"] admin |
|
1240
|
|
|
1241
|
# A user with no capabilities is not shown the names of artifacts. |
|
1242
|
set nameReply [name_get /ambiguous/[string range $nameP 0 0] {}] |
|
1243
|
test name-page-ambiguous-no-read {![string match *$nameP* $nameReply]} |
|
1244
|
|
|
1245
|
############################################################################### |
|
1246
|
# Known faults. |
|
1247
|
|
|
1248
|
# A request for more of the most recent artifacts than there are shows |
|
1249
|
# them all, and a request for fewer shows as many as asked for. |
|
1250
|
test name-page-bloblist-recent-all {[string match \ |
|
1251
|
{*<tr><td align="right">1</td>*} [name_get /bloblist?recent&n=600 admin]]} |
|
1252
|
test name-page-bloblist-recent-count {[regexp -all {<tr><td align="right">} \ |
|
1253
|
[name_get /bloblist?recent&n=250 admin]] == 250} |
|
1254
|
|
|
1255
|
# The list of tags has a quoted key in JSON. |
|
1256
|
fossil whatis --json tip |
|
1257
|
test name-whatis-json-tags-key {[string match {*,"tags":\["br"\],*} $RESULT]} |
|
1258
|
|
|
1259
|
# The second meaning of a name is numbered 2 when it is a ticket. |
|
1260
|
fossil whatis [string range $nameC1 0 5] |
|
1261
|
test name-whatis-ticket-meaning-number \ |
|
1262
|
{[string match "*---- meaning #2 ----*" $RESULT]} |
|
1263
|
|
|
1264
|
############################################################################### |
|
1265
|
test_cleanup |
|
1266
|
|