Fossil Wrapper

Check-in [da5f1a3467]
Login

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

Overview
Comment:tidy up of `reformTimeline' plus small fixes.
Timelines: family | ancestors | descendants | both | dresden
Files: files | file ages | folders
SHA1: da5f1a34677f7eb19ad9a9c707cdde7ff373c176
User & Date: j 2013-07-26 14:52:15
Context
2013-07-26
14:56
different colour scheme for file status information. check-in: 1767aecf48 user: j tags: dresden
14:52
tidy up of `reformTimeline' plus small fixes. check-in: da5f1a3467 user: j tags: dresden
12:19
marginal. check-in: c51edf73ff user: j tags: dresden
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to fsl.

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
448
449
450
451
452
453

454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
      lappend out "$record"
   }
   return $out
}

proc reformTimeline {records revnums} {
# --------------------------------------------------------
# expected input: list of timeline entries as provided by
# `unwrapTimeline', i.e. either "date lines" or "commit"
# lines containing the whole commit including the commit
# message possibly followed by file status lines (if `-showfiles' is used).
#
# output: a list of newline terminated lines where the user/tags
# information is appended to the line containing the time and SHA1 
# hash and the commit message is put on the following line(s) using an 
# indent string `indent' and a line length `maxlen'.
# --------------------------------------------------------


   #these parameters should be user settable:
   set maxlen 78
   set indent {........ }
   set indent {         }


   set numrev {}
   set isAppended 0
   set out {}
   set buf ""
   set usertag ""
   set rgxdate {^=== [0-9-]+ ===$}
   set rgxtime {^\d\d:\d\d:\d\d}
   set rgxrev {\[([a-f\d]{10})([^\]]*)\]}
   set rgxuser {\(user: .*\)}


   set maxrev [dict size $revnums]

   foreach record $records {
      # first get rid of the record/line terminating newline:
      set record "[string trimright $record]"

      if {[regexp $rgxdate $record]} {
         # the `date' information is extracted and then prepended to the suitable checkins
         set date [regsub {(=== )(.*)( ===)} $record {\2}]
      } elseif {[regexp $rgxrev $record]} {
         # this line contains the checkin message:
         regexp $rgxtime $record time
         regexp $rgxrev $record rev
         regexp $rgxuser $record usertag
         set numrev [expr { $maxrev - [dict get $revnums $rev] }]:


         regsub $rgxuser $record "" record
         regsub $time    $record "" record
         regsub $rgxrev  $record "" record
         set record "[string trim $record]"

         ###### patch ######
         #lappend out $record
         lappend out "\n$date $time $numrev$rev $record $usertag"
         ###### the following line wrapping does not work anymore for current format. delete or adjust....
         continue    
         ###### patch ######

         set message [string trim $record]
         set words [split $message]
         set line $indent[lindex $words 0]
         set len [string length $line]

         set words [lreplace $words 0 0]
         set wrdnum [llength $words]
         set wrdcnt 0
         foreach word $words {
            incr wrdcnt
            set wrdlen [string length $word]
            set len [expr {$len + 1 + $wrdlen}]
            if {$len <= $maxlen} {
               set line "$line $word"
               set isAppended 0
            } else {
               lappend out $line\n
               set line $indent$word
               set len [string length $line]
               if {$wrdcnt < $wrdnum} {
                  set isAppended 1
               } else {set isAppended 0} ;#since the loop stops _now_...
            }
         }
         if {$isAppended == 0} {lappend out $line}
      } else {
         # should be a file status line as delivered by `-showfiles' (since
         # it is neither matching `rgxdate' nor `rgxrev'). append after
         # stripping white space and separate by appending a full stop.
         lappend out " [string trim $record]."
      }
   }







|
|
|
|

|
|
|
|
<
|
>
|
|
|
|
>


<

<





|
>



|
|




|
|

|

<

>
|
|
|
<

<
<
<
<
|
<
|
<
<
<
<

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







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
448
449
450
451

452
453
454
455
456

457




458

459




460




461






462





463

464
465
466
467
468
469
470
471
      lappend out "$record"
   }
   return $out
}

proc reformTimeline {records revnums} {
# --------------------------------------------------------
# expected input: list of linefeed terminated lines as provided by
# `unwrapTimeline', i.e. date lines, commit lines containing the whole
# commit message, and lines containg optional file status information (if
# `-showfiles' is used).
#
# output: a list of the following elements 
#   -- single line checkin information (all but first preceded by linefeed)
#   -- status information lines (one per file)
#   -- a single trailing linefeed

#
# not that in the output list the linefeeds are "shifted"
# to the front of the timeline entries and that status information
# is kept in separate list entries. this allows to use the
# colorizers without modification while still getting the
# printed output to the form "one line per checkin".
# --------------------------------------------------------

   set numrev {}

   set out {}

   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
         set date [regsub {(=== )(.*)( ===)} $record {\2}]
      } elseif {[regexp $rgxrev $record]} { # this line contains a checkin message
         # extract relevant fields:
         regexp $rgxtime $record time
         regexp $rgxrev  $record rev
         regexp $rgxuser $record usertag


         # 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
         # it is neither matching `rgxdate' nor `rgxrev'). append after
         # stripping white space and separate by appending a full stop.
         lappend out " [string trim $record]."
      }
   }
628
629
630
631
632
633
634

635

636
637
638

639
640
641
642
643
644
645
646
647
648
649
          # through `fancy_timeline'. think ...)
          if {!$catmode} {
             set lines [unwrapTimeline $lines]
          }
       }
       foreach line $lines {
          if {$debug == true} {

             puts -nonewline "IN: $line"

             puts -nonewline "OU: "
          }
          filter_with $chain "$line"

       }
    }

    log_user $prior_log;              # revert Expect settings
    return [spawned_errno $spawn_id]; # return with fossil error code
}

# --( Entry )-----------------------------------------------------------

config::init ~/.fslrc
exit [fossil {*}$argv]







>
|
>
|
|
|
>











602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
          # through `fancy_timeline'. think ...)
          if {!$catmode} {
             set lines [unwrapTimeline $lines]
          }
       }
       foreach line $lines {
          if {$debug == true} {
             puts "IN: >$line<"
             puts -nonewline "OU: >"
             filter_with $chain "$line"
             puts "<"
          } else {
             filter_with $chain "$line"
          }
       }
    }

    log_user $prior_log;              # revert Expect settings
    return [spawned_errno $spawn_id]; # return with fossil error code
}

# --( Entry )-----------------------------------------------------------

config::init ~/.fslrc
exit [fossil {*}$argv]