Fossil Wrapper

Check-in [796166346a]
Login

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

Overview
Comment:the `revnums' dictionary no longer uses reverse revision numbers as keys.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: 796166346a2e6af62572cc8d40e5e75b811a59ec
User & Date: j 2013-07-28 18:34:15
Context
2013-07-29
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
18:20
simplied `computeRevnums'. check-in: d9327358eb user: j tags: dresden
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
...
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
...
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
448
449
450
451
452
...
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
   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 ""
   set maxrev [dict size $revnums]

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

         # 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 [expr { $maxrev - [dict get $revnums $rev] }]:

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

         lappend out "$prepend$date $time $numrev$rev $record $usertag"
      } else {
         # should be a file status line as delivered by `-showfiles' (since
................................................................................
      }
   }
   return [lappend out \n]
}

proc computeRevnums {params} {
#-----------------------------------------------------------------------
# generate a dictionary of SHA1 keys vs. "reverse" revision numbers 
# (last checkin = 1)
#-----------------------------------------------------------------------
   set huge    1000000        ;# should not be reached by most projects ...
   set revcnt  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 revcnt
         regexp $rgxrev $line rev
         dict set revnums $rev [expr {$revcnt}]
      }
   } 
   return $revnums
}

proc preparse argv {
# -------------------------------------------------------------------
................................................................................
   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}
   set rgx $rgx$rgxrevnum

   # without `-r' argument we can return already:
   if {![regexp $rgx $params revarg]} {return $params}

   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
   }

   # translate rev. numbers to sha1 hashes and construct the 
   # required `diff' arguments:
   regexp $rgxrevnum $revarg numbers
   set revs [split $numbers :]
   set to {}







<







 







|







 







|
<

|

>









>
>
>




|







 







<





|







381
382
383
384
385
386
387

388
389
390
391
392
393
394
...
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
...
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
448
449
450
451
452
453
454
...
569
570
571
572
573
574
575

576
577
578
579
580
581
582
583
584
585
586
587
588
   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
................................................................................

         # 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"}

         lappend out "$prepend$date $time $numrev$rev $record $usertag"
      } else {
         # should be a file status line as delivered by `-showfiles' (since
................................................................................
      }
   }
   return [lappend out \n]
}

proc computeRevnums {params} {
#-----------------------------------------------------------------------
# generate a dictionary of SHA1 keys vs. revision numbers 

#-----------------------------------------------------------------------
   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 }
   }
   foreach line $lines {
      if {[regexp $rgxtime $line]} {
         incr revcnt
         regexp $rgxrev $line rev
         dict set revnums $rev [expr {$maxrev - $revcnt}]
      }
   } 
   return $revnums
}

proc preparse argv {
# -------------------------------------------------------------------
................................................................................
   set rgxrevnum {[[:digit:]]+(:[[:digit:]]+)?}
   set rgx $rgx$rgxrevnum

   # without `-r' argument we can return already:
   if {![regexp $rgx $params revarg]} {return $params}

   set hash2num [computeRevnums {}]


   # 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 $val $sha1
   }

   # translate rev. numbers to sha1 hashes and construct the 
   # required `diff' arguments:
   regexp $rgxrevnum $revarg numbers
   set revs [split $numbers :]
   set to {}