;;;; Function-only upgrade; no test transfers on the user's live desk. (in-package #:cl-user) (defun lime-follow-head-definitions () (let ((manifest '(("src/x11/commands.lisp" "BACKEND-TRANSFER-FOCUSED-CLIENT-TO-HEAD" "BACKEND-TRANSFER-FOCUSED-CLIENT-RELATIVELY" "BACKEND-REHOME-CLIENT-TO-HEAD") ("src/x11/ui.lisp" "%UI-REQUEST-CLIENT-SEND"))) (definitions nil) (*package* (find-package :lime.x11)) (*read-eval* nil)) (dolist (entry manifest) (destructuring-bind (file &rest names) entry (let ((symbols (mapcar (lambda (name) (or (find-symbol name *package*) (error "Missing ~A" name))) names)) (found nil)) (with-open-file (in (merge-pathnames file #p"/home/adan/code/common-lisp/lime/")) (loop for form = (read in nil :eof) until (eq form :eof) when (and (consp form) (eq (first form) 'defun) (member (second form) symbols)) do (push form found))) (assert (= (length symbols) (length found))) (dolist (symbol symbols) (assert (find symbol found :key #'second))) (setf definitions (append definitions (mapcar (lambda (symbol) (find symbol found :key #'second)) symbols)))))) definitions)) (defun lime-upgrade-live-follow-head () (unless (= 1578331 (slynk-backend:getpid)) (error "Unexpected Lime process.")) (lime.dev:with-development-backend (backend) (unless (and (lime.dev::development-session-running-p lime.dev:*development-session*) (not (lime.dev::development-session-paused-p lime.dev:*development-session*))) (error "Lime is not running normally.")) (when (or (lime.x11::x11-backend-pointer-drag backend) (lime.x11::x11-backend-ui-session backend)) (error "Close the menu or finish the drag before upgrading.")) (let* ((world (lime.x11:x11-backend-world backend)) (before (lime.persistence:snapshot-world world)) (head (lime.x11:x11-backend-focused-head-id backend)) (config (lime.x11::x11-backend-configuration backend)) (bindings (lime.x11:list-keybindings backend)) (definitions (lime-follow-head-definitions)) (old-functions (mapcar (lambda (form) (cons (second form) (fdefinition (second form)))) definitions))) (handler-case (progn (dolist (definition definitions) (eval definition)) (assert (equalp before (lime.persistence:snapshot-world world))) (assert (equal head (lime.x11:x11-backend-focused-head-id backend))) (assert (eq config (lime.x11::x11-backend-configuration backend))) (assert (equal bindings (lime.x11:list-keybindings backend))) (assert (lime.core:validate-world world)) (list :upgraded t :world-unchanged t :focus-unchanged t :bindings-unchanged t :function-count (length definitions))) (error (condition) (dolist (entry old-functions) (setf (fdefinition (car entry)) (cdr entry))) (error condition))))))