GNU bug report logs - #18535
tramp alters `vc-handled-backends'

Previous Next

Package: emacs;

Reported by: Emilio Lopes <eclig <at> gmx.net>

Date: Tue, 23 Sep 2014 10:55:02 UTC

Severity: normal

Merged with 18647

Found in version 24.4.50

Done: Stefan Monnier <monnier <at> iro.umontreal.ca>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 18535 in the body.
You can then email your comments to 18535 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#18535; Package emacs. (Tue, 23 Sep 2014 10:55:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Emilio Lopes <eclig <at> gmx.net>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Tue, 23 Sep 2014 10:55:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Emilio Lopes <eclig <at> gmx.net>
To: bug-gnu-emacs <at> gnu.org
Subject: tramp alters `vc-handled-backends'
Date: Tue, 23 Sep 2014 12:53:38 +0200
`tramp-sh-handle-vc-registered' can permanently alter the value of
`vc-handled-backends' causing Emacs to stop recognizing version
controlled files as such.  This happened to me a couple of times after
having pressed `C-g' while some `tramp' operation was apparently
hanging.

Here is a patch:

=== modified file 'lisp/ChangeLog'
--- lisp/ChangeLog    2014-09-16 13:36:04 +0000
+++ lisp/ChangeLog    2014-09-23 09:27:10 +0000
@@ -1,4 +1,9 @@
+2014-09-23  Emilio C. Lopes  <eclig <at> gmx.net>
+
+    * net/tramp-sh.el (tramp-sh-handle-vc-registered): use `unwind-protect'
+    to avoid altering `vc-handled-backends' permanently.
+
 2014-09-22  Kan-Ru Chen  <kanru <at> kanru.info>

    * window.el (fit-window-to-buffer): When counting buffer width,
    count the whole visible buffer.  Correctly convert the body-height
=== modified file 'lisp/net/tramp-sh.el'
--- lisp/net/tramp-sh.el    2014-09-08 15:52:04 +0000
+++ lisp/net/tramp-sh.el    2014-09-23 09:27:10 +0000
@@ -3456,30 +3456,33 @@
     ;; calls shall be answered from the file cache.  We unset
     ;; `process-file-side-effects' and `remote-file-name-inhibit-cache'
     ;; in order to keep the cache.
