Megatest

Check-in [f5d0f037cc]
Login
Overview
Comment:Added nice report generator (thanks to excellent suggestion from Steve Osugi)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | v1.64
Files: files | file ages | folders
SHA1: f5d0f037cc1fe756823044b7b8ea09ae56695976
User & Date: matt on 2017-04-07 23:41:50
Other Links: branch diff | manifest | tags
Context
2017-04-07
23:52
Want report to be newest at top (similar to fossil timeline). check-in: 8e7c86ba1f user: matt tags: v1.64
23:41
Added nice report generator (thanks to excellent suggestion from Steve Osugi) check-in: f5d0f037cc user: matt tags: v1.64
2017-04-06
11:45
Consolidating some stuff back on v1.64 check-in: a81649fabf user: mrwellan tags: v1.64, v1.6403
Changes

Added utils/fslrept.scm version [a0c39060ae].





















































































































































































>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90

(use json fmt posix)

;; abstract out the alist-ref a bit and re-order the params
;;
(define-inline (aref dat key)
  (alist-ref key dat equal?))

;; convert silly vectors in json data to nice clean alist
;;
(define (to-alist inlst)
  (handle-exceptions
      exn
      (begin
	(print-call-chain)
	(print inlst))
    (cond
     ((proper-list? inlst) (map to-alist inlst))
     ((or (list? inlst) ;; it is a pair
	  (pair? inlst))   (cons (car inlst) (to-alist (cdr inlst))))
     ((vector? inlst)      (to-alist (vector->list inlst)))
     (else                 inlst))))

;; columnar line printer
;;
(define (print-rows inlist)
  (define (print-line x)
    (cat (car x)
	 (space-to 10)(pad/left 3 (cadr x))
	 (space-to 25)(pad/left 3 (caddr x))
	 ))
  (fmt #t (pad-char #\  (fmt-join/suffix print-line inlist nl))))

;; from the command line pull branch, start-tag, end-tag
;;
(define (extract-history branch start-tag end-tag)
  (let* ((data       (to-alist  ;; get all the data
		      (with-input-from-pipe
			  "fossil json timeline checkin -n 0"
			json-read)))
	 (timeline   (aref (aref data "payload") "timeline")) ;; extract the timeline alists
	 (start-flag #f)
	 (end-flag   #f))
    ;; now we have all needed data as a list of alists in time order, extract the
    ;; messages for given branch starting at start-tag and ending at end-tag
    (filter
     (lambda (x) x)
     (map
      (lambda (entry)
	(let ((tags (aref entry "tags")))
	  (if (or (not tags) ;; eh?
		  (not (list? tags)))
	      (begin
		;; (with-output-to-port (current-error-port)
		;;   (lambda ()
		;;     (print "ERROR: bad entry. tags: " tags)))
		#f)
	      (let* ((btag (car tags))  ;; first tag is the primary branch
		     (tags (cdr tags))  ;; remainder are actual tags
		     (cmt  (aref entry "comment"))
		     (usr  (aref entry "user"))
		     (tms  (aref entry "timestamp")))
		;; (print "btag: " btag " tags: " tags " usr: " usr)
		(if (equal? btag branch) ;; we are on the branch
		    (begin
		      (if (member start-tag tags)(set! start-flag #t))
		      (let ((res (if (and start-flag
					  (not end-flag))
				     `(,usr
				       ,(time->string (seconds->local-time tms) "WW%U.%w %H:%M")
				       ,cmt)
				     #f)))
			(if (member end-tag tags)(set! end-flag #t))
			res))
		    #f)))))
      (reverse timeline)))))

(define (process-fossil branch start-tag end-tag)
  (print-rows
   (extract-history branch start-tag end-tag)))

;; process command line args and dispatch the call to fossil processing
;;
(if (and (> (length (argv)) 3)
	 (< (length (argv)) 5))
    (apply process-fossil (cdr (argv)))
    (begin ;; no inputs, exit with message
      (print "Usage: fslrept branch start-tag end-tag")
      ))