annotate lisp/net/tramp-vc.el @ 78997:ef0a2673bf5e

* net/tramp.el (tramp-completion-mode): Extend doc-string. (tramp-completion-mode-p): Revert change from 2007-09-24. Checking for `return' etc as last character is not sufficient, for example in dired-mode when entering <g> (revert-buffer) or <s> (dired-sort).
author Michael Albinus <michael.albinus@gmx.de>
date Sat, 06 Oct 2007 15:25:50 +0000
parents 8faf94b6c420
children 6888fd3398e8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
1 ;;; tramp-vc.el --- Version control integration for TRAMP.el
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
2
64701
34bd8e434dd7 Update years in copyright notice; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents: 64085
diff changeset
3 ;; Copyright (C) 2000, 2001, 2002, 2003, 2004,
75347
e3694f1cb928 Add 2007 to copyright years.
Glenn Morris <rgm@gnu.org>
parents: 68423
diff changeset
4 ;; 2005, 2006, 2007 Free Software Foundation, Inc.
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
5
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
6 ;; Author: Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
7 ;; Keywords: comm, processes
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
8
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
9 ;; This file is part of GNU Emacs.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
10
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
11 ;; GNU Emacs is free software; you can redistribute it and/or modify
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
12 ;; it under the terms of the GNU General Public License as published by
78230
84cf1e2214c5 Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 77986
diff changeset
13 ;; the Free Software Foundation; either version 3, or (at your option)
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
14 ;; any later version.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
15
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
16 ;; GNU Emacs is distributed in the hope that it will be useful,
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
19 ;; GNU General Public License for more details.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
20
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
22 ;; along with GNU Emacs; see the file COPYING. If not, write to the
64085
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63588
diff changeset
23 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18a818a2ee7c Update FSF's address.
Lute Kamstra <lute@gnu.org>
parents: 63588
diff changeset
24 ;; Boston, MA 02110-1301, USA.
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
25
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
26 ;;; Commentary:
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
27
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
28 ;; See the main module, 'tramp.el' for discussion of the purpose of TRAMP.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
29 ;; This module provides integration between remote files accessed by TRAMP and
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
30 ;; the Emacs version control system.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
31
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
32 ;;; Code:
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
33
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
34 (require 'vc)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
35 ;; Old VC defines vc-rcs-release in vc.el, new VC requires extra module.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
36 (unless (boundp 'vc-rcs-release)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
37 (require 'vc-rcs))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
38 (require 'tramp)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
39
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
40 ;; Avoid byte-compiler warnings if the byte-compiler supports this.
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
41 ;; Currently, XEmacs supports this.
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
42 (eval-when-compile
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
43 (when (fboundp 'byte-compiler-options)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
44 (let (unused-vars) ; Pacify Emacs byte-compiler
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
45 (defalias 'warnings 'identity) ; Pacify Emacs byte-compiler
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
46 (byte-compiler-options (warnings (- unused-vars))))))
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
47
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
48 ;; -- vc --
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
49
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
50 ;; This used to blow away the file-name-handler-alist and reinstall
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
51 ;; TRAMP into it. This was intended to let VC work remotely. It didn't,
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
52 ;; at least not in my XEmacs 21.2 install.
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
53 ;;
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
54 ;; In any case, tramp-run-real-handler now deals correctly with disabling
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
55 ;; the things that should be, making this a no-op.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
56 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
57 ;; I have removed it from the tramp-file-name-handler-alist because the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
58 ;; shortened version does nothing. This is for reference only now.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
59 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
60 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
61 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
62 ;; (defun tramp-handle-vc-registered (file)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
63 ;; "Like `vc-registered' for tramp files."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
64 ;; (tramp-run-real-handler 'vc-registered (list file)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
65
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
66 ;; `vc-do-command'
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
67 ;; This function does not deal well with remote files, so we define
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
68 ;; our own version and make a backup of the original function and
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
69 ;; call our version for tramp files and the original version for
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
70 ;; normal files.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
71
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
72 ;; The following function is pretty much copied from vc.el, but
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
73 ;; the part that actually executes a command is changed.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
74 ;; CCC: this probably works for Emacs 21, too.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
75 (defun tramp-vc-do-command (buffer okstatus command file last &rest flags)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
76 "Like `vc-do-command' but invoked for tramp files.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
77 See `vc-do-command' for more information."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
78 (save-match-data
56460
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
79 (and file (setq file (expand-file-name file)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
80 (if (not buffer) (setq buffer "*vc*"))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
81 (if vc-command-messages
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
82 (message "Running `%s' on `%s'..." command file))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
83 (let ((obuf (current-buffer)) (camefrom (current-buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
84 (squeezed nil)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
85 (olddir default-directory)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
86 vc-file status)
56460
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
87 (let* ((v (tramp-dissect-file-name (expand-file-name file)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
88 (multi-method (tramp-file-name-multi-method v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
89 (method (tramp-file-name-method v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
90 (user (tramp-file-name-user v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
91 (host (tramp-file-name-host v))
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
92 (localname (tramp-file-name-localname v)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
93 (set-buffer (get-buffer-create buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
94 (set (make-local-variable 'vc-parent-buffer) camefrom)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
95 (set (make-local-variable 'vc-parent-buffer-name)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
96 (concat " from " (buffer-name camefrom)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
97 (setq default-directory olddir)
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
98
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
99 (erase-buffer)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
100
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
101 (mapcar
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
102 (function
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
103 (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
104 flags)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
105 (if (and (eq last 'MASTER) file
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
106 (setq vc-file (vc-name file)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
107 (setq squeezed
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
108 (append squeezed
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
109 (list (tramp-file-name-localname
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
110 (tramp-dissect-file-name vc-file))))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
111 (if (and file (eq last 'WORKFILE))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
112 (progn
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
113 (let* ((pwd (expand-file-name default-directory))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
114 (preflen (length pwd)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
115 (if (string= (substring file 0 preflen) pwd)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
116 (setq file (substring file preflen))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
117 (setq squeezed (append squeezed (list file)))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
118 ;; Unless we (save-window-excursion) the layout of windows in
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
119 ;; the current frame changes. This is painful, at best.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
120 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
121 ;; As a point of note, (save-excursion) is still here only because
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
122 ;; it preserves (point) in the current buffer. (save-window-excursion)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
123 ;; does not, at least under XEmacs 21.2.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
124 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
125 ;; I trust that the FSF support this as well. I can't find useful
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
126 ;; documentation to check :(
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
127 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
128 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
129 (save-excursion
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
130 (save-window-excursion
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
131 ;; Actually execute remote command
59582
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
132 ;; `shell-command' cannot be used; it isn't magic in XEmacs.
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
133 (tramp-handle-shell-command
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
134 (mapconcat 'tramp-shell-quote-argument
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
135 (cons command squeezed) " ") t)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
136 ;;(tramp-wait-for-output)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
137 ;; Get status from command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
138 (tramp-send-command multi-method method user host "echo $?")
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
139 (tramp-wait-for-output)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
140 ;; Make sure to get status from last line of output.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
141 (goto-char (point-max)) (forward-line -1)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
142 (setq status (read (current-buffer)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
143 (message "Command %s returned status %d." command status)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
144 (goto-char (point-max))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
145 (set-buffer-modified-p nil)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
146 (forward-line -1)
48973
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
147 (if (or (not (integerp status))
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
148 (and (integerp okstatus) (< okstatus status)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
149 (progn
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
150 (pop-to-buffer buffer)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
151 (goto-char (point-min))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
152 (shrink-window-if-larger-than-buffer)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
153 (error "Running `%s'...FAILED (%s)" command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
154 (if (integerp status)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
155 (format "status %d" status)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
156 status))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
157 )
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
158 (if vc-command-messages
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
159 (message "Running %s...OK" command))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
160 )
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
161 (set-buffer obuf)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
162 status))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
163 ))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
164
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
165 ;; Following code snarfed from Emacs 21 vc.el and slightly tweaked.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
166 (defun tramp-vc-do-command-new (buffer okstatus command file &rest flags)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
167 "Like `vc-do-command' but for TRAMP files.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
168 This function is for the new VC which comes with Emacs 21.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
169 Since TRAMP doesn't do async commands yet, this function doesn't, either."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
170 (and file (setq file (expand-file-name file)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
171 (if vc-command-messages
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
172 (message "Running %s on %s..." command file))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
173 (save-current-buffer
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
174 (unless (eq buffer t)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
175 ; Pacify byte-compiler
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
176 (funcall (symbol-function 'vc-setup-buffer) buffer))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
177 (let ((squeezed nil)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
178 (inhibit-read-only t)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
179 (status 0))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
180 (let* ((v (when file (tramp-dissect-file-name file)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
181 (multi-method (when file (tramp-file-name-multi-method v)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
182 (method (when file (tramp-file-name-method v)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
183 (user (when file (tramp-file-name-user v)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
184 (host (when file (tramp-file-name-host v)))
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
185 (localname (when file (tramp-file-name-localname v))))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
186 (setq squeezed (delq nil (copy-sequence flags)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
187 (when file
48973
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
188 (setq squeezed (append squeezed (list (file-relative-name
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
189 file default-directory)))))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
190 (let ((w32-quote-process-args t))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
191 (when (eq okstatus 'async)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
192 (message "Tramp doesn't do async commands, running synchronously."))
59582
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
193 ;; `shell-command' cannot be used; it isn't magic in XEmacs.
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
194 (setq status (tramp-handle-shell-command
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
195 (mapconcat 'tramp-shell-quote-argument
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
196 (cons command squeezed) " ") t))
48973
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
197 (when (or (not (integerp status))
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
198 (and (integerp okstatus) (< okstatus status)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
199 (pop-to-buffer (current-buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
200 (goto-char (point-min))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
201 (shrink-window-if-larger-than-buffer)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
202 (error "Running %s...FAILED (%s)" command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
203 (if (integerp status) (format "status %d" status) status))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
204 (if vc-command-messages
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
205 (message "Running %s...OK" command))
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
206 ; Pacify byte-compiler
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
207 (funcall (symbol-function 'vc-exec-after)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
208 `(run-hook-with-args
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
209 'vc-post-command-functions ',command ',localname ',flags))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
210 status))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
211
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
212
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
213 ;; The context for a VC command is the current buffer.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
214 ;; That makes a test on the buffers file more reliable than a test on the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
215 ;; arguments.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
216 ;; This is needed to handle remote VC correctly - else we test against the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
217 ;; local VC system and get things wrong...
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
218 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
219 ;;-(if (fboundp 'vc-call-backend)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
220 ;;- () ;; This is the new VC for which we don't have an appropriate advice yet
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
221 ;;-)
57653
b324ca4df07c * simple.el (process-file): New function, similar to call-process
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 56460
diff changeset
222 (unless (fboundp 'process-file)
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
223 (if (fboundp 'vc-call-backend)
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
224 (defadvice vc-do-command
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
225 (around tramp-advice-vc-do-command
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
226 (buffer okstatus command file &rest flags)
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
227 activate)
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
228 "Invoke tramp-vc-do-command for tramp files."
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
229 (let ((file (symbol-value 'file))) ;pacify byte-compiler
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
230 (if (or (and (stringp file) (tramp-tramp-file-p file))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
231 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
232 (setq ad-return-value
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
233 (apply 'tramp-vc-do-command-new buffer okstatus command
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
234 file ;(or file (buffer-file-name))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
235 flags))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
236 ad-do-it)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
237 (defadvice vc-do-command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
238 (around tramp-advice-vc-do-command
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
239 (buffer okstatus command file last &rest flags)
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
240 activate)
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
241 "Invoke tramp-vc-do-command for tramp files."
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
242 (let ((file (symbol-value 'file))) ;pacify byte-compiler
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
243 (if (or (and (stringp file) (tramp-tramp-file-p file))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
244 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
245 (setq ad-return-value
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
246 (apply 'tramp-vc-do-command buffer okstatus command
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
247 (or file (buffer-file-name)) last flags))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
248 ad-do-it))))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
249
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
250 (add-hook 'tramp-unload-hook
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
251 '(lambda () (ad-unadvise 'vc-do-command))))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
252
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
253
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
254 ;; XEmacs uses this to do some of its work. Like vc-do-command, we
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
255 ;; need to enhance it to make VC work via TRAMP-mode.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
256 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
257 ;; Like the previous function, this is a cut-and-paste job from the VC
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
258 ;; file. It's based on the vc-do-command code.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
259 ;; CCC: this isn't used in Emacs 21, so do as before.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
260 (defun tramp-vc-simple-command (okstatus command file &rest args)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
261 ;; Simple version of vc-do-command, for use in vc-hooks only.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
262 ;; Don't switch to the *vc-info* buffer before running the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
263 ;; command, because that would change its default directory
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
264 (save-match-data
56460
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
265 (let* ((v (tramp-dissect-file-name (expand-file-name file)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
266 (multi-method (tramp-file-name-multi-method v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
267 (method (tramp-file-name-method v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
268 (user (tramp-file-name-user v))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
269 (host (tramp-file-name-host v))
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
270 (localname (tramp-file-name-localname v)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
271 (save-excursion (set-buffer (get-buffer-create "*vc-info*"))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
272 (erase-buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
273 (let ((exec-path (append vc-path exec-path)) exec-status
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
274 ;; Add vc-path to PATH for the execution of this command.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
275 (process-environment
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
276 (cons (concat "PATH=" (getenv "PATH")
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
277 path-separator
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
278 (mapconcat 'identity vc-path path-separator))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
279 process-environment)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
280 ;; Call the actual process. See tramp-vc-do-command for discussion of
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
281 ;; why this does both (save-window-excursion) and (save-excursion).
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
282 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
283 ;; As a note, I don't think that the process-environment stuff above
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
284 ;; has any effect on the remote system. This is a hard one though as
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
285 ;; there is no real reason to expect local and remote paths to be
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
286 ;; identical...
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
287 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
288 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
289 (save-excursion
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
290 (save-window-excursion
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
291 ;; Actually execute remote command
59582
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
292 ;; `shell-command' cannot be used; it isn't magic in XEmacs.
92796330257a Sync with Tramp 2.0.47.
Michael Albinus <michael.albinus@gmx.de>
parents: 57653
diff changeset
293 (tramp-handle-shell-command
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
294 (mapconcat 'tramp-shell-quote-argument
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
295 (append (list command) args (list localname)) " ")
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
296 (get-buffer-create"*vc-info*"))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
297 ;(tramp-wait-for-output)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
298 ;; Get status from command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
299 (tramp-send-command multi-method method user host "echo $?")
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
300 (tramp-wait-for-output)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
301 (setq exec-status (read (current-buffer)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
302 (message "Command %s returned status %d." command exec-status)))
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
303
48973
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
304 ;; Maybe okstatus can be `async' here. But then, maybe the
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
305 ;; async thing is new in Emacs 21, but this function is only
09acf3f65bb5 * net/tramp*.el: Sync with upstream version 2.0.28. Bugfixes.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 45861
diff changeset
306 ;; used in Emacs 20.
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
307 (cond ((> exec-status okstatus)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
308 (switch-to-buffer (get-file-buffer file))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
309 (shrink-window-if-larger-than-buffer
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
310 (display-buffer "*vc-info*"))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
311 (error "Couldn't find version control information")))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
312 exec-status))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
313
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
314 ;; This function does not exist any more in Emacs-21's VC
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
315 (defadvice vc-simple-command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
316 (around tramp-advice-vc-simple-command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
317 (okstatus command file &rest args)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
318 activate)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
319 "Invoke tramp-vc-simple-command for tramp files."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
320 (let ((file (symbol-value 'file))) ;pacify byte-compiler
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
321 (if (or (and (stringp file) (tramp-tramp-file-p file))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
322 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
323 (setq ad-return-value
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
324 (apply 'tramp-vc-simple-command okstatus command
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
325 (or file (buffer-file-name)) args))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
326 ad-do-it)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
327
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
328 (add-hook 'tramp-unload-hook
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
329 '(lambda () (ad-unadvise 'vc-simple-command)))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
330
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
331
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
332 ;; `vc-workfile-unchanged-p'
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
333 ;; This function does not deal well with remote files, so we do the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
334 ;; same as for `vc-do-command'.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
335
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
336 ;; `vc-workfile-unchanged-p' checks the modification time, we cannot
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
337 ;; do that for remote files, so here's a version which relies on diff.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
338 ;; CCC: this one probably works for Emacs 21, too.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
339 (defun tramp-vc-workfile-unchanged-p
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
340 (filename &optional want-differences-if-changed)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
341 (if (fboundp 'vc-backend-diff)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
342 ;; Old VC. Call `vc-backend-diff'.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
343 (let ((status (funcall (symbol-function 'vc-backend-diff)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
344 filename nil nil
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
345 (not want-differences-if-changed))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
346 (zerop status))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
347 ;; New VC. Call `vc-default-workfile-unchanged-p'.
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
348 (funcall (symbol-function 'vc-default-workfile-unchanged-p)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
349 (vc-backend filename) filename)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
350
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
351 (defadvice vc-workfile-unchanged-p
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
352 (around tramp-advice-vc-workfile-unchanged-p
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
353 (filename &optional want-differences-if-changed)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
354 activate)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
355 "Invoke tramp-vc-workfile-unchanged-p for tramp files."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
356 (if (and (stringp filename)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
357 (tramp-tramp-file-p filename)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
358 (not
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
359 (let ((v (tramp-dissect-file-name filename)))
51968
e4c4c45ea013 Tramp 2.0.36 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49995
diff changeset
360 ;; The following check is probably to test whether
e4c4c45ea013 Tramp 2.0.36 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49995
diff changeset
361 ;; file-attributes returns correct last modification
e4c4c45ea013 Tramp 2.0.36 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49995
diff changeset
362 ;; times. This check needs to be changed.
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
363 (tramp-get-remote-perl (tramp-file-name-multi-method v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
364 (tramp-file-name-method v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
365 (tramp-file-name-user v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
366 (tramp-file-name-host v)))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
367 (setq ad-return-value
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
368 (tramp-vc-workfile-unchanged-p filename want-differences-if-changed))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
369 ad-do-it))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
370
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
371 (add-hook 'tramp-unload-hook
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
372 '(lambda () (ad-unadvise 'vc-workfile-unchanged-p)))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
373
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
374
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
375 ;; Redefine a function from vc.el -- allow tramp files.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
376 ;; `save-match-data' seems not to be required -- it isn't in
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
377 ;; the original version, either.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
378 ;; CCC: this might need some work -- how does the Emacs 21 version
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
379 ;; work, anyway? Does it work over ange-ftp? Hm.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
380 (if (not (fboundp 'vc-backend-checkout))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
381 () ;; our replacement won't work and is unnecessary anyway
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
382 (defun vc-checkout (filename &optional writable rev)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
383 "Retrieve a copy of the latest version of the given file."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
384 ;; If ftp is on this system and the name matches the ange-ftp format
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
385 ;; for a remote file, the user is trying something that won't work.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
386 (funcall (symbol-function 'vc-backend-checkout) filename writable rev)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
387 (vc-resynch-buffer filename t t))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
388 )
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
389
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
390
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
391 ;; Do we need to advise the vc-user-login-name function anyway?
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
392 ;; This will return the correct login name for the owner of a
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
393 ;; file. It does not deal with the default remote user name...
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
394 ;;
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
395 ;; That is, when vc calls (vc-user-login-name), we return the
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
396 ;; local login name, something that may be different to the remote
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
397 ;; default.
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
398 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
399 ;; The remote VC operations will occur as the user that we logged
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
400 ;; in with however - not always the same as the local user.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
401 ;;
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
402 ;; In the end, I did advise the function. This is because, well,
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
403 ;; the thing didn't work right otherwise ;)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
404 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
405 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
406
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
407 (defun tramp-handle-vc-user-login-name (&optional uid)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
408 "Return the default user name on the remote machine.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
409 Whenever VC calls this function, `file' is bound to the file name
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
410 in question. If no uid is provided or the uid is equal to the uid
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
411 owning the file, then we return the user name given in the file name.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
412
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
413 This should only be called when `file' is bound to the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
414 filename we are thinking about..."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
415 ;; Pacify byte-compiler; this symbol is bound in the calling
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
416 ;; function. CCC: Maybe it would be better to move the
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
417 ;; boundness-checking into this function?
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
418 (let* ((file (symbol-value 'file))
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
419 (remote-uid
60763
3ba8f94e9cfa Sync with Tramp 2.0.48.
Michael Albinus <michael.albinus@gmx.de>
parents: 59996
diff changeset
420 ;; With Emacs 22, `file-attributes' has got an optional parameter
55420
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
421 ;; ID-FORMAT. Handle this case backwards compatible.
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
422 (if (and (functionp 'subr-arity)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
423 (= 2 (cdr (funcall (symbol-function 'subr-arity)
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
424 (symbol-function 'file-attributes)))))
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
425 (nth 2 (file-attributes file 'integer))
c44f9de543e3 2004-05-07 Kai Grossjohann <kai@emptydomain.de>
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 53206
diff changeset
426 (nth 2 (file-attributes file)))))
53206
0c19f1a19b2b (tramp-chunksize): Extend docstring. Suggested by
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 52401
diff changeset
427 (if (and uid (/= uid remote-uid))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
428 (error "tramp-handle-vc-user-login-name cannot map a uid to a name")
56460
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
429 (let* ((v (tramp-dissect-file-name (expand-file-name file)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
430 (u (tramp-file-name-user v)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
431 (cond ((stringp u) u)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
432 ((vectorp u) (elt u (1- (length u))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
433 ((null u) (user-login-name))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
434 (t (error "tramp-handle-vc-user-login-name cannot cope!")))))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
435
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
436
68385
774d8922e2c3 (vc-user-login-name): Comment out defadvice, it is no longer
André Spiegel <spiegel@gnu.org>
parents: 68335
diff changeset
437 ;; The following defadvice is no longer necessary after changes in VC
774d8922e2c3 (vc-user-login-name): Comment out defadvice, it is no longer
André Spiegel <spiegel@gnu.org>
parents: 68335
diff changeset
438 ;; on 2006-01-25, Andre.
774d8922e2c3 (vc-user-login-name): Comment out defadvice, it is no longer
André Spiegel <spiegel@gnu.org>
parents: 68335
diff changeset
439
78887
8faf94b6c420 * net/tramp.el (tramp-completion-mode-p): Rename from
Michael Albinus <michael.albinus@gmx.de>
parents: 78230
diff changeset
440 ;; That means either GNU Emacs >= 22 or the "new vc" package from XEmacs
8faf94b6c420 * net/tramp.el (tramp-completion-mode-p): Rename from
Michael Albinus <michael.albinus@gmx.de>
parents: 78230
diff changeset
441 ;; packages collection; as of 2007-09-06, test for availability of
8faf94b6c420 * net/tramp.el (tramp-completion-mode-p): Rename from
Michael Albinus <michael.albinus@gmx.de>
parents: 78230
diff changeset
442 ;; `vc-find-version' works for both of those cases.
8faf94b6c420 * net/tramp.el (tramp-completion-mode-p): Rename from
Michael Albinus <michael.albinus@gmx.de>
parents: 78230
diff changeset
443 (unless (fboundp 'vc-find-version)
68423
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
444 (defadvice vc-user-login-name
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
445 (around tramp-vc-user-login-name activate)
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
446 "Support for files on remote machines accessed by TRAMP."
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
447 ;; We rely on the fact that `file' is bound when this is called.
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
448 ;; This appears to be the case everywhere in vc.el and vc-hooks.el
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
449 ;; as of Emacs 20.5.
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
450 ;;
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
451 ;; With Emacs 22, the definition of `vc-user-login-name' has been
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
452 ;; changed. It doesn't need to be adviced any longer.
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
453 (let ((file (when (boundp 'file)
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
454 (symbol-value 'file)))) ;pacify byte-compiler
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
455 (or (and (stringp file)
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
456 (tramp-tramp-file-p file) ; tramp file
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
457 (setq ad-return-value
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
458 (save-match-data
78887
8faf94b6c420 * net/tramp.el (tramp-completion-mode-p): Rename from
Michael Albinus <michael.albinus@gmx.de>
parents: 78230
diff changeset
459 (tramp-handle-vc-user-login-name (ad-get-arg 0))))) ; get the owner name
68423
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
460 ad-do-it))) ; else call the original
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
461
68423
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
462 (add-hook 'tramp-unload-hook
927f1c4f43d8 * net/tramp-vc.el (vc-user-login-name): Wrap defadvice with a test
Michael Albinus <michael.albinus@gmx.de>
parents: 68385
diff changeset
463 '(lambda () (ad-unadvise 'vc-user-login-name))))
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
464
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
465
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
466 ;; Determine the name of the user owning a file.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
467 (defun tramp-file-owner (filename)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
468 "Return who owns FILE (user name, as a string)."
59996
aac0a33f5772 Change release version from 21.4 to 22.1 throughout.
Kim F. Storm <storm@cua.dk>
parents: 59582
diff changeset
469 (let ((v (tramp-dissect-file-name
56460
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
470 (expand-file-name filename))))
9459300bf43b Sync with Tramp 2.0.43.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 55420
diff changeset
471 (if (not (file-exists-p filename))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
472 nil ; file cannot be opened
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
473 ;; file exists, find out stuff
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
474 (save-excursion
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
475 (tramp-send-command
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
476 (tramp-file-name-multi-method v) (tramp-file-name-method v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
477 (tramp-file-name-user v) (tramp-file-name-host v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
478 (format "%s -Lld %s"
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
479 (tramp-get-ls-command (tramp-file-name-multi-method v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
480 (tramp-file-name-method v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
481 (tramp-file-name-user v)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
482 (tramp-file-name-host v))
49995
a0e8a85259ed Version 2.0.30 released.
Kai Großjohann <kgrossjo@eu.uu.net>
parents: 49598
diff changeset
483 (tramp-shell-quote-argument (tramp-file-name-localname v))))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
484 (tramp-wait-for-output)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
485 ;; parse `ls -l' output ...
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
486 ;; ... file mode flags
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
487 (read (current-buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
488 ;; ... number links
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
489 (read (current-buffer))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
490 ;; ... uid (as a string)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
491 (symbol-name (read (current-buffer)))))))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
492
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
493 ;; Wire ourselves into the VC infrastructure...
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
494 ;; This function does not exist any more in Emacs-21's VC
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
495 ;; CCC: it appears that no substitute is needed for Emacs 21.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
496 (defadvice vc-file-owner
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
497 (around tramp-vc-file-owner activate)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
498 "Support for files on remote machines accessed by TRAMP."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
499 (let ((filename (ad-get-arg 0)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
500 (or (and (tramp-file-name-p filename) ; tramp file
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
501 (setq ad-return-value
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
502 (save-match-data
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
503 (tramp-file-owner filename)))) ; get the owner name
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
504 ad-do-it))) ; else call the original
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
505
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
506 (add-hook 'tramp-unload-hook
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
507 '(lambda () (ad-unadvise 'vc-file-owner)))
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
508
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
509
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
510 ;; We need to make the version control software backend version
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
511 ;; information local to the current buffer. This is because each TRAMP
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
512 ;; buffer can (theoretically) have a different VC version and I am
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
513 ;; *way* too lazy to try and push the correct value into each new
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
514 ;; buffer.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
515 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
516 ;; Remote VC costs will just have to be paid, at least for the moment.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
517 ;; Well, at least, they will right until I feel guilty about doing a
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
518 ;; botch job here and fix it. :/
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
519 ;;
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
520 ;; Daniel Pittman <daniel@danann.net>
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
521 ;; CCC: this is probably still needed for Emacs 21.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
522 (defun tramp-vc-setup-for-remote ()
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
523 "Make the backend release variables buffer local.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
524 This makes remote VC work correctly at the cost of some processing time."
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
525 (when (and (buffer-file-name)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
526 (tramp-tramp-file-p (buffer-file-name)))
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
527 (make-local-variable 'vc-rcs-release)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
528 (setq vc-rcs-release nil)))
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
529
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
530 (add-hook 'find-file-hooks 'tramp-vc-setup-for-remote t)
68335
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
531 (add-hook 'tramp-unload-hook
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
532 '(lambda ()
118ceefc8263 Sync with Tramp 2.0.52.
Michael Albinus <michael.albinus@gmx.de>
parents: 64701
diff changeset
533 (remove-hook 'find-file-hooks 'tramp-vc-setup-for-remote)))
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
534
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
535 ;; No need to load this again if anyone asks.
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
536 (provide 'tramp-vc)
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
537
52401
695cf19ef79e Add arch taglines
Miles Bader <miles@gnu.org>
parents: 51968
diff changeset
538 ;;; arch-tag: 27cc42ce-da19-468d-ad5c-a2690558db60
45861
7b663a89ef2a *** empty log message ***
Kai Großjohann <kgrossjo@eu.uu.net>
parents:
diff changeset
539 ;;; tramp-vc.el ends here