Ignore:
Timestamp:
07/30/08 04:27:29 (12 years ago)
Author:
Ivan Raikov
Message:

Switched to using versions library.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • release/3/egg-post-commit/trunk/egg-post-commit.scm

    r11456 r11474  
    1414 utils srfi-1 srfi-13 srfi-18 srfi-69 posix regex
    1515 ftp http-client format-modular uri base64 svn-client
    16  srfi-40 stream-ext html-stream stream-wiki )
     16 srfi-40 stream-ext html-stream stream-wiki versions )
    1717
    1818(define-constant +call/cc-ftp-url+ "www.call-with-current-continuation.org")
     
    206206    (ftp:disconnect ftp) ) )
    207207
    208 ; Convert a string with a version (such as "1.22.0") to a list of the
    209 ; numbers (such as (1 22 0)). If one of the version components cannot
    210 ; be converted to a number, then it is kept as a string.
    211 
    212 (define (version-string->numbers string)
    213   (map (lambda (x) (or (string->number x) (->string x)))
    214        (string-split string ".")))
    215 
    216 ; Given two lists with numbers corresponding to a software version (as returned
    217 ; by version-string->numbers), check if the first is greater than the second.
    218 
    219 (define (version-numbers> a b)
    220   (match (list a b)
    221          ((() _)   #f)
    222          ((_  ())  #t)
    223          (((a1 . an) (b1 . bn))
    224           (cond ((and (number? a1) (number? b1))
    225                  (cond ((> a1 b1) #t) ((= a1 b1) (version-numbers> an bn)) (else #f)))
    226                 ((and (string? a1) (string? b1)) 
    227                  (cond ((string> a1 b1) #t) ((string= a1 b1) (version-numbers> an bn)) (else #f)))
    228                 (else (version-numbers> (cons (->string a1) an) (cons (->string b1) bn)))))
    229          (else (error 'version-numbers> "invalid revisions: " a b))))
    230 
    231208; tags-dir is a directory with files named as software versions (eg. "1.2.29",
    232209; "1.3").  Returns the name of the file corresponding to the greatest software
     
    236213  (fold
    237214    (lambda (a pick)
    238       (let ((a-nums (version-string->numbers a)))
    239         (if (or (not pick) (version-numbers> a-nums (version-string->numbers pick))) a pick)))
     215      (let ((a-nums (string->version a)))
     216        (if (or (not pick) (version>? a-nums (string->version pick))) a pick)))
    240217    #f
    241218    (directory tags-dir)))
Note: See TracChangeset for help on using the changeset viewer.