Changeset 9668


Ignore:
Timestamp:
Jun 3, 2008, 8:17:19 PM (11 years ago)
Author:
mikel
Message:

implemented code to support the update UI, and to ahndle error conditions that block the update from proceeding

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/source/cocoa-ide/ide-self-update.lisp

    r9667 r9668  
    156156;;; -----------------------------------------------------------------
    157157
     158(defun alert (&key
     159              (title "Alert")
     160              (message "Something happened.")
     161              (default-button "Okay")
     162              alternate-button
     163              other-button)
     164  (let ((nstitle (%make-nsstring title))
     165        (nsmessage (%make-nsstring message))
     166        (ns-default-button (%make-nsstring default-button))
     167        (ns-alternate-button (or (and alternate-button (%make-nsstring alternate-button))
     168                                 +null-ptr+))
     169        (ns-other-button (or (and other-button (%make-nsstring other-button))
     170                             +null-ptr+)))
     171    (#_NSRunAlertPanel nstitle nsmessage ns-default-button ns-alternate-button ns-other-button)
     172    (#/release nstitle)
     173    (#/release nsmessage)
     174    (#/release ns-default-button)
     175    (unless (eql ns-alternate-button +null-ptr+)
     176      (#/release ns-alternate-button))
     177    (unless (eql ns-other-button +null-ptr+)
     178      (#/release ns-other-button))))
     179
     180(defun valid-revision-number-for-svn-update? (rev)
     181  (and (stringp rev)
     182       (plusp (length rev))))
     183
     184(defun valid-repository-for-svn-update? (url)
     185  (and (stringp url)
     186       ;; TODO: examine the url to see if it makes sense
     187       ))
     188
     189(defun valid-directory-for-svn-update? (dir)
     190  (and dir
     191       (probe-file dir)
     192       (directoryp dir)
     193       (validate-svn-data-pathname (merge-pathnames ".svn/" dir))))
     194
     195(defun svn-update-ccl (&key directory repository last-revision)
     196  (cond
     197    ((not (valid-directory-for-svn-update? directory))
     198     (alert :title "Update Failed"
     199            :message (format nil "Subversion update failed. CCL directory '~A' doesn't exist, or lacks valid Subversion metadata."
     200                             directory)))
     201    ((not (valid-repository-for-svn-update? repository))
     202     (alert :title "Update Failed"
     203            :message (format nil "Subversion update failed. The supplied repository URL is invalid: '~A'"
     204                             repository)))
     205    ((not (valid-revision-number-for-svn-update? last-revision))
     206     (alert :title "Update Failed"
     207            :message (format nil "Subversion update failed. CCL found an invalid revision number for the current working copy: '~A'"
     208                             last-revision)))
     209    (t (alert :title "Update Succeeded"
     210              :message "Subversion update succeeded. Soon we will actually run the update when it succeeds."))))
     211
     212(defun run-svn-update-for-directory (dir)
     213  (let* ((svn-info (get-svn-info dir))
     214         (revision-entry (assoc "Revision" svn-info :test #'string=))
     215         (revision (and revision-entry (second revision-entry)))
     216         (url-entry (assoc "URL" svn-info :test #'string=))
     217         (url (and url-entry (second url-entry))))
     218    (svn-update-ccl :directory dir :repository url :last-revision revision)))
     219 
    158220(defun run-svn-update ()
    159   (format t "~%running svn self-update...~%")
    160   (let* ((ccl-dir (gui::find-ccl-directory))
    161          (ccl-svn-dir (merge-pathnames ".svn/" ccl-dir)))
    162     (if (validate-svn-data-pathname ccl-svn-dir)
    163         (format t "~%updating...~%")
    164         (#_NSRunInformationalAlertPanel #@"Self-update Cancelled"
    165                                         #@"Subversion self-update failed because the running Lisp's CCL directory does not appear to be under revision control (it doesn't exist, or doesn't contain a '.svn/' subdirectory)."
    166                                         #@"Okay"
    167                                         +null-ptr+
    168                                         +null-ptr+))))
     221  (run-svn-update-for-directory (gui::find-ccl-directory)))
    169222
    170223;;; -----------------------------------------------------------------
Note: See TracChangeset for help on using the changeset viewer.