GNU bug report logs -
#40967
27.0.50; vc-diff in indirect buffers
Previous Next
Reported by: Nathan Moreau <nathan.moreau <at> m4x.org>
Date: Wed, 29 Apr 2020 18:02:01 UTC
Severity: normal
Tags: fixed
Found in version 27.0.50
Fixed in version 28.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #26 received at 40967 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Hi Lars,
Thanks for having a look. This looks good to me.
Best regards,
Nathan
On Thu, 1 Oct 2020 at 19:56, Lars Ingebrigtsen <larsi <at> gnus.org> wrote:
> Nathan Moreau <nathan.moreau <at> m4x.org> writes:
>
> > Gentle ping. This can be rebased on whichever branch you like if it
> > does not apply cleanly (currently it is based on d6f6353cfdbbea for
> > because it happened to be checked-out locally).
>
> The patch does not apply cleanly to Emacs 28, so I've respun it. There
> were some conflicts; please check that it looks correct.
>
> diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
> index 3852a64550..46c44fa54b 100644
> --- a/lisp/vc/vc.el
> +++ b/lisp/vc/vc.el
> @@ -1038,7 +1038,9 @@ vc-deduce-fileset
> list of marked files, or the current directory if no files are
> marked.
> Otherwise, if the current buffer is visiting a version-controlled
> -file, FILESET is a single-file list containing that file's name.
> +file or is an indirect buffer whose base buffer visits a
> +version-controlled file, FILESET is a single-file list containing
> +that file's name.
> Otherwise, if ALLOW-UNREGISTERED is non-nil and the visited file
> is unregistered, FILESET is a single-file list containing the
> name of the visited file.
> @@ -1052,6 +1054,14 @@ vc-deduce-fileset
> the returned list.
>
> BEWARE: this function may change the current buffer."
> + (with-current-buffer (or (buffer-base-buffer) (current-buffer))
> + (vc-deduce-fileset-1 not-state-changing
> + allow-unregistered
> + state-model-only-files)))
> +
> +(defun vc-deduce-fileset-1 (not-state-changing
> + allow-unregistered
> + state-model-only-files)
> (let (backend)
> (cond
> ((derived-mode-p 'vc-dir-mode)
> @@ -1073,7 +1083,7 @@ vc-deduce-fileset
> (derived-mode-p 'dired-mode)))))
> (progn ;FIXME: Why not `with-current-buffer'?
> --Stef.
> (set-buffer vc-parent-buffer)
> - (vc-deduce-fileset not-state-changing allow-unregistered
> state-model-only-files)))
> + (vc-deduce-fileset-1 not-state-changing allow-unregistered
> state-model-only-files)))
> ((and (not buffer-file-name)
> (setq backend (vc-responsible-backend default-directory)))
> (list backend nil))
> @@ -1883,6 +1893,10 @@ vc-root-version-diff
> t (list backend (list rootdir)) rev1 rev2
> (called-interactively-p 'interactive)))))
>
> +(defun vc-maybe-buffer-sync (not-urgent)
> + (with-current-buffer (or (buffer-base-buffer) (current-buffer))
> + (when buffer-file-name (vc-buffer-sync not-urgent))))
> +
> ;;;###autoload
> (defun vc-diff (&optional historic not-urgent)
> "Display diffs between file revisions.
> @@ -1895,6 +1909,7 @@ vc-diff
> (interactive (list current-prefix-arg t))
> (if historic
> (call-interactively 'vc-version-diff)
> + (vc-maybe-buffer-sync not-urgent)
> (let ((fileset (vc-deduce-fileset t)))
> (vc-buffer-sync-fileset fileset not-urgent)
> (vc-diff-internal t fileset nil nil
> @@ -1981,7 +1996,7 @@ vc-ediff
> (interactive (list current-prefix-arg t))
> (if historic
> (call-interactively 'vc-version-ediff)
> - (when buffer-file-name (vc-buffer-sync not-urgent))
> + (vc-maybe-buffer-sync not-urgent)
> (vc-version-ediff (cadr (vc-deduce-fileset t)) nil nil)))
>
> ;;;###autoload
> @@ -1998,7 +2013,7 @@ vc-root-diff
> (if historic
> ;; We want the diff for the VC root dir.
> (call-interactively 'vc-root-version-diff)
> - (when buffer-file-name (vc-buffer-sync not-urgent))
> + (vc-maybe-buffer-sync not-urgent)
> (let ((backend (vc-deduce-backend))
> (default-directory default-directory)
> rootdir working-revision)
> @@ -2038,17 +2053,18 @@ vc-revision-other-window
> If the current file is named `F', the revision is named `F.~REV~'.
> If `F.~REV~' already exists, use it instead of checking it out again."
> (interactive
> - (save-current-buffer
> + (with-current-buffer (or (buffer-base-buffer) (current-buffer))
> (vc-ensure-vc-buffer)
> (list
> (vc-read-revision "Revision to visit (default is working revision):
> "
> (list buffer-file-name)))))
> - (vc-ensure-vc-buffer)
> - (let* ((file buffer-file-name)
> - (revision (if (string-equal rev "")
> - (vc-working-revision file)
> - rev)))
> - (switch-to-buffer-other-window (vc-find-revision file revision))))
> + (with-current-buffer (or (buffer-base-buffer) (current-buffer))
> + (vc-ensure-vc-buffer)
> + (let* ((file buffer-file-name)
> + (revision (if (string-equal rev "")
> + (vc-working-revision file)
> + rev)))
> + (switch-to-buffer-other-window (vc-find-revision file revision)))))
>
> (defun vc-find-revision (file revision &optional backend)
> "Read REVISION of FILE into a buffer and return the buffer.
>
>
> --
> (domestic pets only, the antidote for overdose, milk.)
> bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]
This bug report was last modified 4 years and 223 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.