Skip to content

Commit 72be104

Browse files
committed
Always update safe props into status.el file
Never throw an error about not updated properties, just warn about them.
1 parent 9afe14f commit 72be104

2 files changed

Lines changed: 51 additions & 54 deletions

File tree

el-get-status.el

Lines changed: 49 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -290,22 +290,30 @@ to the operation required."
290290
else do (setq reinstall (plist-put reinstall k v))
291291
finally return (list init update reinstall)))
292292

293-
(defun el-get-diagnosis-properties (old-source new-source)
294-
"Diagnosis difference between OLD-SOURCE and NEW-SOURCE.
295-
296-
Return a list (REQUIRED-OPS ADDED REMOVED). REQUIRED-OPS is list
297-
of one or more of `init', `update', or `reinstall' when
298-
OLD-SOURCE and NEW-SOURCE are different (nil otherwise). It
299-
indicates which operations can perform the change. ADDED and
300-
REMOVED are added and removed properties, respectively."
301-
(let* ((added (el-get-classify-new-properties old-source new-source))
302-
(removed (el-get-classify-new-properties new-source old-source))
303-
(min-op (cond ((or (nth 2 added) (nth 2 removed)) 2)
304-
((or (nth 1 added) (nth 1 removed)) 1)
305-
((or (nth 0 added) (nth 0 removed)) 0))))
306-
(list (and min-op (nthcdr min-op '(init update reinstall)))
307-
(apply #'append (nthcdr (or min-op 0) added))
308-
(apply #'append (nthcdr (or min-op 0) removed)))))
293+
(defun el-get-compute-new-status (operation old new)
294+
"Return an update of OLD with NEW.
295+
296+
Return a list (RESULT REQUIRED TO-ADD TO-REM), where RESULT is
297+
the updated recipe. TO-ADD and TO-REM are the list properties
298+
that prevent a full update with the given OPERATION, REQUIRED is
299+
a list of operations that would allow a full update."
300+
(let* ((ops '(init update reinstall))
301+
(op-rank (1- (length (memq operation ops))))
302+
(ops-given (butlast ops op-rank))
303+
(rem-props (el-get-classify-new-properties new old))
304+
(add-props (el-get-classify-new-properties old new))
305+
(rem-allow (apply #'append (butlast rem-props op-rank)))
306+
(add-allow (apply #'append (butlast add-props op-rank)))
307+
(no-rem (last rem-props op-rank))
308+
(no-add (last add-props op-rank)))
309+
(list (nconc (loop for (key val) on old by #'cddr
310+
unless (plist-member rem-allow key)
311+
nconc (list key val))
312+
add-allow)
313+
(loop for i from (1- (length ops)) downto (length ops-given)
314+
when (or (nth i rem-props) (nth i add-props))
315+
return (nthcdr i ops))
316+
(apply #'append no-add) (apply #'append no-rem))))
309317

310318
(defun el-get-package-or-source (package-or-source)
311319
"Given either a package name or a full source entry, return a
@@ -328,50 +336,39 @@ REMOVED are added and removed properties, respectively."
328336
(error "Package %s is nowhere to be found in el-get status file."
329337
package))))
330338

331-
(defun el-get-merge-properties-into-status (package-or-source
339+
(defun el-get-merge-properties-into-status (package
332340
operation
333341
&rest keys)
334-
"Merge updatable properties for package into package status alist (or status file).
342+
"Merge updatable properties for package into status file.
335343
336-
The first argument is either a package source or a package name,
337-
in which case the source will be read using
338-
`el-get-package-def'. The named package must already be
339-
installed.
344+
PACKAGE is either a package source or name, in which case the
345+
source will be read using `el-get-package-def'. The named
346+
package must already be installed.
340347
341-
If the new source differs only in whitelisted properties (see
342-
`el-get-status-recipe-updatable-properties'), then the updated
343-
values for those properties will be written to the status
344-
file.
345-
346-
If any non-whitelisted properties differ from the cached values,
347-
then an error is raise. With optional keyword argument `:noerror
348-
t', this error is suppressed (but nothing is updated).
349-
350-
\(fn PACKAGE-OR-SOURCE &key NOERROR)"
348+
Warn about any non-whitelisted properties differing from the
349+
cached values."
351350
(interactive
352351
(list (el-get-read-package-with-status "Update cached recipe" "installed")
353-
'init
354-
:noerror current-prefix-arg))
355-
(let* ((noerror (cadr (memq :noerror keys)))
356-
(source (el-get-package-or-source package-or-source))
357-
(package (el-get-as-symbol (el-get-source-name source)))
358-
(cached-recipe
359-
(el-get-read-cached-recipe package source)))
352+
'init))
353+
(let* ((source (el-get-package-or-source package))
354+
(package (plist-get source :name))
355+
(cached (el-get-read-cached-recipe package source)))
360356
(unless (el-get-package-is-installed package)
361357
(error "Package %s is not installed. Cannot update recipe." package))
362-
(destructuring-bind (required-ops added removed)
363-
(el-get-diagnosis-properties cached-recipe source)
364-
(if (and required-ops (not (memq operation required-ops)))
365-
;; Emit a verbose message if `noerror' is t (but still quit
366-
;; the function).
367-
(funcall (if noerror 'el-get-verbose-message 'error)
368-
(concat "Must %s `%s' to modify its cached recipe\n"
369-
" adding: %s"
370-
" removing: %s")
371-
(mapconcat #'symbol-name required-ops " or ") package
372-
(if added (pp-to-string added) "()\n")
373-
(if removed (pp-to-string removed) "()\n"))
358+
(destructuring-bind (new-src required-ops no-add no-rem)
359+
(el-get-compute-new-status operation cached source)
360+
(el-get-save-package-status package "installed" new-src)
374361
(when required-ops
375-
(el-get-save-package-status package "installed" source))))))
362+
(lwarn '(el-get recipe-cache) :warning
363+
(concat "Must %s `%s' to modify its cached recipe\n"
364+
" adding: %s"
365+
" removing: %s")
366+
(mapconcat #'symbol-name required-ops " or ") package
367+
(if no-add (pp-to-string no-add) "()\n")
368+
(if no-rem (pp-to-string no-rem) "()\n"))))))
369+
370+
;; Using `declare' in `defun' only supported from Emacs 24.3.
371+
(set-advertised-calling-convention
372+
'el-get-merge-properties-into-status '(package operation) "May 2016")
376373

377374
(provide 'el-get-status)

el-get.el

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ this warning either uninstall one of the el-get or package.el
375375
version of %s, or call `el-get' before `package-initialize' to
376376
prevent package.el from loading it." package package)))
377377
(when el-get-auto-update-cached-recipes
378-
(el-get-merge-properties-into-status package 'init :noerror t))
378+
(el-get-merge-properties-into-status package 'init))
379379
(condition-case err
380380
(let* ((el-get-sources (el-get-package-status-recipes))
381381
(source (el-get-read-package-status-recipe package))
@@ -633,7 +633,7 @@ PACKAGE may be either a string or the corresponding symbol."
633633
(defun el-get-post-update-build (package)
634634
"Function to call after building the package while updating it."
635635
;; fix trailing failed installs
636-
(el-get-merge-properties-into-status package 'update :noerror t)
636+
(el-get-merge-properties-into-status package 'update)
637637
(when (string= (el-get-read-package-status package) "required")
638638
(el-get-save-package-status package "installed"))
639639
(el-get-invalidate-autoloads package)

0 commit comments

Comments
 (0)