From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#40967: 27.0.50; vc-diff in indirect buffers Date: Thu, 01 Oct 2020 19:56:12 +0200 Message-ID: <87d0214ypv.fsf@gnus.org> References: <4a643eda-2b72-857e-4d25-3b9bcbd1e086@yandex.ru> <5f6e0c6c-d699-d9ff-34f6-a8967fc84dfb@orcon.net.nz> <77dd86b8-c5f8-5a91-a424-74feed90b037@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="26462"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: Phil Sainty , 40967@debbugs.gnu.org, Dmitry Gutov To: Nathan Moreau Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu Oct 01 20:12:10 2020 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kO33p-0006nR-BJ for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 20:12:09 +0200 Original-Received: from localhost ([::1]:58652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO33o-0005WQ-5s for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 14:12:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39354) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kO2pC-0008Di-Nz for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:57:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:54919) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kO2pC-0008HF-A6 for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:57:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kO2pC-0002hC-A6 for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 13:57:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 01 Oct 2020 17:57:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40967 X-GNU-PR-Package: emacs Original-Received: via spool by 40967-submit@debbugs.gnu.org id=B40967.160157498710321 (code B ref 40967); Thu, 01 Oct 2020 17:57:02 +0000 Original-Received: (at 40967) by debbugs.gnu.org; 1 Oct 2020 17:56:27 +0000 Original-Received: from localhost ([127.0.0.1]:38232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO2oc-0002gP-Vs for submit@debbugs.gnu.org; Thu, 01 Oct 2020 13:56:27 -0400 Original-Received: from quimby.gnus.org ([95.216.78.240]:33602) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO2ob-0002gB-2y for 40967@debbugs.gnu.org; Thu, 01 Oct 2020 13:56:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnus.org; s=20200322; h=Content-Type:MIME-Version:Message-ID:In-Reply-To:Date: References:Subject:Cc:To:From:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=zIGs5yAWhPgDR42AJyFuKfHasN6VG5yU6jAEJlm5K3Q=; b=P4y5KUcLdr7U94rsthbHoCy2HX 26/AJhTD0JMITjxQEL+BnubOtTgH9tB/y97APeqGtYAM8PiJIIPcHjN16pi96HuEZMDaKq3MoNgS4 WCL4a25sVe7h2rC8KBBIgzVPHpOY+6yO9xSOmT7VAeSEQLK2GhJ8lQlzguN5dY7C7ogg=; Original-Received: from cm-84.212.202.86.getinternet.no ([84.212.202.86] helo=xo) by quimby with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1kO2oQ-0001K2-23; Thu, 01 Oct 2020 19:56:18 +0200 X-Now-Playing: Nanang Tatang's _Muki_: "Bunny Hop Hop" In-Reply-To: (Nathan Moreau's message of "Thu, 9 Jul 2020 23:47:40 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:189547 Archived-At: Nathan Moreau 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