Mercurial > emacs
comparison lisp/net/tramp-vc.el @ 68335:118ceefc8263
Sync with Tramp 2.0.52.
author | Michael Albinus <michael.albinus@gmx.de> |
---|---|
date | Sun, 22 Jan 2006 21:59:55 +0000 |
parents | 34bd8e434dd7 |
children | 774d8922e2c3 5b7d410e31f9 |
comparison
equal
deleted
inserted
replaced
68334:def0ffff047f | 68335:118ceefc8263 |
---|---|
1 ;;; tramp-vc.el --- Version control integration for TRAMP.el | 1 ;;; tramp-vc.el --- Version control integration for TRAMP.el |
2 | 2 |
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, | 3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004, |
4 ;; 2005 Free Software Foundation, Inc. | 4 ;; 2005, 2006 Free Software Foundation, Inc. |
5 | 5 |
6 ;; Author: Daniel Pittman <daniel@danann.net> | 6 ;; Author: Daniel Pittman <daniel@danann.net> |
7 ;; Keywords: comm, processes | 7 ;; Keywords: comm, processes |
8 | 8 |
9 ;; This file is part of GNU Emacs. | 9 ;; This file is part of GNU Emacs. |
218 ;; This is needed to handle remote VC correctly - else we test against the | 218 ;; This is needed to handle remote VC correctly - else we test against the |
219 ;; local VC system and get things wrong... | 219 ;; local VC system and get things wrong... |
220 ;; Daniel Pittman <daniel@danann.net> | 220 ;; Daniel Pittman <daniel@danann.net> |
221 ;;-(if (fboundp 'vc-call-backend) | 221 ;;-(if (fboundp 'vc-call-backend) |
222 ;;- () ;; This is the new VC for which we don't have an appropriate advice yet | 222 ;;- () ;; This is the new VC for which we don't have an appropriate advice yet |
223 ;;-) | |
223 (unless (fboundp 'process-file) | 224 (unless (fboundp 'process-file) |
224 (if (fboundp 'vc-call-backend) | 225 (if (fboundp 'vc-call-backend) |
226 (defadvice vc-do-command | |
227 (around tramp-advice-vc-do-command | |
228 (buffer okstatus command file &rest flags) | |
229 activate) | |
230 "Invoke tramp-vc-do-command for tramp files." | |
231 (let ((file (symbol-value 'file))) ;pacify byte-compiler | |
232 (if (or (and (stringp file) (tramp-tramp-file-p file)) | |
233 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) | |
234 (setq ad-return-value | |
235 (apply 'tramp-vc-do-command-new buffer okstatus command | |
236 file ;(or file (buffer-file-name)) | |
237 flags)) | |
238 ad-do-it))) | |
225 (defadvice vc-do-command | 239 (defadvice vc-do-command |
226 (around tramp-advice-vc-do-command | 240 (around tramp-advice-vc-do-command |
227 (buffer okstatus command file &rest flags) | 241 (buffer okstatus command file last &rest flags) |
228 activate) | 242 activate) |
229 "Invoke tramp-vc-do-command for tramp files." | 243 "Invoke tramp-vc-do-command for tramp files." |
230 (let ((file (symbol-value 'file))) ;pacify byte-compiler | 244 (let ((file (symbol-value 'file))) ;pacify byte-compiler |
231 (if (or (and (stringp file) (tramp-tramp-file-p file)) | 245 (if (or (and (stringp file) (tramp-tramp-file-p file)) |
232 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) | 246 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) |
233 (setq ad-return-value | 247 (setq ad-return-value |
234 (apply 'tramp-vc-do-command-new buffer okstatus command | 248 (apply 'tramp-vc-do-command buffer okstatus command |
235 file ;(or file (buffer-file-name)) | 249 (or file (buffer-file-name)) last flags)) |
236 flags)) | 250 ad-do-it)))) |
237 ad-do-it))) | 251 |
238 (defadvice vc-do-command | 252 (add-hook 'tramp-unload-hook |
239 (around tramp-advice-vc-do-command | 253 '(lambda () (ad-unadvise 'vc-do-command)))) |
240 (buffer okstatus command file last &rest flags) | |
241 activate) | |
242 "Invoke tramp-vc-do-command for tramp files." | |
243 (let ((file (symbol-value 'file))) ;pacify byte-compiler | |
244 (if (or (and (stringp file) (tramp-tramp-file-p file)) | |
245 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) | |
246 (setq ad-return-value | |
247 (apply 'tramp-vc-do-command buffer okstatus command | |
248 (or file (buffer-file-name)) last flags)) | |
249 ad-do-it))))) | |
250 ;;-) | |
251 | 254 |
252 | 255 |
253 ;; XEmacs uses this to do some of its work. Like vc-do-command, we | 256 ;; XEmacs uses this to do some of its work. Like vc-do-command, we |
254 ;; need to enhance it to make VC work via TRAMP-mode. | 257 ;; need to enhance it to make VC work via TRAMP-mode. |
255 ;; | 258 ;; |
322 (setq ad-return-value | 325 (setq ad-return-value |
323 (apply 'tramp-vc-simple-command okstatus command | 326 (apply 'tramp-vc-simple-command okstatus command |
324 (or file (buffer-file-name)) args)) | 327 (or file (buffer-file-name)) args)) |
325 ad-do-it))) | 328 ad-do-it))) |
326 | 329 |
330 (add-hook 'tramp-unload-hook | |
331 '(lambda () (ad-unadvise 'vc-simple-command))) | |
332 | |
327 | 333 |
328 ;; `vc-workfile-unchanged-p' | 334 ;; `vc-workfile-unchanged-p' |
329 ;; This function does not deal well with remote files, so we do the | 335 ;; This function does not deal well with remote files, so we do the |
330 ;; same as for `vc-do-command'. | 336 ;; same as for `vc-do-command'. |
331 | 337 |
361 (tramp-file-name-user v) | 367 (tramp-file-name-user v) |
362 (tramp-file-name-host v))))) | 368 (tramp-file-name-host v))))) |
363 (setq ad-return-value | 369 (setq ad-return-value |
364 (tramp-vc-workfile-unchanged-p filename want-differences-if-changed)) | 370 (tramp-vc-workfile-unchanged-p filename want-differences-if-changed)) |
365 ad-do-it)) | 371 ad-do-it)) |
372 | |
373 (add-hook 'tramp-unload-hook | |
374 '(lambda () (ad-unadvise 'vc-workfile-unchanged-p))) | |
366 | 375 |
367 | 376 |
368 ;; Redefine a function from vc.el -- allow tramp files. | 377 ;; Redefine a function from vc.el -- allow tramp files. |
369 ;; `save-match-data' seems not to be required -- it isn't in | 378 ;; `save-match-data' seems not to be required -- it isn't in |
370 ;; the original version, either. | 379 ;; the original version, either. |
442 (tramp-tramp-file-p file) ; tramp file | 451 (tramp-tramp-file-p file) ; tramp file |
443 (setq ad-return-value | 452 (setq ad-return-value |
444 (save-match-data | 453 (save-match-data |
445 (tramp-handle-vc-user-login-name uid)))) ; get the owner name | 454 (tramp-handle-vc-user-login-name uid)))) ; get the owner name |
446 ad-do-it))) ; else call the original | 455 ad-do-it))) ; else call the original |
456 | |
457 (add-hook 'tramp-unload-hook | |
458 '(lambda () (ad-unadvise 'vc-user-login-name))) | |
447 | 459 |
448 | 460 |
449 ;; Determine the name of the user owning a file. | 461 ;; Determine the name of the user owning a file. |
450 (defun tramp-file-owner (filename) | 462 (defun tramp-file-owner (filename) |
451 "Return who owns FILE (user name, as a string)." | 463 "Return who owns FILE (user name, as a string)." |
484 (setq ad-return-value | 496 (setq ad-return-value |
485 (save-match-data | 497 (save-match-data |
486 (tramp-file-owner filename)))) ; get the owner name | 498 (tramp-file-owner filename)))) ; get the owner name |
487 ad-do-it))) ; else call the original | 499 ad-do-it))) ; else call the original |
488 | 500 |
501 (add-hook 'tramp-unload-hook | |
502 '(lambda () (ad-unadvise 'vc-file-owner))) | |
503 | |
489 | 504 |
490 ;; We need to make the version control software backend version | 505 ;; We need to make the version control software backend version |
491 ;; information local to the current buffer. This is because each TRAMP | 506 ;; information local to the current buffer. This is because each TRAMP |
492 ;; buffer can (theoretically) have a different VC version and I am | 507 ;; buffer can (theoretically) have a different VC version and I am |
493 ;; *way* too lazy to try and push the correct value into each new | 508 ;; *way* too lazy to try and push the correct value into each new |
504 This makes remote VC work correctly at the cost of some processing time." | 519 This makes remote VC work correctly at the cost of some processing time." |
505 (when (and (buffer-file-name) | 520 (when (and (buffer-file-name) |
506 (tramp-tramp-file-p (buffer-file-name))) | 521 (tramp-tramp-file-p (buffer-file-name))) |
507 (make-local-variable 'vc-rcs-release) | 522 (make-local-variable 'vc-rcs-release) |
508 (setq vc-rcs-release nil))) | 523 (setq vc-rcs-release nil))) |
524 | |
509 (add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t) | 525 (add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t) |
526 (add-hook 'tramp-unload-hook | |
527 '(lambda () | |
528 (remove-hook 'find-file-hooks 'tramp-vc-setup-for-remote))) | |
510 | 529 |
511 ;; No need to load this again if anyone asks. | 530 ;; No need to load this again if anyone asks. |
512 (provide 'tramp-vc) | 531 (provide 'tramp-vc) |
513 | 532 |
514 ;;; arch-tag: 27cc42ce-da19-468d-ad5c-a2690558db60 | 533 ;;; arch-tag: 27cc42ce-da19-468d-ad5c-a2690558db60 |