Fossil Wrapper

Check-in [9c0ef09819]
Login

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

Overview
Comment:cosmetics.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: 9c0ef0981993e70bc9c0259dd57c71e40732f965
User & Date: j 2013-07-29 13:00:07
Context
2013-07-29
14:42
cosmetics. check-in: 010ef78787 user: j tags: dresden
13:00
cosmetics. check-in: 9c0ef09819 user: j tags: dresden
2013-07-28
18:34
the `revnums' dictionary no longer uses reverse revision numbers as keys. check-in: 796166346a user: j tags: dresden
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
...
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
...
631
632
633
634
635
636
637

638
639
640
641
642
643
644
...
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
# Add a new filter on `commands' named `name' (creates proc):
proc filter {name commands body} {
    set caller_ns [uplevel 1 {namespace current}]
    set namespaced "${caller_ns}::$name"
    uplevel 1 [list proc $name line $body]
    foreach command_spec $commands {
        foreach command [triggers_for $command_spec] {
            dict append config::filters $command " $namespaced"
        }
    }
}

proc alias {spec target} {
    foreach name [triggers_for $spec] {
        dict set config::aliases $name $target
................................................................................
    alias  alog   {timeline -t ci -n 100000}
    alias  d      diff
    alias  di     diff
    alias  elog   {timeline -t ci -n 100000 -showfiles}
    alias  flog   {finfo}
    alias  heads  leaves;       # for hg refugees
    alias  log    {timeline -t ci}
    alias  not    {extras --dotfiles --ignore ""}
    alias  st     status
    alias  stat   status
    alias  t      {timeline -t ci}
    alias  time   timeline

    # -- Filters:

................................................................................
proc spawned_errno {{spawn_id -1}} {
    catch {wait -i $spawn_id} result_list
    lindex $result_list 3
}

proc unindent_script {script} {
    regexp "^ *" [set trimmed [string trim $script \n]] indent
    regsub -line -all "^$indent" $trimmed ""
}

proc ansi {mode table text} {
    if {[dict exists $table $mode]} {
        set code [dict get $table $mode]
        return "\[${code}m$text\[0m"
    } else {
................................................................................
# not that in the output list the linefeeds are "shifted"
# to the front of the timeline entries and that status information
# is kept in separate list entries. this allows to use the
# colorizers without modification while still getting the
# printed output to the form "one line per checkin".
# --------------------------------------------------------

   set numrev {}
   set out {}
   set usertag ""
   set rgxdate {^=== [0-9-]+ ===$}
   set rgxtime {^\d\d:\d\d:\d\d}
   set rgxrev {\[([a-f\d]{10})([^\]]*)\]}
   set rgxuser {\(user: .*\)}
   set cnt 0
   set prepend ""

   foreach record $records {
      # first get rid of the all leading/trailing whitespace and line feeds:
      set record [string trim $record]

      if {[regexp $rgxdate $record]} {
         # the `date' information is extracted and then prepended to the suitable checkins
................................................................................
      } elseif {[regexp $rgxrev $record]} { # this line contains a checkin message
         # extract relevant fields:
         regexp $rgxtime $record time
         regexp $rgxrev  $record rev
         regexp $rgxuser $record usertag

         # now reduce `record' to the checkin message:
         regsub " $rgxuser" $record "" record
         regsub "$time "    $record "" record
         regsub "$rgxrev "  $record "" record

         # determine relative revision number:
         set numrev [dict get $revnums $rev]:

         incr cnt
         if {$cnt > 1} {set prepend "\n"}

................................................................................
#-----------------------------------------------------------------------
   set huge    1000000     ;# should not be reached by most projects ...
   set revcnt  0
   set maxrev  0
   set rgxtime {^\d\d:\d\d:\d\d}
   set rgxrev  {\[([a-f\d]{10})([^\]]*)\]}
   set rgxrepo {\-R[[:blank:]]+.+} 
   set repo    ""

   regexp $rgxrepo $params repo
   catch {exec fossil timeline -n $huge {*}$repo} timeline
   set lines [split $timeline \n]

   foreach line $lines { 
      if {[regexp $rgxtime $line]} { incr maxrev }
................................................................................
   # output is generated. after extraction of the debug level the
   # option and its value are eliminated from the argument string
   # since it otherwise would be interpreted as an (unknown) command
   # during further processing.
  
   set dbgpat {\--debug[[:blank:]]+([[:digit:]]+[ ]*)}
   regexp $dbgpat $argv dum config::dbglvl
   regsub $dbgpat $argv "" argv

   return $argv
}

# --( Interceptors )----------------------------------------------------

# - Interceptors can refer to the current parameter list via an
................................................................................
        return 0;                # params cleared, no need to run fossil
    }
    set command [first $params]; # expanded candidate

    # Prepare filters:
    set chain [chain_for $candidate]
    set chain [expr {[empty? $chain] ? [chain_for $command] : $chain}]


    # Expect settings:
    set prior_log [log_user];   # to be reverted before returning
    if {![empty? $chain]} {
        log_user 0;             # disable logging to stdout
    }
    if {![interactive? $command]} {
................................................................................
          # if yes, don't unwrap (but it's still filtered 
          # through `fancy_timeline'. think ...)
          if {!$catmode} {
             set lines [unwrapTimeline $lines]
          }
       }

       if {$config::dbglvl > 1} {puts "*** filter chain: $chain"}

       foreach line $lines {
          if {$config::dbglvl > 2} {
             puts "IN: >$line<"
             puts -nonewline "OU: >"
             filter_with $chain "$line"
             puts "<"







|







 







|







 







|







 







|
|
|


|

|
|







 







|
|
|







 







|







 







|







 







>







 







|







36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
..
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
...
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
...
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
...
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
...
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
...
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
...
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
# Add a new filter on `commands' named `name' (creates proc):
proc filter {name commands body} {
    set caller_ns [uplevel 1 {namespace current}]
    set namespaced "${caller_ns}::$name"
    uplevel 1 [list proc $name line $body]
    foreach command_spec $commands {
        foreach command [triggers_for $command_spec] {
            dict append config::filters $command "$namespaced "
        }
    }
}

proc alias {spec target} {
    foreach name [triggers_for $spec] {
        dict set config::aliases $name $target
................................................................................
    alias  alog   {timeline -t ci -n 100000}
    alias  d      diff
    alias  di     diff
    alias  elog   {timeline -t ci -n 100000 -showfiles}
    alias  flog   {finfo}
    alias  heads  leaves;       # for hg refugees
    alias  log    {timeline -t ci}
    alias  not    {extras --dotfiles --ignore {}}
    alias  st     status
    alias  stat   status
    alias  t      {timeline -t ci}
    alias  time   timeline

    # -- Filters:

................................................................................
proc spawned_errno {{spawn_id -1}} {
    catch {wait -i $spawn_id} result_list
    lindex $result_list 3
}

proc unindent_script {script} {
    regexp "^ *" [set trimmed [string trim $script \n]] indent
    regsub -line -all "^$indent" $trimmed {}
}

proc ansi {mode table text} {
    if {[dict exists $table $mode]} {
        set code [dict get $table $mode]
        return "\[${code}m$text\[0m"
    } else {
................................................................................
# not that in the output list the linefeeds are "shifted"
# to the front of the timeline entries and that status information
# is kept in separate list entries. this allows to use the
# colorizers without modification while still getting the
# printed output to the form "one line per checkin".
# --------------------------------------------------------

   set numrev  {}
   set out     {}
   set usertag {}
   set rgxdate {^=== [0-9-]+ ===$}
   set rgxtime {^\d\d:\d\d:\d\d}
   set rgxrev  {\[([a-f\d]{10})([^\]]*)\]}
   set rgxuser {\(user: .*\)}
   set cnt     0
   set prepend {}

   foreach record $records {
      # first get rid of the all leading/trailing whitespace and line feeds:
      set record [string trim $record]

      if {[regexp $rgxdate $record]} {
         # the `date' information is extracted and then prepended to the suitable checkins
................................................................................
      } elseif {[regexp $rgxrev $record]} { # this line contains a checkin message
         # extract relevant fields:
         regexp $rgxtime $record time
         regexp $rgxrev  $record rev
         regexp $rgxuser $record usertag

         # now reduce `record' to the checkin message:
         regsub " $rgxuser" $record {} record
         regsub "$time "    $record {} record
         regsub "$rgxrev "  $record {} record

         # determine relative revision number:
         set numrev [dict get $revnums $rev]:

         incr cnt
         if {$cnt > 1} {set prepend "\n"}

................................................................................
#-----------------------------------------------------------------------
   set huge    1000000     ;# should not be reached by most projects ...
   set revcnt  0
   set maxrev  0
   set rgxtime {^\d\d:\d\d:\d\d}
   set rgxrev  {\[([a-f\d]{10})([^\]]*)\]}
   set rgxrepo {\-R[[:blank:]]+.+} 
   set repo    {}

   regexp $rgxrepo $params repo
   catch {exec fossil timeline -n $huge {*}$repo} timeline
   set lines [split $timeline \n]

   foreach line $lines { 
      if {[regexp $rgxtime $line]} { incr maxrev }
................................................................................
   # output is generated. after extraction of the debug level the
   # option and its value are eliminated from the argument string
   # since it otherwise would be interpreted as an (unknown) command
   # during further processing.
  
   set dbgpat {\--debug[[:blank:]]+([[:digit:]]+[ ]*)}
   regexp $dbgpat $argv dum config::dbglvl
   regsub $dbgpat $argv {} argv

   return $argv
}

# --( Interceptors )----------------------------------------------------

# - Interceptors can refer to the current parameter list via an
................................................................................
        return 0;                # params cleared, no need to run fossil
    }
    set command [first $params]; # expanded candidate

    # Prepare filters:
    set chain [chain_for $candidate]
    set chain [expr {[empty? $chain] ? [chain_for $command] : $chain}]
    set chain [string trimright $chain]

    # Expect settings:
    set prior_log [log_user];   # to be reverted before returning
    if {![empty? $chain]} {
        log_user 0;             # disable logging to stdout
    }
    if {![interactive? $command]} {
................................................................................
          # if yes, don't unwrap (but it's still filtered 
          # through `fancy_timeline'. think ...)
          if {!$catmode} {
             set lines [unwrapTimeline $lines]
          }
       }

       if {$config::dbglvl > 1} {puts "*** filter chain: [join $chain ", "]"}

       foreach line $lines {
          if {$config::dbglvl > 2} {
             puts "IN: >$line<"
             puts -nonewline "OU: >"
             filter_with $chain "$line"
             puts "<"