unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
@ 2020-06-20 23:55 Juri Linkov
  2020-06-21  0:07 ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2020-06-20 23:55 UTC (permalink / raw)
  To: 41974

For example, typing

  M-x vc-print-branch-log RET

on the project's *compilation* buffer signals the error:

  "Buffer *compilation* is not associated with a file"

I think this restriction should be lifted, so vc commands should
work even when called on non-file buffers whose default-directory
is inside the vc project.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-20 23:55 bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer Juri Linkov
@ 2020-06-21  0:07 ` Dmitry Gutov
  2020-06-21 22:51   ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2020-06-21  0:07 UTC (permalink / raw)
  To: Juri Linkov, 41974

On 21.06.2020 02:55, Juri Linkov wrote:
> I think this restriction should be lifted, so vc commands should
> work even when called on non-file buffers whose default-directory
> is inside the vc project.

Agreed.

Does this patch help, or does it miss more cases?

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9b12d44978..36013fcdc9 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -2563,7 +2563,7 @@ vc-print-branch-log
      (vc-read-revision "Branch to log: ")))
    (when (equal branch "")
      (error "No branch specified"))
-  (let* ((backend (vc-responsible-backend default-directory))
+  (let* ((backend (vc-deduce-backend))
           (rootdir (vc-call-backend backend 'root default-directory)))
      (vc-print-log-internal backend
                             (list rootdir) branch t





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-21  0:07 ` Dmitry Gutov
@ 2020-06-21 22:51   ` Juri Linkov
  2020-06-22  0:59     ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2020-06-21 22:51 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 41974

> On 21.06.2020 02:55, Juri Linkov wrote:
>> I think this restriction should be lifted, so vc commands should
>> work even when called on non-file buffers whose default-directory
>> is inside the vc project.
>
> Agreed.
>
> Does this patch help, or does it miss more cases?
>
> diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
> index 9b12d44978..36013fcdc9 100644
> --- a/lisp/vc/vc.el
> +++ b/lisp/vc/vc.el
> @@ -2563,7 +2563,7 @@ vc-print-branch-log
>      (vc-read-revision "Branch to log: ")))
>    (when (equal branch "")
>      (error "No branch specified"))
> -  (let* ((backend (vc-responsible-backend default-directory))
> +  (let* ((backend (vc-deduce-backend))
>           (rootdir (vc-call-backend backend 'root default-directory)))
>      (vc-print-log-internal backend
>                             (list rootdir) branch t

Strange, this patch has no effect, the same error remains.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-21 22:51   ` Juri Linkov
@ 2020-06-22  0:59     ` Dmitry Gutov
  2020-06-22 23:38       ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2020-06-22  0:59 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 41974

On 22.06.2020 01:51, Juri Linkov wrote:
> Strange, this patch has no effect, the same error remains.

Sorry, that was a brain fart.

How about this:

diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index 9b12d44978..6bb72d8976 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -1074,11 +1074,11 @@ vc-deduce-fileset
        (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)))
-     ((and (derived-mode-p 'log-view-mode)
+     ((and (not buffer-file-name)
  	   (setq backend (vc-responsible-backend default-directory)))
        (list backend nil))
       ((not buffer-file-name)
-       (error "Buffer %s is not associated with a file" (buffer-name)))
+       (error "Buffer %s is not recognized by any VC backend" 
(buffer-name)))
       ((and allow-unregistered (not (vc-registered buffer-file-name)))
        (if state-model-only-files
  	  (list (vc-backend-for-registration (buffer-file-name))





^ permalink raw reply related	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-22  0:59     ` Dmitry Gutov
@ 2020-06-22 23:38       ` Juri Linkov
  2020-06-23  0:34         ` Dmitry Gutov
  0 siblings, 1 reply; 7+ messages in thread
From: Juri Linkov @ 2020-06-22 23:38 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 41974

> How about this:
>
> diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
> index 9b12d44978..6bb72d8976 100644
> --- a/lisp/vc/vc.el
> +++ b/lisp/vc/vc.el
> @@ -1074,11 +1074,11 @@ vc-deduce-fileset
>        (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)))
> -     ((and (derived-mode-p 'log-view-mode)
> +     ((and (not buffer-file-name)
>  	   (setq backend (vc-responsible-backend default-directory)))
>        (list backend nil))

Thanks for finding the right place to fix, and it should also fix all
other vc commands that failed on non-file buffers.

>       ((not buffer-file-name)
> -       (error "Buffer %s is not associated with a file" (buffer-name)))
> +       (error "Buffer %s is not recognized by any VC backend"

It seems this code is not necessary anymore because before this code
gets executed, vc-responsible-backend already signals its error
"No VC backend is responsible for file".





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-22 23:38       ` Juri Linkov
@ 2020-06-23  0:34         ` Dmitry Gutov
  2020-06-23 23:54           ` Juri Linkov
  0 siblings, 1 reply; 7+ messages in thread
From: Dmitry Gutov @ 2020-06-23  0:34 UTC (permalink / raw)
  To: Juri Linkov; +Cc: 41974

On 23.06.2020 02:38, Juri Linkov wrote:
>>        ((not buffer-file-name)
>> -       (error "Buffer %s is not associated with a file" (buffer-name)))
>> +       (error "Buffer %s is not recognized by any VC backend"
> It seems this code is not necessary anymore because before this code
> gets executed, vc-responsible-backend already signals its error
> "No VC backend is responsible for file".

Even better.





^ permalink raw reply	[flat|nested] 7+ messages in thread

* bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer
  2020-06-23  0:34         ` Dmitry Gutov
@ 2020-06-23 23:54           ` Juri Linkov
  0 siblings, 0 replies; 7+ messages in thread
From: Juri Linkov @ 2020-06-23 23:54 UTC (permalink / raw)
  To: Dmitry Gutov; +Cc: 41974

tags 41974 fixed
close 41974 28.0.50
quit

>>>        ((not buffer-file-name)
>>> -       (error "Buffer %s is not associated with a file" (buffer-name)))
>>> +       (error "Buffer %s is not recognized by any VC backend"
>> It seems this code is not necessary anymore because before this code
>> gets executed, vc-responsible-backend already signals its error
>> "No VC backend is responsible for file".
>
> Even better.

Thanks, pushed to master.





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-06-23 23:54 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-20 23:55 bug#41974: 28.0.50; Some vc commands refuse to work when called on non-file buffer Juri Linkov
2020-06-21  0:07 ` Dmitry Gutov
2020-06-21 22:51   ` Juri Linkov
2020-06-22  0:59     ` Dmitry Gutov
2020-06-22 23:38       ` Juri Linkov
2020-06-23  0:34         ` Dmitry Gutov
2020-06-23 23:54           ` Juri Linkov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).