| 136 | | ;;================================================= |
| 137 | | ;; parse svn log |
| 138 | | ;; |
| 139 | | ;; |
| 140 | | ;; result format: |
| 141 | | ;; ( |
| 142 | | ;; revision alist |
| 143 | | ;; (154 ( (user . kiyoka) (date . <date>-value) (date-str . "2007-09-25T12:54:09.955196Z"))) |
| 144 | | ;; (153 ( (user . kiyoka) (date . <date>-value) (date-str . "2007-09-25T12:19:35.838490Z"))) |
| 145 | | ;; . |
| 146 | | ;; . |
| 147 | | ;; ) |
| 148 | | (define (oldtype:parse-log logfile) |
| 149 | | (let1 sxml |
| 150 | | (with-input-from-file logfile |
| 151 | | (lambda () |
| 152 | | (ssax:xml->sxml (current-input-port) '()))) |
| 153 | | |
| 154 | | (map |
| 155 | | (lambda (x) |
| 156 | | `( |
| 157 | | ,(string->number (first x)) |
| 158 | | ( |
| 159 | | (user . ,(string->symbol (second x))) |
| 160 | | (date . ,(oldtype:date-string->date-alist (third x))) |
| 161 | | (date-str . ,(third x))))) |
| 162 | | (zip |
| 163 | | ((sxpath "//log/logentry/@revision/text()") sxml) |
| 164 | | ((sxpath "//log/logentry/author/text()") sxml) |
| 165 | | ((sxpath "//log/logentry/date/text()") sxml))))) |
| 166 | | |
| 167 | | ;; |
| 168 | | ;; result format: |
| 169 | | ;; ( |
| 170 | | ;; ( |
| 171 | | ;; revision aliat |
| 172 | | ;; (140 ((user . kiyoka) (str . "* What is OldType"))) |
| 173 | | ;; (142 ((user . kiyoka) (str . "- [[OldType]]"))) |
| 174 | | ;; (143 ((user . kiyoka) (str . "- OldType development blog is [[@username:blog]]"))) |
| 175 | | ;; . |
| 176 | | ;; . |
| 177 | | ;; . |
| 178 | | ;; ) |
| 179 | | ;; ) |
| 180 | | (define (oldtype:parse-annotate annfile) |
| 181 | | (reverse |
| 182 | | (with-input-from-file annfile |
| 183 | | (lambda () |
| 184 | | (let loop ((lst '())) |
| 185 | | (cond |
| 186 | | ((eof-object? (peek-char (current-input-port))) |
| 187 | | lst) |
| 188 | | (else |
| 189 | | (let ( |
| 190 | | (rev (string-trim-both (read-string 6))) |
| 191 | | (user (string-trim-both (read-string 12))) |
| 192 | | (text (next-token '() '(#\newline *eof*))) |
| 193 | | (_ (read-char))) |
| 194 | | (loop (cons `( |
| 195 | | ,(string->number rev) |
| 196 | | ( |
| 197 | | (user . ,(string->symbol user)) |
| 198 | | (str . ,text))) |
| 199 | | lst)))))))))) |
| 200 | | |