]> git.eshelyaron.com Git - emacs.git/commitdiff
(vc-switch-backend): Try to be more careful with unwanted
authorStefan Monnier <monnier@iro.umontreal.ca>
Fri, 20 Oct 2006 07:58:11 +0000 (07:58 +0000)
committerStefan Monnier <monnier@iro.umontreal.ca>
Fri, 20 Oct 2006 07:58:11 +0000 (07:58 +0000)
side-effect due to mixing various backends's file properties.

lisp/ChangeLog
lisp/vc.el

index 0999e794216f0b0e6949d44aade8fcd243347bdf..44439658b5638bf87a510cb6208b9c2233c7eb1d 100644 (file)
@@ -1,5 +1,8 @@
 2006-10-20  Stefan Monnier  <monnier@iro.umontreal.ca>
 
+       * vc.el (vc-switch-backend): Try to be more careful with unwanted
+       side-effect due to mixing various backends's file properties.
+
        * vc-svn.el (vc-svn-parse-status): Remove unused arg `localp'.
        Add arg `filename' instead.  Don't set vc-backend if `filename' is set.
        Return `filename's status if applicable.  Update callers.
index d72ee4c7e4eed8b165727fc8b68ea4eee8479c23..afeba8d24090850f150959c1a320314de66fe189 100644 (file)
@@ -2682,25 +2682,32 @@ To get a prompt, use a prefix argument."
         (error "There is no version-controlled file in this buffer"))
     (let ((backend (vc-backend buffer-file-name))
          (backends nil))
-      (unless backend
-        (error "File %s is not under version control" buffer-file-name))
-      ;; Find the registered backends.
-      (dolist (backend vc-handled-backends)
-       (when (vc-call-backend backend 'registered buffer-file-name)
-         (push backend backends)))
-      ;; Find the next backend.
-      (let ((def (car (delq backend (append (memq backend backends) backends))))
-           (others (delete backend backends)))
-       (cond
-        ((null others) (error "No other backend to switch to"))
-        (current-prefix-arg
-         (intern
-          (upcase
-           (completing-read
-            (format "Switch to backend [%s]: " def)
-            (mapcar (lambda (b) (list (downcase (symbol-name b)))) backends)
-            nil t nil nil (downcase (symbol-name def))))))
-       (t def))))))
+      (unwind-protect
+         (progn
+           (unless backend
+             (error "File %s is not under version control" buffer-file-name))
+           ;; Find the registered backends.
+           (dolist (backend vc-handled-backends)
+             (when (vc-call-backend backend 'registered buffer-file-name)
+               (push backend backends)))
+           ;; Find the next backend.
+           (let ((def (car (delq backend
+                                 (append (memq backend backends) backends))))
+                 (others (delete backend backends)))
+             (cond
+              ((null others) (error "No other backend to switch to"))
+              (current-prefix-arg
+               (intern
+                (upcase
+                 (completing-read
+                  (format "Switch to backend [%s]: " def)
+                  (mapcar (lambda (b) (list (downcase (symbol-name b)))) backends)
+                  nil t nil nil (downcase (symbol-name def))))))
+              (t def))))
+       ;; Calling the `registered' method can mess up the file
+       ;; properties, so we want to revert them to what they were.
+       (if (and backend (delete backend backends))
+           (vc-call-backend backend 'registered buffer-file-name))))))
   (unless (eq backend (vc-backend file))
     (vc-file-clearprops file)
     (vc-file-setprop file 'vc-backend backend)