Changeset 12100


Ignore:
Timestamp:
May 20, 2009, 12:07:42 PM (10 years ago)
Author:
gb
Message:

Don't use WITH-OUTPUT-TO-STRING when calling out to svn/svnversion;
just make a STRING-OUTPUT-STREAM so LOCAL-SVN-REVISION and
SVN-INFO-COMPONENT return NIL on failure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/lib/misc.lisp

    r12094 r12100  
    819819(defun svn-info-component (component)
    820820  (let* ((component-length (length component)))
    821   (with-output-to-string (s)
    822     (multiple-value-bind (status exit-code)
    823         (external-process-status
    824          (run-program "svn"  (list "info" (native-translated-namestring "ccl:")):output s))
    825       (when (and (eq :exited status) (zerop exit-code))
    826         (with-input-from-string (output (get-output-stream-string s))
     821    (let* ((s (make-string-output-stream)))
     822      (multiple-value-bind (status exit-code)
     823          (external-process-status
     824           (run-program "svn"  (list "info" (native-translated-namestring "ccl:")) :output s :error :output))
     825        (when (and (eq :exited status) (zerop exit-code))
     826          (with-input-from-string (output (get-output-stream-string s))
    827827            (do* ((line (read-line output nil nil) (read-line output nil nil)))
    828828                 ((null line))
     
    830830                         (string= component line :end2 component-length))
    831831                (return-from svn-info-component
    832                   (string-trim " " (subseq line component-length)))))))))))
     832                  (string-trim " " (subseq line component-length)))))))))
     833    nil))
    833834
    834835(defun svn-url () (svn-info-component "URL:"))
     
    863864                         
    864865(defun local-svn-revision ()
    865   (or
    866    ;; svn2cvs uses a .svnrev file to sync CVS and SVN; if present,
    867    ;; it contains the svn revision in decimal.
    868    (with-open-file (f "ccl:\\.svnrev" :direction :input :if-does-not-exist nil)
    869      (when f (read f)))
    870    (with-output-to-string (s)
    871      (let* ((root (native-translated-namestring "ccl:")))
    872        (when *use-cygwin-svn*
    873          (setq root (cygpath root)))
    874        (multiple-value-bind (status exit-code)
     866  (let* ((s (make-string-output-stream))
     867          (root (native-translated-namestring "ccl:")))
     868     (when *use-cygwin-svn*
     869       (setq root (cygpath root)))
     870     (multiple-value-bind (status exit-code)
    875871           (external-process-status
    876             (run-program "svnversion"  (list  (native-translated-namestring "ccl:") (or (svn-url) "")):output s))
     872            (run-program "svnversion"  (list  (native-translated-namestring "ccl:") (or (svn-url) "")) :output s :error :output))
    877873         (when (and (eq :exited status) (zerop exit-code))
    878874           (with-input-from-string (output (get-output-stream-string s))
    879875             (let* ((line (read-line output nil nil)))
    880876               (when (and line (parse-integer line :junk-allowed t) )
    881                  (return-from local-svn-revision line))))))))))
     877                 (return-from local-svn-revision line))))))
     878     nil))
    882879
    883880
Note: See TracChangeset for help on using the changeset viewer.