Fossil Wrapper

Check-in [132ed5e030]
Login

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

Overview
Comment:new interceptor `df' allowing relative svn/hg-style revison numbers during diffs. alpha state.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: 132ed5e03024c6f2bccfba6345726f2c4e05952c
User & Date: j 2013-07-27 09:59:53
Context
2013-07-27
12:04
improved `df' interceptor. check-in: 1f0b2f3546 user: j tags: dresden
09:59
new interceptor `df' allowing relative svn/hg-style revison numbers during diffs. alpha state. check-in: 132ed5e030 user: j tags: dresden
2013-07-26
14:56
different colour scheme for file status information. check-in: 1767aecf48 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
...
350
351
352
353
354
355
356





















































357
358
359
360
361
362
363
...
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
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]} {

	    # 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 ...)

................................................................................

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






















































proc unwrapTimeline records {
#-----------------------------------------------------------------------
# unwrap `fossil timeline' output, putting each checkin on a single
# line. expected input: currently, a list of \n terminated lines.
# (maybe the \n should go away?). continuation lines belonging
# to the checkin message (including the trailing user/tags info)
................................................................................
            set line [string trimright $line]
         }
      }
      # we have to newline-terminate the records in order to enable
      # calls to `unwrapTimeline' even if `reformTimeline' is _not_
      # called subsequently.

      set record "[string trimright $record] \n"

      # temporary patch (better strategy needed, probably). eliminate
      # a blank in the used `regsub' pattern, which is assumed(!) to be caused by
      # `fossil' treating `-' as word boundary (there might be other instances,
      # actually, in the commit message itself):
      regsub -all {([[:alnum:]])- ([[:alnum:]])} $record \\1-\\2 record

      lappend out "$record"
   }
   return $out
}

proc reformTimeline {records revnums} {
# --------------------------------------------------------
# expected input: list of linefeed terminated lines as provided by







|
>







 







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







 







|







|







8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
...
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
...
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
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 ...)

................................................................................

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.
   #

   set hash2num [computeRevnums {}]
   set dim [dict size $hash2num]

   #revert the above dictonary in order to get the mapping from numbers to sha1.
   #at the same time, strip the square brackets around the hash value.
   dict for {key val} $hash2num {
      regexp {[[:alnum:]]+} $key sha1
      dict set num2hash [expr {$dim - $val}] $sha1
   }

   set parstring [concat $params]

   # first introduce a blank between `-r' and revnum in case it was forgotten...
   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}
   regsub "\\-r($rgxrevnum)" $parstring {-r \1} parstring

   #extract the full match of the `df' command as well as the revnums
   set rgx {df[ ]+\-r[ ]+([[:digit:]]+(:[[:digit:]]+)?)}
   regexp $rgx $parstring fullmatch numbers
   set revs [split $numbers :]
   set fromto [list from to]
   set to {}
   set cnt 0
   
   #translate to sha1 hashes and prepend with correct `diff' options
   foreach rev $revs {
      set which [lindex $fromto $cnt] 
      set $which " --$which [dict get $num2hash $rev]"
      incr cnt
   } 
   #we use `di' instead of `diff' since only the former triggers the `diff' filter
   set replace "di $from$to"
   regsub $fullmatch $parstring $replace parstring

   #create the modified `params' list
   regsub -all {[[:blank:]]+} $parstring " " parstring
   set params [split $parstring]

   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.
# (maybe the \n should go away?). continuation lines belonging
# to the checkin message (including the trailing user/tags info)
................................................................................
            set line [string trimright $line]
         }
      }
      # we have to newline-terminate the records in order to enable
      # calls to `unwrapTimeline' even if `reformTimeline' is _not_
      # called subsequently.

      set record "[string trimright $record]\n"

      # temporary patch (better strategy needed, probably). eliminate
      # a blank in the used `regsub' pattern, which is assumed(!) to be caused by
      # `fossil' treating `-' as word boundary (there might be other instances,
      # actually, in the commit message itself):
      regsub -all {([[:alnum:]])- ([[:alnum:]])} $record \\1-\\2 record

      lappend out $record
   }
   return $out
}

proc reformTimeline {records revnums} {
# --------------------------------------------------------
# expected input: list of linefeed terminated lines as provided by