;;; tramp-vc.el --- Version control integration for TRAMP.el
;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
-;; 2005 Free Software Foundation, Inc.
+;; 2005, 2006 Free Software Foundation, Inc.
;; Author: Daniel Pittman <daniel@danann.net>
;; Keywords: comm, processes
;; Daniel Pittman <daniel@danann.net>
;;-(if (fboundp 'vc-call-backend)
;;- () ;; This is the new VC for which we don't have an appropriate advice yet
+;;-)
(unless (fboundp 'process-file)
-(if (fboundp 'vc-call-backend)
+ (if (fboundp 'vc-call-backend)
+ (defadvice vc-do-command
+ (around tramp-advice-vc-do-command
+ (buffer okstatus command file &rest flags)
+ activate)
+ "Invoke tramp-vc-do-command for tramp files."
+ (let ((file (symbol-value 'file))) ;pacify byte-compiler
+ (if (or (and (stringp file) (tramp-tramp-file-p file))
+ (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
+ (setq ad-return-value
+ (apply 'tramp-vc-do-command-new buffer okstatus command
+ file ;(or file (buffer-file-name))
+ flags))
+ ad-do-it)))
(defadvice vc-do-command
(around tramp-advice-vc-do-command
- (buffer okstatus command file &rest flags)
- activate)
+ (buffer okstatus command file last &rest flags)
+ activate)
"Invoke tramp-vc-do-command for tramp files."
- (let ((file (symbol-value 'file))) ;pacify byte-compiler
- (if (or (and (stringp file) (tramp-tramp-file-p file))
- (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
- (setq ad-return-value
- (apply 'tramp-vc-do-command-new buffer okstatus command
- file ;(or file (buffer-file-name))
- flags))
- ad-do-it)))
- (defadvice vc-do-command
- (around tramp-advice-vc-do-command
- (buffer okstatus command file last &rest flags)
- activate)
- "Invoke tramp-vc-do-command for tramp files."
- (let ((file (symbol-value 'file))) ;pacify byte-compiler
- (if (or (and (stringp file) (tramp-tramp-file-p file))
- (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
- (setq ad-return-value
- (apply 'tramp-vc-do-command buffer okstatus command
- (or file (buffer-file-name)) last flags))
- ad-do-it)))))
-;;-)
+ (let ((file (symbol-value 'file))) ;pacify byte-compiler
+ (if (or (and (stringp file) (tramp-tramp-file-p file))
+ (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
+ (setq ad-return-value
+ (apply 'tramp-vc-do-command buffer okstatus command
+ (or file (buffer-file-name)) last flags))
+ ad-do-it))))
+
+ (add-hook 'tramp-unload-hook
+ '(lambda () (ad-unadvise 'vc-do-command))))
;; XEmacs uses this to do some of its work. Like vc-do-command, we
(or file (buffer-file-name)) args))
ad-do-it)))
+(add-hook 'tramp-unload-hook
+ '(lambda () (ad-unadvise 'vc-simple-command)))
+
;; `vc-workfile-unchanged-p'
;; This function does not deal well with remote files, so we do the
(tramp-vc-workfile-unchanged-p filename want-differences-if-changed))
ad-do-it))
+(add-hook 'tramp-unload-hook
+ '(lambda () (ad-unadvise 'vc-workfile-unchanged-p)))
+
;; Redefine a function from vc.el -- allow tramp files.
;; `save-match-data' seems not to be required -- it isn't in
(t (error "tramp-handle-vc-user-login-name cannot cope!")))))))
-(defadvice vc-user-login-name
- (around tramp-vc-user-login-name activate)
- "Support for files on remote machines accessed by TRAMP."
- ;; We rely on the fact that `file' is bound when this is called.
- ;; This appears to be the case everywhere in vc.el and vc-hooks.el
- ;; as of Emacs 20.5.
- ;;
- ;; CCC TODO there should be a real solution! Talk to Andre Spiegel
- ;; about this.
- (let ((file (when (boundp 'file)
- (symbol-value 'file)))) ;pacify byte-compiler
- (or (and (stringp file)
- (tramp-tramp-file-p file) ; tramp file
- (setq ad-return-value
- (save-match-data
- (tramp-handle-vc-user-login-name uid)))) ; get the owner name
- ad-do-it))) ; else call the original
+;; The following defadvice is no longer necessary after changes in VC
+;; on 2006-01-25, Andre.
+
+(unless (fboundp 'process-file)
+ (defadvice vc-user-login-name
+ (around tramp-vc-user-login-name activate)
+ "Support for files on remote machines accessed by TRAMP."
+ ;; We rely on the fact that `file' is bound when this is called.
+ ;; This appears to be the case everywhere in vc.el and vc-hooks.el
+ ;; as of Emacs 20.5.
+ ;;
+ ;; With Emacs 22, the definition of `vc-user-login-name' has been
+ ;; changed. It doesn't need to be adviced any longer.
+ (let ((file (when (boundp 'file)
+ (symbol-value 'file)))) ;pacify byte-compiler
+ (or (and (stringp file)
+ (tramp-tramp-file-p file) ; tramp file
+ (setq ad-return-value
+ (save-match-data
+ (tramp-handle-vc-user-login-name uid)))) ; get the owner name
+ ad-do-it))) ; else call the original
+
+ (add-hook 'tramp-unload-hook
+ '(lambda () (ad-unadvise 'vc-user-login-name))))
;; Determine the name of the user owning a file.
(tramp-file-owner filename)))) ; get the owner name
ad-do-it))) ; else call the original
+(add-hook 'tramp-unload-hook
+ '(lambda () (ad-unadvise 'vc-file-owner)))
+
;; We need to make the version control software backend version
;; information local to the current buffer. This is because each TRAMP
(tramp-tramp-file-p (buffer-file-name)))
(make-local-variable 'vc-rcs-release)
(setq vc-rcs-release nil)))
+
(add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t)
+(add-hook 'tramp-unload-hook
+ '(lambda ()
+ (remove-hook 'find-file-hooks 'tramp-vc-setup-for-remote)))
;; No need to load this again if anyone asks.
(provide 'tramp-vc)