[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 7ab556b576 29/42: Improve robustness of 'package-vc-update'
From: |
Philip Kaludercic |
Subject: |
master 7ab556b576 29/42: Improve robustness of 'package-vc-update' |
Date: |
Thu, 17 Nov 2022 14:56:23 -0500 (EST) |
branch: master
commit 7ab556b57631cb28db86b89ba296bc0599d9a399
Author: Philip Kaludercic <philipk@posteo.net>
Commit: Philip Kaludercic <philipk@posteo.net>
Improve robustness of 'package-vc-update'
* lisp/emacs-lisp/package-vc.el (package-vc-update): Ensure that the
command is only invoked with installed packages. that the hook is
always removed and that 'vc-pull' is always called in the right
directory.
---
lisp/emacs-lisp/package-vc.el | 29 ++++++++++++-----------------
1 file changed, 12 insertions(+), 17 deletions(-)
diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el
index 9d8d3ee5f4..289f8e37ce 100644
--- a/lisp/emacs-lisp/package-vc.el
+++ b/lisp/emacs-lisp/package-vc.el
@@ -562,7 +562,7 @@ installed package."
(defun package-vc-update (pkg-desc)
"Attempt to update the package PKG-DESC."
- (interactive (list (package-vc--read-package-desc "Update source package:")))
+ (interactive (list (package-vc--read-package-desc "Update source package: "
t)))
;; HACK: To run `package-vc--unpack-1' after checking out the new
;; revision, we insert a hook into `vc-post-command-functions', and
;; remove it right after it ran. To avoid running the hook multiple
@@ -577,28 +577,23 @@ installed package."
;; If there is a better way to do this, it should be done.
(cl-assert (package-vc-p pkg-desc))
(letrec ((pkg-dir (package-desc-dir pkg-desc))
- (empty (make-symbol "empty"))
- (args (list empty empty empty empty))
+ (vc-flags)
(vc-filter-command-function
(lambda (command file-or-list flags)
- (setf (nth 0 args) command
- (nth 1 args) file-or-list
- (nth 2 args) flags
- (nth 3 args) default-directory)
+ (setq vc-flags flags)
(list command file-or-list flags)))
(post-upgrade
- (lambda (command file-or-list flags)
- (when (and (memq (nth 0 args) (list command empty))
- (memq (nth 1 args) (list file-or-list empty))
- (memq (nth 2 args) (list flags empty))
- (or (eq (nth 3 args) empty)
- (file-equal-p (nth 3 args) default-directory)))
- (with-demoted-errors "Failed to activate: %S"
- (package-vc--unpack-1 pkg-desc pkg-dir))
- (remove-hook 'vc-post-command-functions post-upgrade)))))
+ (lambda (_command _file-or-list flags)
+ (when (and (file-equal-p pkg-dir default-directory)
+ (eq flags vc-flags))
+ (unwind-protect
+ (with-demoted-errors "Failed to activate: %S"
+ (package-vc--unpack-1 pkg-desc pkg-dir))
+ (remove-hook 'vc-post-command-functions post-upgrade))))))
(add-hook 'vc-post-command-functions post-upgrade)
(with-demoted-errors "Failed to fetch: %S"
- (vc-pull))))
+ (let ((default-directory pkg-dir))
+ (vc-pull)))))
(defun package-vc--archives-initialize ()
"Initialize package.el and fetch package specifications."
- master b0200a37e4 10/42: Expand 'package-vc--unpack-1' documentation, (continued)
- master b0200a37e4 10/42: Expand 'package-vc--unpack-1' documentation, Philip Kaludercic, 2022/11/17
- master 2ec02024ab 14/42: Track 'default-directory' while updating source packages, Philip Kaludercic, 2022/11/17
- master d67b66f8ab 13/42: Respect :lisp-dir in package specs by loading a sub-directory, Philip Kaludercic, 2022/11/17
- master c53c5f3884 15/42: Rename 'package-vc-refresh' to 'package-vc-rebuild', Philip Kaludercic, 2022/11/17
- master 348f7d263c 17/42: Move package spec documentation to 'package-vc-selected-packages', Philip Kaludercic, 2022/11/17
- master 2b93d0e6f1 16/42: Fix type error in package-vc prompt function, Philip Kaludercic, 2022/11/17
- master 7c3d3fa44e 19/42: Improve robustness of documentation generation, Philip Kaludercic, 2022/11/17
- master ccd7ab84c5 20/42: Fix edebug spec for 'package--with-response-buffer', Philip Kaludercic, 2022/11/17
- master 496c578d9c 22/42: Have 'package-vc-selected-packages' consider all installed packages, Philip Kaludercic, 2022/11/17
- master a467afbd98 25/42: Mention package name when package is lacking VC data, Philip Kaludercic, 2022/11/17
- master 7ab556b576 29/42: Improve robustness of 'package-vc-update',
Philip Kaludercic <=
- master 3326337776 30/42: Avoid destructive manipulation of 'package-vc--archive-spec-alist', Philip Kaludercic, 2022/11/17
- master 32f51f17c4 33/42: Remove temporary .texi files if used to build documentation, Philip Kaludercic, 2022/11/17
- master 228c247e6f 34/42: Remove duplicate package descriptions after updating, Philip Kaludercic, 2022/11/17
- master 4bd7ae833f 36/42: Allow the direct installation of package specifications, Philip Kaludercic, 2022/11/17
- master 53c90abfa8 37/42: ; * lisp/emacs-lisp/package-vc.el: Update TODO, Philip Kaludercic, 2022/11/17
- master aadf07f5b8 05/42: Autoload 'package-vc-install-selected-packages', Philip Kaludercic, 2022/11/17
- master 9f4a433b27 12/42: Fix generation of documentation for source packages, Philip Kaludercic, 2022/11/17
- master aa56e50fe2 23/42: Raise 'wrong-type-argument' when installing package nil, Philip Kaludercic, 2022/11/17
- master d0ea38b5fe 27/42: Have 'vc-prepare-patch' handle prefix arguments., Philip Kaludercic, 2022/11/17
- master 2ed115fc3c 21/42: Fix indefinite loading of asynchronous downloads, Philip Kaludercic, 2022/11/17