Unverified Commit 595fc897 authored by Eric Timmons's avatar Eric Timmons
Browse files

Make COMPONENT-VERSION backwards compatible

COMPONENT-VERSION has explicitly said in its documentation (for several years
now) that the returned version is NIL *or* a string of dot-separated natural
numbers.

In order to maintain backward compatbility, keep the same semantics by only
returning the version if it fits those criteria. To increase the usefulness of
this function, state that if the version is a pre-release (in which case it
almost certainly will *not* meet the criteria), it returns the result of
VERSION-PRE-RELEASE-FOR.

Add function COMPONENT-VERSION* which returns a VERSION-OBJECT directly.

This may be modified if, after checking QL, we determine that no one is
counting on COMPONENT-VERSION having dot-separated natural numbers.
parent aa4c42a3
Loading
Loading
Loading
Loading
+1 −1
Changes for bundle.lisp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -444,7 +444,7 @@ or of opaque libraries shipped along the source code."))
           (library (second inputs))
           (asd (output-file o s))
           (name (if (and fasl asd) (pathname-name asd) (return-from perform)))
           (version (nth-value 1 (component-version s)))
           (version (component-version* s))
           (dependencies
             (if (operation-monolithic-p o)
                 ;; We want only dependencies, and we use basic-load-op rather than load-op so that
+24 −18
Changes for component.lisp: 24 added lines, 18 removed lines.
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@
   #:component-in-order-to #:component-sideway-dependencies
   #:component-if-feature #:around-compile-hook
   #:component-description #:component-long-description
   #:component-version #:version-satisfies
   #:component-version #:component-version* #:version-satisfies
   #:component-inline-methods ;; backward-compatibility only. DO NOT USE!
   #:component-operation-times ;; For internal use only.
   ;; portable ASDF encoding and implementation-specific external-format
@@ -65,9 +65,15 @@ Use asdf-encodings to support more encodings."))
    (:documentation "Check whether a COMPONENT satisfies the constraint of being at least as recent
as the specified VERSION, which must be a string of dot-separated natural numbers, or NIL."))
  (defgeneric component-version (component)
    (:documentation "Return the version of a COMPONENT in two VALUES. The first
value is a string that specifies the version, or NIL. The second value is the
VERSION-OBJECT instance that is suitable for use with UIOP:VERSION<, or NIL."))
    (:documentation "Return the version of a COMPONENT, which must be a string
of dot-separated natural numbers, or NIL. If the component is a pre-release,
returns the version which it is a pre-release for.

This function is kept for backward compatibility. New code should prefer to use
COMPONENT-VERSION*."))
  (defgeneric component-version* (component)
    (:documentation "Return the version of a COMPONENT. The returned version is
version object suitable for use with VERSION< and friends (or NIL)."))
  (defgeneric (setf component-version) (new-version component)
    (:documentation "Updates the version of a COMPONENT."))
  (defgeneric component-version-class (component)
@@ -166,21 +172,21 @@ The return value is a list of component NAMES; a list of strings."
      component))

  (defmethod component-version ((component component))
    "The VERSION slot of COMPONENT may be NIL, unbound, a string, or a
VERSION-OBJECT. If it's a string, update it to be a VERSION-OBJECT and return
it. If it's a VERSION-OBJECT object, return it. Else, return NIL."
    ;; The VERSION slot of COMPONENT may be NIL, unbound, or a
    ;; VERSION-OBJECT. It should not be a string (due to the
    ;; *post-upgrade-cleanup-hook*).
    (if-let (raw-version (and (slot-boundp component 'version)
                              (slot-value component 'version)))
      (typecase raw-version
        (string
         ;; If we're upgrading ASDF and some systems have already been loaded,
         ;; they likely have the old representation of the version (plain
         ;; string) stored.
         (let ((new-version (make-version raw-version)))
           (setf (slot-value component 'version) new-version)
           (values (version-string new-version) new-version)))
        (version-object
         (values (version-string raw-version) raw-version)))))
      (progn
        ;; This ensures that all pre-release info is stripped.
        (when (version-pre-release-p raw-version)
          (setf raw-version (version-pre-release-for raw-version)))
        ;; Ensure that it parses as a series of dot-separated integers.
        (ignore-errors (version-string (make-version (version-string raw-version)))))))
  (defmethod component-version* ((component component))
    (if-let (raw-version (and (slot-boundp component 'version)
                              (slot-value component 'version)))
      raw-version))

  (defmethod (setf component-version) ((value string) (component component))
    "Set the VERSION slot of component."
@@ -345,7 +351,7 @@ this compilation, or check its results, etc."))
  (defmethod version-satisfies :around ((c t) (version null))
    t)
  (defmethod version-satisfies ((c component) version)
    (let ((component-version (component-version c)))
    (let ((component-version (component-version* c)))
      (unless (and version component-version)
        (when version
          (warn "Requested version ~S but ~S has no version" version c))
+15 −5
Changes for doc/asdf.texinfo: 15 added lines, 5 removed lines.
Original line number Diff line number Diff line
@@ -3793,12 +3793,22 @@ the @code{:version-string} initarg.
@end deffn

@deffn {Generic Function} asdf:component-version @var{component}
Returns the version of @code{component}. Returns two values.
Returns the version of @code{component}.

For backwards compatibility, the first value is the string
representation of the version, or NIL (if no version is specified or
it is invalid). The second value is the object that is a subclass of
@code{uiop:version-object}.
This function is kept for backward compatibility. New code should prefer
@code{component-version*}.

The version is a string of dot-separated natural numbers, or NIL. If the
component is a pre-release, returns the version which it is a
pre-release for.

@end deffn

@deffn {Generic Function} asdf:component-version* @var{component}
Returns the version of @code{component}.

The returned version is version object suitable for use with
@code{uiop:version<} and friends (or NIL).

@end deffn

+3 −0
Changes for doc/exported-functions: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ COMPONENT-RELATIVE-PATHNAME
COMPONENT-SIDEWAY-DEPENDENCIES
COMPONENT-SYSTEM
COMPONENT-VERSION
COMPONENT-VERSION*
COMPUTE-SOURCE-REGISTRY
DEFSYSTEM
DISABLE-DEFERRED-WARNINGS-CHECK
@@ -108,6 +109,8 @@ SYSTEM-SOURCE-DIRECTORY
SYSTEM-SOURCE-FILE
SYSTEM-SOURCE-REGISTRY
SYSTEM-SOURCE-REGISTRY-DIRECTORY
SYSTEM-VERSION
SYSTEM-VERSION*
SYSTEM-WEAKLY-DEPENDS-ON
TEST-SYSTEM
TRAVERSE
+3 −3
Changes for footer.lisp: 3 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -30,12 +30,12 @@
;;;; data from the file system that we want to preserve instead of blasting
;;;; away and replacing with a blank preloaded system.
(with-upgradability ()
  (unless (equal (system-version (registered-system "asdf")) (asdf-version))
  (unless (version= (system-version* (registered-system "asdf")) (asdf-version))
    (clear-system "asdf"))
  ;; 3.1.2 is the last version where asdf-package-system was a separate system.
  (when (version< "3.1.2" (system-version (registered-system "asdf-package-system")))
  (when (version< "3.1.2" (system-version* (registered-system "asdf-package-system")))
    (clear-system "asdf-package-system"))
  (unless (equal (system-version (registered-system "uiop")) *uiop-version*)
  (unless (version= (system-version* (registered-system "uiop")) *uiop-version*)
    (clear-system "uiop")))

;;;; Hook ASDF into the implementation's REQUIRE and other entry points.
Loading