From 49dbfc0c667f76c1542c9e11d76966a5bfe82d30 Mon Sep 17 00:00:00 2001
From: Francois-Rene Rideau <fare@tunes.org>
Date: Mon, 17 Oct 2016 09:15:40 -0400
Subject: [PATCH] Rename asdf/cache to asdf/session

---
 Makefile                          |  2 +-
 action.lisp                       |  2 +-
 asdf.asd                          |  6 +++---
 find-component.lisp               |  2 +-
 find-system.lisp                  |  2 +-
 interface.lisp                    |  2 +-
 lisp-action.lisp                  |  2 +-
 make-asdf.bat                     |  2 +-
 make-asdf.sh                      |  2 +-
 operate.lisp                      | 12 +++++++-----
 parse-defsystem.lisp              |  2 +-
 plan.lisp                         | 19 +++++++++++--------
 cache.lisp => session.lisp        |  5 +++--
 test/script-support.lisp          |  2 +-
 test/test-logical-pathname.script |  2 +-
 test/test-utilities.script        |  2 +-
 test/test-xach-update-bug.script  |  2 +-
 17 files changed, 37 insertions(+), 31 deletions(-)
 rename cache.lisp => session.lisp (97%)

diff --git a/Makefile b/Makefile
index f8a9fdfc8..c64cdf511 100644
--- a/Makefile
+++ b/Makefile
@@ -80,7 +80,7 @@ XCL ?= xcl
 
 header_lisp := header.lisp
 driver_lisp := uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/version.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/lisp-build.lisp uiop/launch-program.lisp uiop/run-program.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp
-defsystem_lisp := upgrade.lisp cache.lisp component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp output-translations.lisp source-registry.lisp package-inferred-system.lisp backward-interface.lisp backward-internals.lisp interface.lisp user.lisp footer.lisp
+defsystem_lisp := upgrade.lisp session.lisp component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp output-translations.lisp source-registry.lisp package-inferred-system.lisp backward-interface.lisp backward-internals.lisp interface.lisp user.lisp footer.lisp
 all_lisp := $(header_lisp) $(driver_lisp) $(defsystem_lisp)
 
 print-%  : ; @echo $* = $($*)
