Changeset 15370 in project


Ignore:
Timestamp:
08/08/09 16:01:03 (10 years ago)
Author:
sjamaan
Message:

Split out subversion implementation to make it easier to plug in something else

Location:
release/4/qwiki/trunk
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • release/4/qwiki/trunk/qwiki.meta

    r15367 r15370  
    77 (doc-from-wiki)
    88 (hidden)
    9  (files "qwiki.scm" "qwiki-sxml" "qwiki.setup"))
     9 (files "qwiki.scm" "qwiki-sxml" "qwiki-svn" "qwiki.setup"))
  • release/4/qwiki/trunk/qwiki.scm

    r15369 r15370  
    3535
    3636(module qwiki
    37   (qwiki-docroot qwiki-repos-uri qwiki-repos-username qwiki-repos-password
    38    qwiki-source-path qwiki-base-uri qwiki-transformation-steps
     37  (qwiki-docroot qwiki-source-path qwiki-base-uri qwiki-transformation-steps
    3938   qwiki-handler qwiki-show qwiki-edit qwiki-history)
    4039
    4140(import chicken scheme)
    42 (use extras regex files ports posix data-structures srfi-1 srfi-13 srfi-18
    43      intarweb uri-common spiffy sxml-transforms svn-client
    44      wiki-parse qwiki-sxml doctype sxml-fu sxml-shortcuts)
     41(use extras files posix ports data-structures srfi-1 srfi-13
     42     intarweb uri-common spiffy sxml-transforms
     43     wiki-parse qwiki-sxml doctype sxml-fu sxml-shortcuts
     44     ;; There should be a way to parameterize the versioning implementation
     45     qwiki-svn)
    4546
    4647;; HTML files are stored here, relative to the current Spiffy docroot
    4748(define qwiki-docroot (make-parameter "/"))
    48 
    49 ;; The version control system's repos uri, username and password
    50 ;; TODO: Move this elsewhere
    51 (define qwiki-repos-uri (make-parameter #f)) ; string, not uri-reference!
    52 (define qwiki-repos-username (make-parameter "anonymous"))
    53 (define qwiki-repos-password (make-parameter ""))
    5449
    5550;; The location of the wiki source files (where a checkout will be made)
     
    9186    (create-directory (pathname-directory path) #t))
    9287  (with-output-to-file path thunk))
    93 
    94 ;; Get the history for a given file starting at rev, going back in
    95 ;; time.  If rev is #f, start at the latest revision.  If limit is not
    96 ;; specified or #f, the full history is returned.  Otherwise, a
    97 ;; maximum of that many items is returned.
    98 (define (get-history file rev #!optional limit)
    99   (let ((history '()))
    100    (svn-client-log2
    101     file (if rev (make-svn-opt-revision-number rev) svn-opt-revision-head)
    102     (make-svn-opt-revision-number 0) (or limit 0) #f #f
    103     (qwiki-repos-username) (qwiki-repos-password)
    104     (lambda (files rev author date msg)
    105       ;; What about the timezone?  Is it always GMT?  POSIX strptime
    106       ;; doesn't know about this so we may need to use srfi-19...
    107       (let* ((seconds-date (string-substitute "\\.[0-9]+.*" "" date))
    108              (date (string->time date "%Y-%m-%dT%H:%M")))
    109        (set! history (cons (list rev author date msg) history)))))
    110    (reverse history)))
    111 
    112 (define (call-with-input-revision file rev proc)
    113   (let ((filename (svn-client-cat
    114                    file (make-svn-opt-revision-number rev)
    115                    (qwiki-repos-username) (qwiki-repos-password))))
    116     (handle-exceptions exn
    117       (begin
    118         (delete-file* filename)
    119         (raise exn))
    120      (let ((result (call-with-input-file filename proc)))
    121        (delete-file* filename)
    122        result))))
    12388
    12489(define (send-content content)
     
    233198  (or (string=? name ".") (string=? name "..") (string-index name #\/)))
    234199
    235 (define (checkout-sources!)
    236   (svn-update (qwiki-repos-uri) (qwiki-source-path) svn-opt-revision-head
    237               (qwiki-repos-username) (qwiki-repos-password)))
    238 
    239 (define (update-sources!)
    240   (svn-update (qwiki-repos-uri) (qwiki-source-path) svn-opt-revision-head
    241               (qwiki-repos-username) (qwiki-repos-password)))
    242 
    243200(define (ensure-latest-sources!)
    244201  (if (not (directory-exists? (qwiki-source-path)))
    245       (checkout-sources!)
     202      (checkout-sources! (qwiki-source-path))
    246203      ;; Not sure if this should be done every freaking time - it's slow!
    247       #;(update-sources!)
     204      #;(update-sources! (qwiki-source-path))
    248205      (void)))
    249206
  • release/4/qwiki/trunk/qwiki.setup

    r15367 r15370  
    55(compile -s -O2 qwiki-sxml.import.scm)
    66
     7(compile -s -O2 qwiki-svn.scm -j qwiki-svn)
     8(compile -s -O2 qwiki-svn.import.scm)
     9
    710(install-extension
    811  'qwiki
    912  '("qwiki.so" "qwiki.import.so"
    10     "qwiki-sxml.so" "qwiki-sxml.import.so")
     13    "qwiki-sxml.so" "qwiki-sxml.import.so"
     14    "qwiki-svn.so" "qwiki-svn.import.so")
    1115  `((version 0.1)
    1216    (documentation "qwiki.html")))
Note: See TracChangeset for help on using the changeset viewer.