Centralize the control for whether 'vc-diff' is asynchronous
across the backends, while also allowing 'vc-BACKEND-diff' to be
called asynchronously when needed. Previously in bug#21969.
* lisp/vc/vc.el (vc-allow-async-diff): New user option.
* lisp/vc/vc.el (vc-version-diff, vc-diff, vc-diff-mergebase)
(vc-root-diff): Obey it.
* lisp/vc/log-view.el (log-view-diff-common): Same.
* lisp/vc/vc-annotate.el
(vc-annotate-show-diff-revision-at-line-internal): Same.
* lisp/vc/vc-git.el (vc-git-diff): Follow the ASYNC argument.
* lisp/vc/vc-hg.el (vc-hg-diff): Same.
* lisp/vc/vc-rcs.el (vc-rcs-diff): Same.
(cherry picked from commit
bec823b107ef7d3b51b8e430ccab82c81bd63d24)
(log-view-diff-common beg end t)))
(defun log-view-diff-common (beg end &optional whole-changeset)
+ (defvar vc-allow-async-diff)
(let* ((to (log-view-current-tag beg))
(fr-entry (log-view-current-entry end))
(fr (cadr fr-entry)))
(point))))
(setq fr (vc-call-backend log-view-vc-backend 'previous-revision nil fr)))
(vc-diff-internal
- t (list log-view-vc-backend
- ;; The value passed here should follow what
- ;; `vc-deduce-fileset' returns. If we want to see the
- ;; diff for all the files in the changeset, pass NIL for
- ;; the file list.
- (unless whole-changeset
- (if log-view-per-file-logs
- (list (log-view-current-file))
- log-view-vc-fileset)))
+ vc-allow-async-diff
+ (list log-view-vc-backend
+ ;; The value passed here should follow what
+ ;; `vc-deduce-fileset' returns. If we want to see the
+ ;; diff for all the files in the changeset, pass NIL for
+ ;; the file list.
+ (unless whole-changeset
+ (if log-view-per-file-logs
+ (list (log-view-current-file))
+ log-view-vc-fileset)))
fr to)))
(provide 'log-view)
(car rev-at-line) t 1)))))))
(defun vc-annotate-show-diff-revision-at-line-internal (filediff)
+ (defvar vc-allow-async-diff)
(if (not (derived-mode-p 'vc-annotate-mode))
(message "Cannot be invoked outside of a vc annotate buffer")
(let* ((rev-at-line (vc-annotate-extract-revision-at-line))
(vc-call-backend vc-annotate-backend 'previous-revision
(if filediff fname nil) rev))
(vc-diff-internal
- t
+ vc-allow-async-diff
;; The value passed here should follow what
;; `vc-deduce-fileset' returns.
(list vc-annotate-backend
samp coding-system-for-read t)))
(setq coding-system-for-read 'undecided)))
-(defun vc-git-diff (files &optional rev1 rev2 buffer _async)
+(defun vc-git-diff (files &optional rev1 rev2 buffer async)
"Get a difference report using Git between two revisions of FILES."
(let (process-file-side-effects
(command "diff-tree"))
(unless rev1 (setq rev1 "HEAD")))
(if vc-git-diff-switches
(apply #'vc-git-command (or buffer "*vc-diff*")
- 1 ; bug#21969
+ (if async 'async 1)
files
command
"--exit-code"
(cons 'vc-hg-region-history-font-lock-keywords
(cdr font-lock-defaults))))
-(defun vc-hg-diff (files &optional oldvers newvers buffer _async)
+(defun vc-hg-diff (files &optional oldvers newvers buffer async)
"Get a difference report using hg between two revisions of FILES."
(let* ((firstfile (car files))
(working (and firstfile (vc-working-revision firstfile))))
(setq oldvers working))
(apply #'vc-hg-command
(or buffer "*vc-diff*")
- nil ; bug#21969
+ (if async 'async 1)
files "diff"
(append
(vc-switches 'hg 'diff)
(vc-rcs-print-log-cleanup))
(when limit 'limit-unsupported))
-(defun vc-rcs-diff (files &optional oldvers newvers buffer _async)
+(defun vc-rcs-diff (files &optional oldvers newvers buffer async)
"Get a difference report using RCS between two sets of files."
(apply #'vc-do-command (or buffer "*vc-diff*")
- ;; The repo is local, so this is fast anyway.
- 1 ; bug#21969
+ (if async 'async 1)
"rcsdiff" (vc-expand-dirs files 'RCS)
(append (list "-q"
(and oldvers (concat "-r" oldvers))
(const :tag "Yes" t))
:version "22.1")
+(defcustom vc-allow-async-diff nil
+ "Non-nil to allow asynchronous diff process.
+Enabling this means the buffer will be displayed before the diff is
+generated, and so might only say \"No changes ...\"."
+ :type '(choice (const :tag "No" nil)
+ (const :tag "Yes" t))
+ :version "31.1")
+
;;;###autoload
(defcustom vc-checkout-hook nil
"Normal hook (list of functions) run after checking out a file.
(error "Not a valid revision range"))
;; Yes, it's painful to call (vc-deduce-fileset) again. Alas, the
;; placement rules for (interactive) don't actually leave us a choice.
- (vc-diff-internal t (vc-deduce-fileset t) rev1 rev2
+ (vc-diff-internal vc-allow-async-diff (vc-deduce-fileset t) rev1 rev2
(called-interactively-p 'interactive)))
;;;###autoload
(error "Not a valid revision range"))
(vc--with-backend-in-rootdir "VC root-diff"
(let ((default-directory rootdir))
- (vc-diff-internal t (list backend (list rootdir)) rev1 rev2
+ (vc-diff-internal vc-allow-async-diff (list backend (list rootdir)) rev1 rev2
(called-interactively-p 'interactive)))))
;;;###autoload
(call-interactively 'vc-version-diff)
(let ((fileset (or fileset (vc-deduce-fileset t))))
(vc-buffer-sync-fileset fileset not-essential)
- (vc-diff-internal t fileset nil nil
+ (vc-diff-internal vc-allow-async-diff fileset nil nil
(called-interactively-p 'interactive)))))
(defun vc-buffer-sync-fileset (fileset &optional not-essential missing-in-dirs)
(vc--with-backend-in-rootdir "VC root-diff"
(let ((default-directory rootdir)
(rev1 (vc-call-backend backend 'mergebase rev1 rev2)))
- (vc-diff-internal t (list backend (list rootdir)) rev1 rev2
- (called-interactively-p 'interactive)))))
+ (vc-diff-internal
+ vc-allow-async-diff (list backend (list rootdir)) rev1 rev2
+ (called-interactively-p 'interactive)))))
(declare-function ediff-load-version-control "ediff" (&optional silent))
(declare-function ediff-vc-internal "ediff-vers"
(let ((default-directory rootdir)
(fileset `(,backend (,rootdir))))
(vc-buffer-sync-fileset fileset not-essential)
- (vc-diff-internal t fileset nil nil
+ (vc-diff-internal vc-allow-async-diff fileset nil nil
(called-interactively-p 'interactive))))))
;;;###autoload