Fossil Wrapper

Check-in [abdb439351]
Login

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

Overview
Comment:minor.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: abdb4393517bddfcc3b1e43406c21f6c87cd3a39
User & Date: j 2013-07-27 16:46:30
Context
2013-07-27
19:56
added some comments as a personal memo. check-in: c0a6e8052f user: j tags: dresden
16:46
minor. check-in: abdb439351 user: j tags: dresden
16:22
simplified and improved `df' interceptor. check-in: 838bbe2a57 user: j tags: dresden
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

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
...
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
    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]

   # 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 {}
................................................................................
      # 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
# line. expected input: currently, a list of \n terminated lines.







|
|
|
>
>
>
|
>
|

<
>


<
|



|


|







 







|







 







<







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
...
410
411
412
413
414
415
416

417
418
419
420
421
422
423
    puts "Currently defined expansions:"
    dict for {alias expansion} $config::aliases {
        puts [format "%10s -> %s" $alias $expansion]
    }
}

interceptor df|gdf {
   # ------------------------------------------------------------------------
   # drop-in replacement for `fsl (g)di' using hg/svn-style relative revision
   # numbers. call as
   #
   # fsl (g)df ... -r n(:m) ...
   #
   # where n, m are counting from 0 (initial checkin) and `...' denotes
   # further `diff' arguments.
   # This call is mapped to
   #

   # fsl (g)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]

   # exchange keys and values in the above dictonary. at the same time,
   # strip the square brackets around the hash value:
   dict for {key val} $hash2num {
      regexp {[a-f\d]{10}} $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 can return already:
   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 {}
................................................................................
      # 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

   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.