(use posix ssax sxpath sxpath-lolevel files) (define (usage code) (print #<#EOF usage: svn-update-meta -h -help Show this message svn-update-meta will ask Subversion for all files that are managed by it and put those in the meta-file's FILES entry. Files that are unversioned are ignored. EOF ) (exit code)) (define (call-with-input-pipe* cmd proc) (let* ([p (open-input-pipe cmd)] [res (proc p)]) (unless (zero? (close-input-pipe p)) (error "Got an error while executing command " cmd)) res)) (define (svn-xml cmd) (call-with-input-pipe* cmd (lambda (i) (ssax:xml->sxml i '())))) (define (ensure-meta-file-exists!) (let* ((metas (glob "*.meta"))) (cond ((null? metas) (fprintf (current-error-port) "Error: No meta-file found! Please create one first~%") (exit 1)) ((> (length metas) 1) (fprintf (current-error-port) "Error: ~A meta files found. Can only deal with one!~%" (length metas)) (exit 1)) (else #t)))) (define (valid-meta-data? port) (handle-exceptions exn #f (let ((meta (read-file port))) (and (= 1 (length meta)) (list? (car meta)) (>= 1 (length (filter (lambda (e) (eq? 'files (car e))) (car meta)))))))) (define (update-meta! files-list) (let* ((files-list (sort files-list string (string-length arg) 2) (let ((sos (string->list (substring arg 1)))) (if (null? (lset-intersection eq? *short-options* sos)) (loop (append (map (cut string #\- <>) sos) (cdr args))) (usage 1))) (usage 1))) (else (usage 1))))))) (main (command-line-arguments))