diff --git a/action.lisp b/action.lisp
index 9aae7abc7..1f6e7666b 100644
--- a/action.lisp
+++ b/action.lisp
@@ -5,7 +5,7 @@
   (:nicknames :asdf-action)
   (:recycle :asdf/action :asdf)
   (:use :uiop/common-lisp :uiop :asdf/upgrade
-   :asdf/component :asdf/system #:asdf/cache :asdf/find-system :asdf/find-component :asdf/operation)
+   :asdf/component :asdf/system #:asdf/session :asdf/find-system :asdf/find-component :asdf/operation)
   (:import-from :asdf/operation #:check-operation-constructor)
   #-clisp (:unintern #:required-components #:traverse-action #:traverse-sub-actions)
   (:export
diff --git a/asdf.asd b/asdf.asd
index 3fec667bf..2e26ef5e3 100644
--- a/asdf.asd
+++ b/asdf.asd
@@ -44,17 +44,17 @@
   :encoding :utf-8
   :components
   ((:file "upgrade")
-   (:file "cache" :depends-on ("upgrade"))
+   (:file "session" :depends-on ("upgrade"))
    (:file "component" :depends-on ("upgrade"))
    (:file "system" :depends-on ("component"))
-   (:file "find-system" :depends-on ("system" "cache"))
+   (:file "find-system" :depends-on ("system" "session"))
    (:file "find-component" :depends-on ("find-system"))
    (:file "operation" :depends-on ("find-system"))
    (:file "action" :depends-on ("find-component" "operation"))
    (:file "lisp-action" :depends-on ("action"))
    (:file "plan" :depends-on ("lisp-action"))
    (:file "operate" :depends-on ("plan"))
-   (:file "parse-defsystem" :depends-on ("cache" "system" "lisp-action" "operate"))
+   (:file "parse-defsystem" :depends-on ("session" "system" "lisp-action" "operate"))
    (:file "bundle" :depends-on ("lisp-action" "operate" "parse-defsystem"))
    (:file "concatenate-source" :depends-on ("plan" "parse-defsystem" "bundle"))
    (:file "output-translations" :depends-on ("operate"))
diff --git a/find-component.lisp b/find-component.lisp
index 52d38e248..145e8c011 100644
--- a/find-component.lisp
+++ b/find-component.lisp
@@ -3,7 +3,7 @@
 
 (uiop/package:define-package :asdf/find-component
   (:recycle :asdf/find-component :asdf)
-  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
+  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
    :asdf/component :asdf/system :asdf/find-system)
   (:export
    #:find-component
diff --git a/find-system.lisp b/find-system.lisp
index e502762a1..c2ccb8056 100644
--- a/find-system.lisp
+++ b/find-system.lisp
@@ -4,7 +4,7 @@
 (uiop/package:define-package :asdf/find-system
   (:recycle :asdf/find-system :asdf)
   (:use :uiop/common-lisp :uiop :asdf/upgrade
-    :asdf/cache :asdf/component :asdf/system)
+    :asdf/session :asdf/component :asdf/system)
   (:export
    #:remove-entry-from-registry #:coerce-entry-to-directory
    #:coerce-name #:primary-system-name #:coerce-filename
diff --git a/interface.lisp b/interface.lisp
index 611318c23..41ddbeb24 100644
--- a/interface.lisp
+++ b/interface.lisp
@@ -7,7 +7,7 @@
   (:unintern
    #:loaded-systems ; makes for annoying SLIME completion
    #:output-files-for-system-and-operation) ; ASDF-BINARY-LOCATION function we use to detect ABL
-  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
+  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
    :asdf/component :asdf/system :asdf/find-system :asdf/find-component
    :asdf/operation :asdf/action :asdf/lisp-action
    :asdf/output-translations :asdf/source-registry
diff --git a/lisp-action.lisp b/lisp-action.lisp
index 9c1fa5a8d..4ea0d2139 100644
--- a/lisp-action.lisp
+++ b/lisp-action.lisp
@@ -3,7 +3,7 @@
 
 (uiop/package:define-package :asdf/lisp-action
   (:recycle :asdf/lisp-action :asdf)
-  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
+  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
    :asdf/component :asdf/system :asdf/find-component :asdf/find-system
    :asdf/operation :asdf/action)
   (:export
diff --git a/make-asdf.bat b/make-asdf.bat
index 321ed65f8..4614e1254 100644
--- a/make-asdf.bat
+++ b/make-asdf.bat
@@ -5,7 +5,7 @@
 set here=%~dp0
 set header_lisp=header.lisp
 set driver_lisp=uiop\package.lisp + uiop\common-lisp.lisp + uiop\utility.lisp + uiop\version.lisp + uiop\os.lisp + uiop\pathname.lisp + uiop\filesystem.lisp + uiop\stream.lisp + uiop\image.lisp + uiop\lisp-build.lisp + uiop\launch-program.lisp + uiop\run-program.lisp + uiop\configuration.lisp + uiop\backward-driver.lisp + uiop\driver.lisp
-set defsystem_lisp=upgrade.lisp + cache.lisp + component.lisp + system.lisp + find-system.lisp + find-component.lisp + operation.lisp + action.lisp + lisp-action.lisp + plan.lisp + operate.lisp + parse-defsystem.lisp + bundle.lisp + concatenate-source.lisp + output-translations.lisp + source-registry.lisp + package-inferred-system.lisp + backward-interface.lisp + backward-internals.lisp + interface.lisp + user.lisp + footer.lisp
+set defsystem_lisp=upgrade.lisp + session.lisp + component.lisp + system.lisp + find-system.lisp + find-component.lisp + operation.lisp + action.lisp + lisp-action.lisp + plan.lisp + operate.lisp + parse-defsystem.lisp + bundle.lisp + concatenate-source.lisp + output-translations.lisp + source-registry.lisp + package-inferred-system.lisp + backward-interface.lisp + backward-internals.lisp + interface.lisp + user.lisp + footer.lisp
 
 %~d0
 cd "%~p0"
diff --git a/make-asdf.sh b/make-asdf.sh
index 2a894a916..7194e1716 100755
--- a/make-asdf.sh
+++ b/make-asdf.sh
@@ -6,7 +6,7 @@ here="$(dirname $0)"
 
 header_lisp="header.lisp"
 driver_lisp="uiop/package.lisp uiop/common-lisp.lisp uiop/utility.lisp uiop/version.lisp uiop/os.lisp uiop/pathname.lisp uiop/filesystem.lisp uiop/stream.lisp uiop/image.lisp uiop/lisp-build.lisp uiop/launch-program.lisp uiop/run-program.lisp uiop/configuration.lisp uiop/backward-driver.lisp uiop/driver.lisp"
-defsystem_lisp="upgrade.lisp cache.lisp component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp output-translations.lisp source-registry.lisp package-inferred-system.lisp backward-interface.lisp backward-internals.lisp interface.lisp user.lisp footer.lisp"
+defsystem_lisp="upgrade.lisp session.lisp component.lisp system.lisp find-system.lisp find-component.lisp operation.lisp action.lisp lisp-action.lisp plan.lisp operate.lisp parse-defsystem.lisp bundle.lisp concatenate-source.lisp output-translations.lisp source-registry.lisp package-inferred-system.lisp backward-interface.lisp backward-internals.lisp interface.lisp user.lisp footer.lisp"
 
 all () {
   # Default action: bootstrap asdf.lisp
diff --git a/operate.lisp b/operate.lisp
index fee732528..676468b49 100644
--- a/operate.lisp
+++ b/operate.lisp
@@ -3,7 +3,7 @@
 
 (uiop/package:define-package :asdf/operate
   (:recycle :asdf/operate :asdf)
-  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/cache
+  (:use :uiop/common-lisp :uiop :asdf/upgrade :asdf/session
    :asdf/component :asdf/system :asdf/operation :asdf/action
    :asdf/find-system :asdf/find-component :asdf/lisp-action :asdf/plan)
   (:export
@@ -86,13 +86,15 @@ But do NOT depend on it, for this is deprecated behavior."))
   (defmethod operate :before ((operation operation) (component component)
                               &key version &allow-other-keys)
     (unless (version-satisfies component version)
-      (error 'missing-component-of-version :requires component :version version)))
+      (error 'missing-component-of-version :requires component :version version))
+    (when *plan*
+      (plan-record-dependency *plan* operation component)))
 
   (defmethod operate ((operation operation) (component component)
                       &rest keys &key plan-class &allow-other-keys)
-    (let ((plan (apply 'make-plan plan-class operation component keys)))
-      (apply 'perform-plan plan keys)
-      (values operation plan)))
+    (let ((*plan* (apply 'make-plan plan-class operation component #|:parent *plan*|# keys)))
+      (apply 'perform-plan *plan* keys)
+      (values operation *plan*)))
 
   (defun oos (operation component &rest args &key &allow-other-keys)
     (apply 'operate operation component args))
diff --git a/parse-defsystem.lisp b/parse-defsystem.lisp
index 101ecef5b..c535c17ff 100644
--- a/parse-defsystem.lisp
+++ b/parse-defsystem.lisp
@@ -5,7 +5,7 @@
   (:recycle :asdf/parse-defsystem :asdf/defsystem :asdf)
   (:nicknames :asdf/defsystem) ;; previous name, to be compatible with, in case anyone cares
   (:use :uiop/common-lisp :asdf/driver :asdf/upgrade
-   :asdf/cache :asdf/component :asdf/system
+   :asdf/session :asdf/component :asdf/system
    :asdf/find-system :asdf/find-component :asdf/action :asdf/lisp-action :asdf/operate)
   (:import-from :asdf/system #:depends-on #:weakly-depends-on)
   (:export
diff --git a/plan.lisp b/plan.lisp
index 5a8e7ee63..987e0d40e 100644
--- a/plan.lisp
+++ b/plan.lisp
@@ -7,11 +7,11 @@
   (:recycle :asdf/plan :asdf)
   (:use :uiop/common-lisp :uiop :asdf/upgrade
    :asdf/component :asdf/operation :asdf/system
-   :asdf/cache :asdf/find-system :asdf/find-component
+   :asdf/session :asdf/find-system :asdf/find-component
    :asdf/operation :asdf/action :asdf/lisp-action)
   (:export
    #:component-operation-time
-   #:plan #:plan-traversal #:sequential-plan #:*default-plan-class*
+   #:plan #:plan-traversal #:sequential-plan #:*default-plan-class* #:*plan*
    #:planned-action-status #:plan-action-status #:action-already-done-p
    #:circular-dependency #:circular-dependency-actions
    #:needed-in-image-p
@@ -55,7 +55,10 @@
      (visiting-action-set ;; as a set
       :initform (make-hash-table :test 'equal) :accessor plan-visiting-action-set)
      (visiting-action-list :initform () :accessor plan-visiting-action-list)) ;; as a list
-    (:documentation "Base class for plans that simply traverse dependencies")))
+    (:documentation "Base class for plans that simply traverse dependencies"))
+
+  (defvar *plan* nil
+    "The plan currently being executed"))
 
 
 ;;;; Planned action status
@@ -467,11 +470,11 @@ initialized with SEED."
     (apply 'perform-plan (plan-actions plan) keys))
 
   (defmethod perform-plan ((steps list) &key force &allow-other-keys)
-    (loop* :for action :in steps
-           :as o = (action-operation action)
-           :as c = (action-component action)
-           :when (or force (not (nth-value 1 (compute-action-stamp nil o c))))
-           :do (perform-with-restarts o c)))
+    (loop :for action :in steps
+          :as o = (action-operation action)
+          :as c = (action-component action)
+          :unless (nth-value 1 (compute-action-stamp nil o c))
+          :do (perform-with-restarts o c)))
 
   (defmethod plan-operates-on-p ((plan plan-traversal) (component-path list))
     (plan-operates-on-p (plan-actions plan) component-path))
diff --git a/cache.lisp b/session.lisp
similarity index 97%
rename from cache.lisp
rename to session.lisp
index 06427f165..d2a673ec3 100644
--- a/cache.lisp
+++ b/session.lisp
@@ -1,14 +1,15 @@
 ;;;; -------------------------------------------------------------------------
 ;;;; Session cache
 
-(uiop/package:define-package :asdf/cache
+(uiop/package:define-package :asdf/session
+  (:recycle :asdf/session :asdf/cache)
   (:use :uiop/common-lisp :uiop :asdf/upgrade)
   (:export #:get-file-stamp #:compute-file-stamp #:register-file-stamp
            #:set-asdf-cache-entry #:unset-asdf-cache-entry #:consult-asdf-cache
            #:do-asdf-cache #:normalize-namestring
            #:call-with-asdf-cache #:with-asdf-cache #:*asdf-cache*
            #:clear-configuration-and-retry #:retry))
-(in-package :asdf/cache)
+(in-package :asdf/session)
 
 ;;; The ASDF session cache is used to memoize some computations. It is instrumental in achieving:
 ;; * Consistency in the view of the world relied on by ASDF within a given session.
diff --git a/test/script-support.lisp b/test/script-support.lisp
index 510c07886..5a88a2bab 100644
--- a/test/script-support.lisp
+++ b/test/script-support.lisp
@@ -655,7 +655,7 @@ is bound, write a message and exit on an error.  If
   (format t "Frob packages~%")
   (use-package :asdf :asdf-test)
   (when (find-package :uiop) (use-package :uiop :asdf-test))
-  (when (find-package :asdf/cache) (use-package :asdf/cache :asdf-test))
+  (when (find-package :asdf/session) (use-package :asdf/session :asdf-test))
   (setf *package* (find-package :asdf-test))
   t)
 
diff --git a/test/test-logical-pathname.script b/test/test-logical-pathname.script
index fc4f8aae7..e24409fe6 100644
--- a/test/test-logical-pathname.script
+++ b/test/test-logical-pathname.script
@@ -10,7 +10,7 @@
                       `(,*asdf-directory* "build/fasls" :implementation "logical-host-asdf")
                       :wilden t))))
 
-(setf asdf/cache:*asdf-cache* nil)
+(setf asdf/session:*asdf-cache* nil)
 
 (DBG :logical
      (logical-pathname-translations "ASDF")
diff --git a/test/test-utilities.script b/test/test-utilities.script
index 9ce471a73..4e006cfa5 100644
--- a/test/test-utilities.script
+++ b/test/test-utilities.script
@@ -283,7 +283,7 @@
     asdf/find-system:contrib-sysdef-search
     asdf/find-system:sysdef-find-asdf
     ;; restart
-    asdf/cache:clear-configuration-and-retry
+    asdf/session:clear-configuration-and-retry
     ))
 
 (defun defined-symbol-p (symbol)
diff --git a/test/test-xach-update-bug.script b/test/test-xach-update-bug.script
index 5326092d0..5a53171ad 100644
--- a/test/test-xach-update-bug.script
+++ b/test/test-xach-update-bug.script
@@ -1,6 +1,6 @@
 ;;; -*- Lisp -*-
 
-(setf asdf/cache:*asdf-cache* nil) ;; disable cache between those two very different compilations.
+(setf asdf/session:*asdf-cache* nil) ;; disable cache between those two very different compilations.
 #-(and ecl ecl-bytecmp)
 (setf asdf::*load-system-operation* 'load-bundle-op) ;; This triggers a bug on ECL no more!
 
-- 
GitLab