-    (let ((vc-handled-backends vc-handled-backends)
+    (let ((vc-handled-backends-saved vc-handled-backends)
           remote-file-name-inhibit-cache process-file-side-effects)
       ;; Reduce `vc-handled-backends' in order to minimize process calls.
-      (when (and (memq 'Bzr vc-handled-backends)
-             (boundp 'vc-bzr-program)
-             (not (with-tramp-connection-property v vc-bzr-program
-                (tramp-find-executable
-                 v vc-bzr-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Bzr vc-handled-backends)))
-      (when (and (memq 'Git vc-handled-backends)
-             (boundp 'vc-git-program)
-             (not (with-tramp-connection-property v vc-git-program
-                (tramp-find-executable
-                 v vc-git-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Git vc-handled-backends)))
-      (when (and (memq 'Hg vc-handled-backends)
-             (boundp 'vc-hg-program)
-             (not (with-tramp-connection-property v vc-hg-program
-                (tramp-find-executable
-                 v vc-hg-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Hg vc-handled-backends)))
-      ;; Run.
-      (ignore-errors
-        (tramp-run-real-handler 'vc-registered (list file))))))))
+          (unwind-protect
+              (progn
+                (when (and (memq 'Bzr vc-handled-backends)
+                           (boundp 'vc-bzr-program)
+                           (not (with-tramp-connection-property v
vc-bzr-program
+                                  (tramp-find-executable
+                                   v vc-bzr-program
(tramp-get-remote-path v)))))
+                  (setq vc-handled-backends (delq 'Bzr vc-handled-backends)))
+                (when (and (memq 'Git vc-handled-backends)
+                           (boundp 'vc-git-program)
+                           (not (with-tramp-connection-property v
vc-git-program
+                                  (tramp-find-executable
+                                   v vc-git-program
(tramp-get-remote-path v)))))
+                  (setq vc-handled-backends (delq 'Git vc-handled-backends)))
+                (when (and (memq 'Hg vc-handled-backends)
+                           (boundp 'vc-hg-program)
+                           (not (with-tramp-connection-property v vc-hg-program
+                                  (tramp-find-executable
+                                   v vc-hg-program
(tramp-get-remote-path v)))))
+                  (setq vc-handled-backends (delq 'Hg vc-handled-backends)))
+                ;; Run.
+                (ignore-errors
+                  (tramp-run-real-handler 'vc-registered (list file))))
+            (setq vc-handled-backends vc-handled-backends-saved)))))))

 ;;;###tramp-autoload
 (defun tramp-sh-file-name-handler (operation &rest args)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18535; Package emacs. (Tue, 23 Sep 2014 15:38:02 GMT) Full text and rfc822 format available.

Message #8 received at 18535 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Emilio Lopes <eclig <at> gmx.net>
Cc: 18535 <at> debbugs.gnu.org
Subject: Re: bug#18535: tramp alters `vc-handled-backends'
Date: Tue, 23 Sep 2014 11:37:20 -0400
> `tramp-sh-handle-vc-registered' can permanently alter the value of
> `vc-handled-backends' causing Emacs to stop recognizing version
> controlled files as such.  This happened to me a couple of times after
> having pressed `C-g' while some `tramp' operation was apparently
> hanging.

The current code uses a `let' binding, which uses the same mechanism as
unwind-protect, so I don't think that's the source of a the problem.

The `delq' look dangerous on the other hand.  Shouldn't these be
`remq' instead?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#18535; Package emacs. (Thu, 25 Sep 2014 07:11:01 GMT) Full text and rfc822 format available.

Message #11 received at 18535 <at> debbugs.gnu.org (full text, mbox):

From: Emilio Lopes <eclig <at> gmx.net>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 18535 <at> debbugs.gnu.org
Subject: Re: bug#18535: tramp alters `vc-handled-backends'
Date: Thu, 25 Sep 2014 09:10:04 +0200
2014-09-23 17:37 GMT+02:00 Stefan Monnier <monnier <at> iro.umontreal.ca>:
>> `tramp-sh-handle-vc-registered' can permanently alter the value of
>> `vc-handled-backends' causing Emacs to stop recognizing version
>> controlled files as such.  This happened to me a couple of times after
>> having pressed `C-g' while some `tramp' operation was apparently
>> hanging.
>
> The current code uses a `let' binding, which uses the same mechanism as
> unwind-protect, so I don't think that's the source of a the problem.

Is this common behavior in Lisps?  I could not find any reference to
this in the Elisp manual.

Anyway, thanks for point this out!

> The `delq' look dangerous on the other hand.  Shouldn't these be
> `remq' instead?

yes, this seems to solve the problem.

=== modified file 'lisp/net/tramp-sh.el'
--- lisp/net/tramp-sh.el    2014-09-08 15:52:04 +0000
+++ lisp/net/tramp-sh.el    2014-09-25 07:07:25 +0000
@@ -3464,19 +3464,19 @@
              (not (with-tramp-connection-property v vc-bzr-program
                 (tramp-find-executable
                  v vc-bzr-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Bzr vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Bzr vc-handled-backends)))
       (when (and (memq 'Git vc-handled-backends)
              (boundp 'vc-git-program)
              (not (with-tramp-connection-property v vc-git-program
                 (tramp-find-executable
                  v vc-git-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Git vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Git vc-handled-backends)))
       (when (and (memq 'Hg vc-handled-backends)
              (boundp 'vc-hg-program)
              (not (with-tramp-connection-property v vc-hg-program
                 (tramp-find-executable
                  v vc-hg-program (tramp-get-remote-path v)))))
-        (setq vc-handled-backends (delq 'Hg vc-handled-backends)))
+        (setq vc-handled-backends (remq 'Hg vc-handled-backends)))
       ;; Run.
       (ignore-errors
         (tramp-run-real-handler 'vc-registered (list file))))))))




Reply sent to Stefan Monnier <monnier <at> iro.umontreal.ca>:
You have taken responsibility. (Thu, 25 Sep 2014 13:08:02 GMT) Full text and rfc822 format available.

Notification sent to Emilio Lopes <eclig <at> gmx.net>:
bug acknowledged by developer. (Thu, 25 Sep 2014 13:08:03 GMT) Full text and rfc822 format available.

Message #16 received at 18535-done <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Emilio Lopes <eclig <at> gmx.net>
Cc: 18535-done <at> debbugs.gnu.org
Subject: Re: bug#18535: tramp alters `vc-handled-backends'
Date: Thu, 25 Sep 2014 09:07:40 -0400
>> The current code uses a `let' binding, which uses the same mechanism as
>> unwind-protect, so I don't think that's the source of a the problem.
> Is this common behavior in Lisps?  I could not find any reference to
> this in the Elisp manual.

The Elisp manual's description is not in terms of implementation, so it
doesn't say that, but it does document that behavior.  E.g.:

   When that local binding is no longer in effect, the
   previously shadowed value (or lack of one) comes back.

>> The `delq' look dangerous on the other hand.  Shouldn't these be
>> `remq' instead?
> yes, this seems to solve the problem.

Thanks, installed,


        Stefan




Forcibly Merged 18535 18647. Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Tue, 07 Oct 2014 02:42:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Tue, 04 Nov 2014 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 10 years and 233 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.