Fossil Wrapper

Check-in [ec867b5461]
Login

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

Overview
Comment:augmented `df' interceptor to map to `gdi' if called as `gdf'. `df' can now also be called without further args.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: ec867b5461c943ab832d8628978f958a757fa886
User & Date: j 2013-07-27 15:06:00
Context
2013-07-27
16:22
simplified and improved `df' interceptor. check-in: 838bbe2a57 user: j tags: dresden
15:06
augmented `df' interceptor to map to `gdi' if called as `gdf'. `df' can now also be called without further args. check-in: ec867b5461 user: j tags: dresden
12:20
adjusted `fancy_timeline' which now highlights the relative revision numbers in magenta. check-in: 1d05884eb1 user: j tags: dresden
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
377
378
379
380
381
382
383
384
385
386

387
388
389
390
391
392
393
...
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
...
603
604
605
606
607
608
609

610
611
612
613
614
615
616
namespace eval config {
    set aliases {}
    set filters {};             # registered filters
    set commands {};            # registered interceptors

    proc init {filename} {
        set myname $::argv0
        if {[file exists $filename] && [file mtime $filename] > [file mtime $myname]} {
        #if {[file exists $filename] } {}
	    # an existing config file is used only if it is _newer_ than the
	    # running `fsl' file. otherwise the config file is (re)created
	    # since it's definition in `config::defaults' might have changed.
	    # this makes it probable that changes to this script become
	    # automatically active for other users (as long as they don't happen
	    # to manually modify there config files frequently ...)

................................................................................
        dict set config::commands $command $fn
    }
}

proc intercept {params} {
    set command [first $params]
    if {[interceptor? $command]} {
        return [apply [dict get $config::commands $command] $params]
    }
    return $params
}

# --( Command triggers )------------------------------------------------

proc prefixes {xs {start 0}} {
................................................................................
interceptor ali:aliases {
    puts "Currently defined expansions:"
    dict for {alias expansion} $config::aliases {
        puts [format "%10s -> %s" $alias $expansion]
    }
}

interceptor df {
   # ----------------------------------------------------------------------
   # a first stab at getting relative revision numbers working with `diff'.
   # should be called as `fsl df -r n' or `fsl df -r n:m' where `n, m' are
   # counting from 0 (initial checkin). This call which is 
   # be mapped to 
   #
   # fsl di -r sha1_n --to sha1_m
   #
   # where `sha1_n, sha1_m' are the sha1 hashes of the respective checkins.
   # further arguments to `diff' are passed through unmodified (hopefully).
   # ----------------------------------------------------------------------
   set hash2num [computeRevnums {}]
   set dim [dict size $hash2num]

................................................................................
   # strip the square brackets around the hash value:
   dict for {key val} $hash2num {
      regexp {[[:alnum:]]+} $key sha1
      dict set num2hash [expr {$dim - $val}] $sha1
   }

   # modification of the `params' list is performed in place and step by
   # step. we use `di' instead of `diff' since only the former triggers the
   # `diff' filter:
   set params [lreplace $params  0 0 di]


   # extract the revison number information from `params'. the case where the
   # blank between `-r' and `n:m' is ommitted is handled, too:
   set cnt 0
   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}
   foreach word $params {
      set rgx {^\-r} 
................................................................................
   foreach word $from$to {
      set idx [expr $flagpos + $cnt]
      set params [linsert $params $idx $word]
      incr cnt
   }
   set params [lreplace $params $flagpos $flagpos]

   puts "executing `fossil $params'"
   return $params
}

proc unwrapTimeline records {
#-----------------------------------------------------------------------
# unwrap `fossil timeline' output, putting each checkin on a single
# line. expected input: currently, a list of \n terminated lines.
................................................................................
    #if `true' generate some noise:
    set debug false

    set candidate [first $args]; # candidate for expansion

    # Alias expansion and command interception:
    set params [intercept [expand $args]]

    if {[empty? $params]} {
        return 0;                # params cleared, no need to run fossil
    }
    set command [first $params]; # expanded candidate

    # Prepare filters:
    set chain [chain_for $candidate]







|
|







 







|







 







|


|



|







 







|

|
>







 







|







 







>







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
...
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
...
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
...
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
...
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
namespace eval config {
    set aliases {}
    set filters {};             # registered filters
    set commands {};            # registered interceptors

    proc init {filename} {
        set myname $::argv0
        #if {[file exists $filename] && [file mtime $filename] > [file mtime $myname]} {}
        if {[file exists $filename] } {
	    # an existing config file is used only if it is _newer_ than the
	    # running `fsl' file. otherwise the config file is (re)created
	    # since it's definition in `config::defaults' might have changed.
	    # this makes it probable that changes to this script become
	    # automatically active for other users (as long as they don't happen
	    # to manually modify there config files frequently ...)

................................................................................
        dict set config::commands $command $fn
    }
}

proc intercept {params} {
    set command [first $params]
    if {[interceptor? $command]} {
        set params [apply [dict get $config::commands $command] $params]
    }
    return $params
}

# --( Command triggers )------------------------------------------------

proc prefixes {xs {start 0}} {
................................................................................
interceptor ali:aliases {
    puts "Currently defined expansions:"
    dict for {alias expansion} $config::aliases {
        puts [format "%10s -> %s" $alias $expansion]
    }
}

interceptor df|gdf {
   # ----------------------------------------------------------------------
   # a first stab at getting relative revision numbers working with `diff'.
   # should be called as `fsl {g}df -r n' or `fsl {g}df -r n:m' where `n, m' are
   # counting from 0 (initial checkin). This call which is 
   # be mapped to 
   #
   # fsl {g}di -r sha1_n --to sha1_m
   #
   # where `sha1_n, sha1_m' are the sha1 hashes of the respective checkins.
   # further arguments to `diff' are passed through unmodified (hopefully).
   # ----------------------------------------------------------------------
   set hash2num [computeRevnums {}]
   set dim [dict size $hash2num]

................................................................................
   # strip the square brackets around the hash value:
   dict for {key val} $hash2num {
      regexp {[[:alnum:]]+} $key sha1
      dict set num2hash [expr {$dim - $val}] $sha1
   }

   # modification of the `params' list is performed in place and step by
   # step. we use `{g}di' instead of `diff' since only the former triggers the
   # `diff' filter:
   regsub {^(g?d)f} $params {\1i} params
   if {[llength $params] == 1} {return $params}

   # extract the revison number information from `params'. the case where the
   # blank between `-r' and `n:m' is ommitted is handled, too:
   set cnt 0
   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}
   foreach word $params {
      set rgx {^\-r} 
................................................................................
   foreach word $from$to {
      set idx [expr $flagpos + $cnt]
      set params [linsert $params $idx $word]
      incr cnt
   }
   set params [lreplace $params $flagpos $flagpos]

   #puts "executing `fossil $params'"
   return $params
}

proc unwrapTimeline records {
#-----------------------------------------------------------------------
# unwrap `fossil timeline' output, putting each checkin on a single
# line. expected input: currently, a list of \n terminated lines.
................................................................................
    #if `true' generate some noise:
    set debug false

    set candidate [first $args]; # candidate for expansion

    # Alias expansion and command interception:
    set params [intercept [expand $args]]
    ###puts "final pars: $params"
    if {[empty? $params]} {
        return 0;                # params cleared, no need to run fossil
    }
    set command [first $params]; # expanded candidate

    # Prepare filters:
    set chain [chain_for $candidate]