Improve reproducibility of generated loaddefs file.

* lisp/emacs-lisp/autoload.el (autoload-generate-file-autoloads):
Make the return value the modtime of the input file (if no autoloads).
(update-directory-autoloads): In the "no autoloads" section,
use "most recent modtime" rather than "current time".

; http://lists.gnu.org/archive/html/emacs-devel/2015-06/msg00688.html
This commit is contained in:
Glenn Morris 2015-06-30 14:59:04 -04:00
parent 0dfea4562e
commit 5200c2baef

View file

@ -522,8 +522,8 @@ If OUTFILE is non-nil and FILE specifies a `generated-autoload-file'
different from OUTFILE, then OUTBUF is ignored. different from OUTFILE, then OUTBUF is ignored.
Return non-nil if and only if FILE adds no autoloads to OUTFILE Return non-nil if and only if FILE adds no autoloads to OUTFILE
\(or OUTBUF if OUTFILE is nil)." \(or OUTBUF if OUTFILE is nil). The actual return value is
(catch 'done FILE's modification time."
(let (load-name (let (load-name
(print-length nil) (print-length nil)
(print-level nil) (print-level nil)
@ -534,6 +534,8 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
(absfile (expand-file-name file)) (absfile (expand-file-name file))
;; nil until we found a cookie. ;; nil until we found a cookie.
output-start) output-start)
(when
(catch 'done
(with-current-buffer (or visited (with-current-buffer (or visited
;; It is faster to avoid visiting the file. ;; It is faster to avoid visiting the file.
(autoload-find-file file)) (autoload-find-file file))
@ -631,7 +633,8 @@ Return non-nil if and only if FILE adds no autoloads to OUTFILE
(or (not output-start) (or (not output-start)
;; If the entries were added to some other buffer, then the file ;; If the entries were added to some other buffer, then the file
;; doesn't add entries to OUTFILE. ;; doesn't add entries to OUTFILE.
otherbuf)))) otherbuf))
(nth 5 (file-attributes absfile)))))
(defun autoload-save-buffers () (defun autoload-save-buffers ()
(while autoload-modified-buffers (while autoload-modified-buffers
@ -757,7 +760,7 @@ write its autoloads into the specified file instead."
t files-re)) t files-re))
dirs))) dirs)))
(done ()) (done ())
(this-time (current-time)) (last-time)
;; Files with no autoload cookies or whose autoloads go to other ;; Files with no autoload cookies or whose autoloads go to other
;; files because of file-local autoload-generated-file settings. ;; files because of file-local autoload-generated-file settings.
(no-autoloads nil) (no-autoloads nil)
@ -782,14 +785,14 @@ write its autoloads into the specified file instead."
;; There shouldn't be more than one such entry. ;; There shouldn't be more than one such entry.
;; Remove the obsolete section. ;; Remove the obsolete section.
(autoload-remove-section (match-beginning 0)) (autoload-remove-section (match-beginning 0))
(let ((last-time (nth 4 form))) (setq last-time (nth 4 form))
(dolist (file file) (dolist (file file)
(let ((file-time (nth 5 (file-attributes file)))) (let ((file-time (nth 5 (file-attributes file))))
(when (and file-time (when (and file-time
(not (time-less-p last-time file-time))) (not (time-less-p last-time file-time)))
;; file unchanged ;; file unchanged
(push file no-autoloads) (push file no-autoloads)
(setq files (delete file files))))))) (setq files (delete file files))))))
((not (stringp file))) ((not (stringp file)))
((or (not (file-exists-p file)) ((or (not (file-exists-p file))
;; Remove duplicates as well, just in case. ;; Remove duplicates as well, just in case.
@ -811,14 +814,18 @@ write its autoloads into the specified file instead."
(push file done) (push file done)
(setq files (delete file files))))) (setq files (delete file files)))))
;; Elements remaining in FILES have no existing autoload sections yet. ;; Elements remaining in FILES have no existing autoload sections yet.
(let ((no-autoloads-time (or last-time '(0 0 0 0))) file-time)
(dolist (file files) (dolist (file files)
(cond (cond
((member (expand-file-name file) autoload-excludes) nil) ((member (expand-file-name file) autoload-excludes) nil)
;; Passing nil as second argument forces ;; Passing nil as second argument forces
;; autoload-generate-file-autoloads to look for the right ;; autoload-generate-file-autoloads to look for the right
;; spot where to insert each autoloads section. ;; spot where to insert each autoloads section.
((autoload-generate-file-autoloads file nil buffer-file-name) ((setq file-time
(push file no-autoloads)))) (autoload-generate-file-autoloads file nil buffer-file-name))
(push file no-autoloads)
(if (time-less-p no-autoloads-time file-time)
(setq no-autoloads-time file-time)))))
(when no-autoloads (when no-autoloads
;; Sort them for better readability. ;; Sort them for better readability.
@ -827,8 +834,8 @@ write its autoloads into the specified file instead."
(goto-char (point-max)) (goto-char (point-max))
(search-backward "\f" nil t) (search-backward "\f" nil t)
(autoload-insert-section-header (autoload-insert-section-header
(current-buffer) nil nil no-autoloads this-time) (current-buffer) nil nil no-autoloads no-autoloads-time)
(insert generate-autoload-section-trailer)) (insert generate-autoload-section-trailer)))
(let ((version-control 'never)) (let ((version-control 'never))
(save-buffer)) (save-buffer))