Subject: Re: bug#63949: 30.0.50; `vc-print-log´ does not erase buffer when called from *vc-change-log* buffer, at least for CVS logs

From: Eli Zaretskii <[email-masked]>
Date: Sat, 10 Jun 2023 20:23:06 +0300

> Date: Sat, 10 Jun 2023 17:44:26 +0200
> Cc: [email-masked], [email-masked]
> From: Jens Schmidt <[email-masked]>
> 
> On 2023-06-10  08:01, Eli Zaretskii wrote:
> 
> > Why do you think it's a problem?  I can justify this behavior, at 
> > least in some use cases.
> 
> Let's distinguish "VC-controlled buffers" like the buffer of a
> VC-controlled file or a *vc-dir* buffer or a dired buffer of
> VC-controlled directory.  And "VC working buffers", like
> *vc-change-log*, *vc-log*, *vc-diff*.

First, let me clarify what I alluded to as "a problem": I meant the
fact that "C-x v l" in a *vc-change-log* buffer shows the log for the
entire repository.  How this is accomplished by setting
vc-parent-buffer is an implementation detail.

> It is my understanding that `vc-parent-buffer' in a VC working buffer
> points to the VC-controlled buffer from which it originates.  The
> rationale of that variable is to allow VC operations from a VC working
> buffer as if executed on the original VC-controlled buffer.  So I can do
> C-x v l, pick a commit, do a C-x v ~ on that commit, then a C-x v =, and
> all these operations would automagically relate to the original
> VC-controlled buffer.  At least I use that concept frequently.

If the backend is a VCS that records changes per-file, what you want
will happen automatically, since "C-x v l" and other operations must
in general refer to a file with those VCSes.  For backends that record
changes per-repository, why does it make sense that typing "C-x v l"
from a buffer that already shows a log should produce the same log
again?

> The documentation on `vc-parent-buffer', unfortunately, is out of date 
> and does not necessarily support my understanding:
> 
>    ;; In a log entry buffer, this is a local variable
>    ;; that points to the buffer for which it was made
>    ;; (either a file, or a directory buffer).

We need to define what we want vc-parent-buffer to mean, and then we
should adjust the documentation and keep our promises about that
variable in the future.

> However, this has been working as described by me up to and including
> Emacs 27.  So at least we can say that the fix fur bug#40967 has changed
> established behavior.

Probably because no one realized that this must be the established
behavior.

> That logic used to work as intended (by me) up to Nathan's commit, which
> put a `with-current-buffer' around the whole function and rendered the
> `set-buffer' side effect pointless.
> 
> Let's put it that way: The pre-28 logic of handling the VC parent buffer
> was not necessarily clean, as also pointed out by Stefan.  But I think
> the concept of having a stable VC parent buffer across multiple VC
> operations is nice, and changing it midway according to rather unclear
> rules undesirable.
> 
> Ideally, we would have a fix that handled indirect buffers and VC parent
> buffers (which are somewhat similar by concept) all consistently and
> nicely and in a stable way, at the same time fixing both issues that I 
> have.  I'll mediate about that...

If you can suggest changes to make the treatment of vc-parent-buffer
more consistent, that would be good, I think.

I'd also like to hear Dmitry's views on these issues.  He was until
now silent in this discussion, AFAICT.