From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Nathan Moreau Newsgroups: gmane.emacs.bugs Subject: bug#40967: 27.0.50; vc-diff in indirect buffers Date: Fri, 2 Oct 2020 02:27:40 +0200 Message-ID: References: <4a643eda-2b72-857e-4d25-3b9bcbd1e086@yandex.ru> <5f6e0c6c-d699-d9ff-34f6-a8967fc84dfb@orcon.net.nz> <77dd86b8-c5f8-5a91-a424-74feed90b037@yandex.ru> <87d0214ypv.fsf@gnus.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="000000000000018e6b05b0a534d3" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="15986"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Phil Sainty , 40967@debbugs.gnu.org, Dmitry Gutov To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Oct 02 02:28:47 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 1kO8wJ-00041l-9t for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 02 Oct 2020 02:28:47 +0200 Original-Received: from localhost ([::1]:60294 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kO8wI-0005Zu-4z for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 01 Oct 2020 20:28:46 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kO8va-0005XG-PK for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 20:28:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55433) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kO8va-0004WT-Ff for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 20:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kO8va-00042A-Ax for bug-gnu-emacs@gnu.org; Thu, 01 Oct 2020 20:28:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Nathan Moreau Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 02 Oct 2020 00:28: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.160159848115498 (code B ref 40967); Fri, 02 Oct 2020 00:28:02 +0000 Original-Received: (at 40967) by debbugs.gnu.org; 2 Oct 2020 00:28:01 +0000 Original-Received: from localhost ([127.0.0.1]:38746 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO8vY-00041t-CF for submit@debbugs.gnu.org; Thu, 01 Oct 2020 20:28:00 -0400 Original-Received: from mail-vk1-f181.google.com ([209.85.221.181]:42024) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kO8vV-00041g-Q4 for 40967@debbugs.gnu.org; Thu, 01 Oct 2020 20:27:59 -0400 Original-Received: by mail-vk1-f181.google.com with SMTP id b4so123048vkh.9 for <40967@debbugs.gnu.org>; Thu, 01 Oct 2020 17:27:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=iRlENu/t/qQURuMgk/X7bgxpE1uEhGoeZ80gIJ8YRKg=; b=rqX2pHHLxqyLW5ZnNIFnjdOpdHq8y7mp5rNYtrsp3bpLIw1//ZQKaqsY39Y4irplmQ CSkt5XbKgPcliADkfdskoS+w+hu4z2xRP9ZNZ6vDI4b1rkgQAwFAu3s1EJz0+t9cw5wu p5LfdjRN9N7QYoejWVRnTveF4nFGxNbFDAIPK0+SdYEjFvRLu/kyq3FbK83hM7UzFo5/ 11Ks1M2z3Jg04q5DmeHstfB5A7zA+TuMuYXz72LxTRTNYAOO8cvGWWXWNyzyWhyi6JxP AWbGpbFdrZQIv3pkMBcTzvTir3oobeeKVvgLlInEm5HGBDEJ/JAGjqi3q9P/Nsz62HZT Yyjw== X-Gm-Message-State: AOAM532hdooz9d/muHgcptftxz6DasoKmjq0kdCU/ph+EtnPZijy41CK wX7WT4878OQFNn5W9VLonvaJEkw4NbP3QSZI8bI= X-Google-Smtp-Source: ABdhPJzpFpsDzKQv/n9aaId1p92acofpSSEBNvK0z0ArqKETtY0JFJP/rFoAyfIkAlRbZzH/usr2Pmr14B/2mncOvuc= X-Received: by 2002:ac5:ccd3:: with SMTP id j19mr7049032vkn.8.1601598472161; Thu, 01 Oct 2020 17:27:52 -0700 (PDT) In-Reply-To: <87d0214ypv.fsf@gnus.org> 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:189601 Archived-At: --000000000000018e6b05b0a534d3 Content-Type: text/plain; charset="UTF-8" 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 wrote: > 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 > --000000000000018e6b05b0a534d3 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi Lars,

Thanks for having a= look. This looks good to me.

Best regards,
<= div>Nathan

On Thu, 1 Oct 2020 at 19:56, Lars Ingebrigtsen <larsi@gnus.org> wrote:
Nathan Moreau <nathan.moreau@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.=C2=A0 = 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
=C2=A0list of marked files, or the current directory if no files are
=C2=A0marked.
=C2=A0Otherwise, 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.
=C2=A0Otherwise, if ALLOW-UNREGISTERED is non-nil and the visited file
=C2=A0is unregistered, FILESET is a single-file list containing the
=C2=A0name of the visited file.
@@ -1052,6 +1054,14 @@ vc-deduce-fileset
=C2=A0the returned list.

