| | @@ -248,172 +248,89 @@ |
| 248 | 248 | close $out |
| 249 | 249 | } |
| 250 | 250 | proc write_file_indented {filename txt} { |
| 251 | 251 | write_file $filename [string trim [string map [list "\n " \n] $txt]]\n |
| 252 | 252 | } |
| 253 | + |
| 254 | +# Returns the directory of Fossil source files that the settings come |
| 255 | +# from: src/, beside the directory of this script. |
| 256 | +# |
| 257 | +proc get_source_dir {} { |
| 258 | + return [file join [file dirname $::testfiledir] src] |
| 259 | +} |
| 260 | + |
| 261 | +# Returns a dictionary of the settings defined in the source files, with |
| 262 | +# the setting name as key and a list {VERSIONABLE CONDITIONAL} as value. |
| 263 | +# |
| 264 | +# A setting is defined by a "** SETTING: NAME ?FLAGS?" comment, which |
| 265 | +# tools/mkindex.c reads to build the table of settings compiled into |
| 266 | +# fossil. The setting is versionable if FLAGS include "versionable". |
| 267 | +# As in mkindex, a setting is conditional when the last preprocessor |
| 268 | +# line before it starts with "#if", and a line starting with "#e", such |
| 269 | +# as "#else" or "#endif", ends that condition. A setting defined more |
| 270 | +# than once, such as case-sensitive, is defined under alternative |
| 271 | +# conditions, so it is not conditional. |
| 272 | +# |
| 273 | +proc get_source_settings {} { |
| 274 | + set count [dict create] |
| 275 | + set result [dict create] |
| 276 | + foreach fileName [glob -nocomplain -directory [get_source_dir] *.c] { |
| 277 | + set inIf 0 |
| 278 | + foreach line [split [read_file $fileName] \n] { |
| 279 | + if {[regexp {^#\s*(\S)(\S)?} $line dummy c1 c2]} { |
| 280 | + if {"$c1$c2" eq "if"} { |
| 281 | + set inIf 1 |
| 282 | + } elseif {$c1 eq "e"} { |
| 283 | + set inIf 0 |
| 284 | + } |
| 285 | + } elseif {[regexp -- {^\*\* SETTING:\s+(\S+)(.*)$} $line \ |
| 286 | + dummy name flags]} { |
| 287 | + set flags [regexp -all -inline {\S+} $flags] |
| 288 | + set versionable [expr {"versionable" in $flags}] |
| 289 | + dict incr count $name |
| 290 | + dict set result $name [list $versionable $inIf] |
| 291 | + } |
| 292 | + } |
| 293 | + } |
| 294 | + if {[dict size $result] == 0} { |
| 295 | + error "No \"** SETTING:\" comments found in [get_source_dir]/*.c" |
| 296 | + } |
| 297 | + dict for {name n} $count { |
| 298 | + if {$n > 1} { |
| 299 | + dict set result $name [list [lindex [dict get $result $name] 0] 0] |
| 300 | + } |
| 301 | + } |
| 302 | + return $result |
| 303 | +} |
| 304 | + |
| 305 | +# Returns the settings defined in the source files that this fossil |
| 306 | +# binary has: every unconditional setting, and each conditional setting |
| 307 | +# that "fossil settings NAME --exact" accepts. With VERSIONABLE true, |
| 308 | +# returns only the versionable ones. |
| 309 | +# |
| 310 | +proc get_source_settings_in_binary {versionable} { |
| 311 | + set result [list] |
| 312 | + dict for {name info} [get_source_settings] { |
| 313 | + lassign $info isVersionable isConditional |
| 314 | + if {$versionable && !$isVersionable} continue |
| 315 | + if {$isConditional && \ |
| 316 | + [catch {exec $::fossilexe settings $name --exact}]} continue |
| 317 | + lappend result $name |
| 318 | + } |
| 319 | + return [lsort -dictionary $result] |
| 320 | +} |
| 253 | 321 | |
| 254 | 322 | # Returns the list of all supported versionable settings. |
| 255 | 323 | # |
| 256 | 324 | proc get_versionable_settings {} { |
| 257 | | - # |
| 258 | | - # TODO: If the list of supported versionable settings in "db.c" is modified, |
| 259 | | - # this list (and procedure) most likely needs to be modified as well. |
| 260 | | - # |
| 261 | | - set result [list \ |
| 262 | | - binary-glob \ |
| 263 | | - clean-glob \ |
| 264 | | - crlf-glob \ |
| 265 | | - crnl-glob \ |
| 266 | | - dotfiles \ |
| 267 | | - empty-dirs \ |
| 268 | | - encoding-glob \ |
| 269 | | - ignore-glob \ |
| 270 | | - keep-glob \ |
| 271 | | - manifest] |
| 272 | | - |
| 273 | | - return [lsort -dictionary $result] |
| 325 | + return [get_source_settings_in_binary 1] |
| 274 | 326 | } |
| 275 | 327 | |
| 276 | 328 | # Returns the list of all supported settings. |
| 277 | 329 | # |
| 278 | 330 | proc get_all_settings {} { |
| 279 | | - # |
| 280 | | - # TODO: If the list of supported settings in "db.c" is modified, this list |
| 281 | | - # (and procedure) most likely needs to be modified as well. |
| 282 | | - # |
| 283 | | - set result [list \ |
| 284 | | - access-log \ |
| 285 | | - admin-log \ |
| 286 | | - allow-symlinks \ |
| 287 | | - auto-captcha \ |
| 288 | | - auto-hyperlink \ |
| 289 | | - auto-hyperlink-delay \ |
| 290 | | - auto-hyperlink-mouseover \ |
| 291 | | - auto-shun \ |
| 292 | | - autosync \ |
| 293 | | - autosync-tries \ |
| 294 | | - backoffice-disable \ |
| 295 | | - backoffice-logfile \ |
| 296 | | - backoffice-nodelay \ |
| 297 | | - binary-glob \ |
| 298 | | - case-sensitive \ |
| 299 | | - chat-alert-sound \ |
| 300 | | - chat-initial-history \ |
| 301 | | - chat-inline-images \ |
| 302 | | - chat-keep-count \ |
| 303 | | - chat-keep-days \ |
| 304 | | - chat-poll-timeout \ |
| 305 | | - chat-timeline-user \ |
| 306 | | - clean-glob \ |
| 307 | | - clearsign \ |
| 308 | | - comment-format \ |
| 309 | | - crlf-glob \ |
| 310 | | - crnl-glob \ |
| 311 | | - default-csp \ |
| 312 | | - default-perms \ |
| 313 | | - default-skin \ |
| 314 | | - diff-binary \ |
| 315 | | - diff-command \ |
| 316 | | - dont-commit \ |
| 317 | | - dont-push \ |
| 318 | | - dotfiles \ |
| 319 | | - editor \ |
| 320 | | - email-admin \ |
| 321 | | - email-listid \ |
| 322 | | - email-renew-interval \ |
| 323 | | - email-self \ |
| 324 | | - email-send-command \ |
| 325 | | - email-send-db \ |
| 326 | | - email-send-dir \ |
| 327 | | - email-send-method \ |
| 328 | | - email-send-relayhost \ |
| 329 | | - email-subname \ |
| 330 | | - email-url \ |
| 331 | | - empty-dirs \ |
| 332 | | - encoding-glob \ |
| 333 | | - exec-rel-paths \ |
| 334 | | - fileedit-glob \ |
| 335 | | - forbid-delta-manifests \ |
| 336 | | - forum-close-policy \ |
| 337 | | - forum-title \ |
| 338 | | - gdiff-command \ |
| 339 | | - gmerge-command \ |
| 340 | | - hash-digits \ |
| 341 | | - hooks \ |
| 342 | | - http-port \ |
| 343 | | - https-login \ |
| 344 | | - ignore-glob \ |
| 345 | | - keep-glob \ |
| 346 | | - large-file-size \ |
| 347 | | - localauth \ |
| 348 | | - lock-timeout \ |
| 349 | | - main-branch \ |
| 350 | | - mainmenu \ |
| 351 | | - manifest \ |
| 352 | | - max-cache-entry \ |
| 353 | | - max-loadavg \ |
| 354 | | - max-upload \ |
| 355 | | - mimetypes \ |
| 356 | | - mtime-changes \ |
| 357 | | - mv-rm-files \ |
| 358 | | - pgp-command \ |
| 359 | | - preferred-diff-type \ |
| 360 | | - proxy \ |
| 361 | | - raw-bgcolor \ |
| 362 | | - redirect-to-https \ |
| 363 | | - relative-paths \ |
| 364 | | - repo-cksum \ |
| 365 | | - repolist-skin \ |
| 366 | | - robot-restrict \ |
| 367 | | - robots-txt \ |
| 368 | | - safe-html \ |
| 369 | | - self-pw-reset \ |
| 370 | | - self-register \ |
| 371 | | - sitemap-extra \ |
| 372 | | - ssh-command \ |
| 373 | | - ssl-ca-location \ |
| 374 | | - ssl-identity \ |
| 375 | | - tclsh \ |
| 376 | | - th1-setup \ |
| 377 | | - th1-uri-regexp \ |
| 378 | | - ticket-default-report \ |
| 379 | | - timeline-hard-newlines \ |
| 380 | | - timeline-plaintext \ |
| 381 | | - timeline-truncate-at-blank \ |
| 382 | | - timeline-tslink-info \ |
| 383 | | - timeline-utc \ |
| 384 | | - user-color-map \ |
| 385 | | - verify-comments \ |
| 386 | | - uv-sync \ |
| 387 | | - vuln-report \ |
| 388 | | - web-browser] |
| 389 | | - |
| 390 | | - fossil test-th-eval "hasfeature legacyMvRm" |
| 391 | | - |
| 392 | | - if {[normalize_result] eq "1"} { |
| 393 | | - lappend result mv-rm-files |
| 394 | | - } |
| 395 | | - |
| 396 | | - fossil test-th-eval "hasfeature tcl" |
| 397 | | - |
| 398 | | - if {[normalize_result] eq "1"} { |
| 399 | | - lappend result tcl tcl-setup |
| 400 | | - } |
| 401 | | - |
| 402 | | - fossil test-th-eval "hasfeature th1Docs" |
| 403 | | - |
| 404 | | - if {[normalize_result] eq "1"} { |
| 405 | | - lappend result th1-docs |
| 406 | | - } |
| 407 | | - |
| 408 | | - fossil test-th-eval "hasfeature th1Hooks" |
| 409 | | - |
| 410 | | - if {[normalize_result] eq "1"} { |
| 411 | | - lappend result th1-hooks |
| 412 | | - } |
| 413 | | - |
| 414 | | - return [lsort -dictionary $result] |
| 331 | + return [get_source_settings_in_binary 0] |
| 415 | 332 | } |
| 416 | 333 | |
| 417 | 334 | # Return true if two files are the same |
| 418 | 335 | # |
| 419 | 336 | proc same_file {a b} { |
| 420 | 337 | |