Fossil Wrapper

Check-in [838bbe2a57]
Login

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

Overview
Comment:simplified and improved `df' interceptor.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: 838bbe2a575e7e42c553234f1269b72a9c03fa67
User & Date: j 2013-07-27 16:22:32
Context
2013-07-27
16:46
minor. check-in: abdb439351 user: j tags: dresden
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
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

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


418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
        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]

   # exchange keys and values in the above dictonary 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
   }

   # 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} 
      if {[regexp $rgx $word]} {
         set flagpos $cnt
         set rgx $rgx$rgxrevnum
         if {[regexp $rgx $word]} {
            set noblank 1 
         } else {set noblank 0}
         break
      }
      incr cnt
   }
   if {$noblank} {
      set dum [lindex $params $flagpos]
      set numbers [string trimleft $dum -r]
   } else {
      set idx [expr $flagpos + 1]
      set numbers [lindex $params $idx] 
      # remove the `numbers' field from `params':
      set params [lreplace $params $idx $idx]
   }
   set revs [split $numbers :]

   # translate rev. numbers to sha1 hashes and construct the 
   # required `diff' arguments:


   set to {}
   set cnt 0
   set fromto [list from to]
   foreach rev $revs {
      set which [lindex $fromto $cnt] 
      # this evals in turn to define variables `from' and `to', respectively,
      # which contain the respective `diff' arguments.
      set $which " --$which [dict get $num2hash $rev]"
      incr cnt
   } 

   # insert the canonical `diff' arguments/options into the `params' list
   # after `-r' (whose position is given by `flagpos') and finally remove the
   # `-r'.

   set cnt 1
   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







|



|














|
|
<

<

|
|
<

<
|
<
|
|
<
<
<
<
|
<
<
<
|
<
<
<
|
<
<
|
<
<


>
>




|

|
|



<
<
<
|
<
|
<
<
<
<
<
<







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
418
419
420
        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]

   # exchange keys and values in the above dictonary 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
   }

   # map this interceptor command to `fossil (g)diff'. actually, we use `di'
   # instead of `diff' since only the former will trigger the `diff' filter:

   regsub {^(g?d)f} $params {\1i} params


   # extract the revison number information from `params'. contrary to
   # `fossil' it is acceptable to omit blanks between `-r' and `n:m':

   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}

   set rgx { -r} 

   set rgx { \-r[[:blank:]]*}
   set rgx $rgx$rgxrevnum








   # without `-r' argument we return `params' as is:



   if {![regexp $rgx $params revarg]} {return $params}





   # translate rev. numbers to sha1 hashes and construct the 
   # required `diff' arguments:
   regexp $rgxrevnum $revarg numbers
   set revs [split $numbers :]
   set to {}
   set cnt 0
   set fromto [list from to]
   foreach rev $revs {
      set optarg [lindex $fromto $cnt] 
      # this evals in turn to define variables `from' and `to', respectively,
      # which contain the respective `diff' arguments:
      set $optarg " --$optarg [dict get $num2hash $rev]"
      incr cnt
   } 




   #replace `-r n:m' by the constructed `diff' arguments: 

   regsub $revarg $params $from$to params






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

proc unwrapTimeline records {
#-----------------------------------------------------------------------
# unwrap `fossil timeline' output, putting each checkin on a single