=C2=A0BEWARE: this function may change the current buffer."
+=C2=A0 (with-current-buffer (or (buffer-base-buffer) (current-buffer))
+=C2=A0 =C2=A0 (vc-deduce-fileset-1 not-state-changing
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0allow-unregistered
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0state-model-only-files)))
+
+(defun vc-deduce-fileset-1 (not-state-changing
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 allow-unregistered
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 state-model-only-files)
=C2=A0 =C2=A0(let (backend)
=C2=A0 =C2=A0 =C2=A0(cond
=C2=A0 =C2=A0 =C2=A0 ((derived-mode-p 'vc-dir-mode)
@@ -1073,7 +1083,7 @@ vc-deduce-fileset
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (derived-mode-p= 'dired-mode)))))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(progn=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 ;FIXME: Why not `with-current-buffer'? --Stef.
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (set-buffer vc-parent-buffer)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0(vc-deduce-fileset not-state-changing allow-unr= egistered state-model-only-files)))
+=C2=A0 =C2=A0 =C2=A0 =C2=A0(vc-deduce-fileset-1 not-state-changing allow-u= nregistered state-model-only-files)))
=C2=A0 =C2=A0 =C2=A0 ((and (not buffer-file-name)
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0(setq backend (vc-responsible-back= end default-directory)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(list backend nil))
@@ -1883,6 +1893,10 @@ vc-root-version-diff
=C2=A0 =C2=A0 =C2=A0 =C2=A0 t (list backend (list rootdir)) rev1 rev2
=C2=A0 =C2=A0 =C2=A0 =C2=A0 (called-interactively-p 'interactive)))))
+(defun vc-maybe-buffer-sync (not-urgent)
+=C2=A0 (with-current-buffer (or (buffer-base-buffer) (current-buffer))
+=C2=A0 =C2=A0 (when buffer-file-name (vc-buffer-sync not-urgent))))
+
=C2=A0;;;###autoload
=C2=A0(defun vc-diff (&optional historic not-urgent)
=C2=A0 =C2=A0"Display diffs between file revisions.
@@ -1895,6 +1909,7 @@ vc-diff
=C2=A0 =C2=A0(interactive (list current-prefix-arg t))
=C2=A0 =C2=A0(if historic
=C2=A0 =C2=A0 =C2=A0 =C2=A0(call-interactively 'vc-version-diff)
+=C2=A0 =C2=A0 (vc-maybe-buffer-sync not-urgent)
=C2=A0 =C2=A0 =C2=A0(let ((fileset (vc-deduce-fileset t)))
=C2=A0 =C2=A0 =C2=A0 =C2=A0(vc-buffer-sync-fileset fileset not-urgent)
=C2=A0 =C2=A0 =C2=A0 =C2=A0(vc-diff-internal t fileset nil nil
@@ -1981,7 +1996,7 @@ vc-ediff
=C2=A0 =C2=A0(interactive (list current-prefix-arg t))
=C2=A0 =C2=A0(if historic
=C2=A0 =C2=A0 =C2=A0 =C2=A0(call-interactively 'vc-version-ediff)
-=C2=A0 =C2=A0 (when buffer-file-name (vc-buffer-sync not-urgent))
+=C2=A0 =C2=A0 (vc-maybe-buffer-sync not-urgent)
=C2=A0 =C2=A0 =C2=A0(vc-version-ediff (cadr (vc-deduce-fileset t)) nil nil)= ))

=C2=A0;;;###autoload
@@ -1998,7 +2013,7 @@ vc-root-diff
=C2=A0 =C2=A0(if historic
=C2=A0 =C2=A0 =C2=A0 =C2=A0;; We want the diff for the VC root dir.
=C2=A0 =C2=A0 =C2=A0 =C2=A0(call-interactively 'vc-root-version-diff) -=C2=A0 =C2=A0 (when buffer-file-name (vc-buffer-sync not-urgent))
+=C2=A0 =C2=A0 (vc-maybe-buffer-sync not-urgent)
=C2=A0 =C2=A0 =C2=A0(let ((backend (vc-deduce-backend))
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (default-directory default-directory) =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 rootdir working-revision)
@@ -2038,17 +2053,18 @@ vc-revision-other-window
=C2=A0If the current file is named `F', the revision is named `F.~REV~&= #39;.
=C2=A0If `F.~REV~' already exists, use it instead of checking it out ag= ain."
=C2=A0 =C2=A0(interactive
-=C2=A0 =C2=A0(save-current-buffer
+=C2=A0 =C2=A0(with-current-buffer (or (buffer-base-buffer) (current-buffer= ))
=C2=A0 =C2=A0 =C2=A0 (vc-ensure-vc-buffer)
=C2=A0 =C2=A0 =C2=A0 (list
=C2=A0 =C2=A0 =C2=A0 =C2=A0(vc-read-revision "Revision to visit (defau= lt is working revision): "
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0(list buffer-file-name)))))
-=C2=A0 (vc-ensure-vc-buffer)
-=C2=A0 (let* ((file buffer-file-name)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 (revision (if (string-equal rev "")<= br> -=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0(vc-working-revision file)
-=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0rev))= )
-=C2=A0 =C2=A0 (switch-to-buffer-other-window (vc-find-revision file revisi= on))))
+=C2=A0 (with-current-buffer (or (buffer-base-buffer) (current-buffer))
+=C2=A0 =C2=A0 (vc-ensure-vc-buffer)
+=C2=A0 =C2=A0 (let* ((file buffer-file-name)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 (revision (if (string-equal rev "&= quot;)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (vc-working-revision file)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 rev)))
+=C2=A0 =C2=A0 =C2=A0 (switch-to-buffer-other-window (vc-find-revision file= revision)))))

=C2=A0(defun vc-find-revision (file revision &optional backend)
=C2=A0 =C2=A0"Read REVISION of FILE into a buffer and return the buffe= r.


--
(domestic pets only, the antidote for overdose, milk.)
=C2=A0 =C2=A0bloggy blog: http://lars.ingebrigtsen.no
--000000000000018e6b05b0a534d3--