comparison lisp/net/tramp-vc.el @ 49995:a0e8a85259ed

Version 2.0.30 released. Replace term "path" with "localname" unless it is used for a search path. (tramp-handle-expand-file-name): Allow ".." to cross host boundaries. (tramp-open-connection-setup-interactive-shell): Unset $ENV in addition to setting $PS1 when starting the Bourne-ish shell. Some sh implementations (eg, bash when called as sh) read the file named there on startup, which could clobber $PS1. (tramp-do-copy-or-rename-file-one-local): New function. Not implemented. Not used. Should invoke rcp or scp directly to keep the time.
author Kai Großjohann <kgrossjo@eu.uu.net>
date Fri, 28 Feb 2003 18:28:47 +0000
parents 0d8b17d428b5
children e4c4c45ea013
comparison
equal deleted inserted replaced
49994:dcf78d005b68 49995:a0e8a85259ed
41 ;; -- vc -- 41 ;; -- vc --
42 42
43 ;; This used to blow away the file-name-handler-alist and reinstall 43 ;; This used to blow away the file-name-handler-alist and reinstall
44 ;; TRAMP into it. This was intended to let VC work remotely. It didn't, 44 ;; TRAMP into it. This was intended to let VC work remotely. It didn't,
45 ;; at least not in my XEmacs 21.2 install. 45 ;; at least not in my XEmacs 21.2 install.
46 ;; 46 ;;
47 ;; In any case, tramp-run-real-handler now deals correctly with disabling 47 ;; In any case, tramp-run-real-handler now deals correctly with disabling
48 ;; the things that should be, making this a no-op. 48 ;; the things that should be, making this a no-op.
49 ;; 49 ;;
50 ;; I have removed it from the tramp-file-name-handler-alist because the 50 ;; I have removed it from the tramp-file-name-handler-alist because the
51 ;; shortened version does nothing. This is for reference only now. 51 ;; shortened version does nothing. This is for reference only now.
80 (let* ((v (tramp-dissect-file-name (tramp-handle-expand-file-name file))) 80 (let* ((v (tramp-dissect-file-name (tramp-handle-expand-file-name file)))
81 (multi-method (tramp-file-name-multi-method v)) 81 (multi-method (tramp-file-name-multi-method v))
82 (method (tramp-file-name-method v)) 82 (method (tramp-file-name-method v))
83 (user (tramp-file-name-user v)) 83 (user (tramp-file-name-user v))
84 (host (tramp-file-name-host v)) 84 (host (tramp-file-name-host v))
85 (path (tramp-file-name-path v))) 85 (localname (tramp-file-name-localname v)))
86 (set-buffer (get-buffer-create buffer)) 86 (set-buffer (get-buffer-create buffer))
87 (set (make-local-variable 'vc-parent-buffer) camefrom) 87 (set (make-local-variable 'vc-parent-buffer) camefrom)
88 (set (make-local-variable 'vc-parent-buffer-name) 88 (set (make-local-variable 'vc-parent-buffer-name)
89 (concat " from " (buffer-name camefrom))) 89 (concat " from " (buffer-name camefrom)))
90 (setq default-directory olddir) 90 (setq default-directory olddir)
91 91
92 (erase-buffer) 92 (erase-buffer)
93 93
94 (mapcar 94 (mapcar
95 (function 95 (function
96 (lambda (s) (and s (setq squeezed (append squeezed (list s)))))) 96 (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
97 flags) 97 flags)
98 (if (and (eq last 'MASTER) file 98 (if (and (eq last 'MASTER) file
99 (setq vc-file (vc-name file))) 99 (setq vc-file (vc-name file)))
100 (setq squeezed 100 (setq squeezed
101 (append squeezed 101 (append squeezed
102 (list (tramp-file-name-path 102 (list (tramp-file-name-localname
103 (tramp-dissect-file-name vc-file)))))) 103 (tramp-dissect-file-name vc-file))))))
104 (if (and file (eq last 'WORKFILE)) 104 (if (and file (eq last 'WORKFILE))
105 (progn 105 (progn
106 (let* ((pwd (expand-file-name default-directory)) 106 (let* ((pwd (expand-file-name default-directory))
107 (preflen (length pwd))) 107 (preflen (length pwd)))
170 (let* ((v (when file (tramp-dissect-file-name file))) 170 (let* ((v (when file (tramp-dissect-file-name file)))
171 (multi-method (when file (tramp-file-name-multi-method v))) 171 (multi-method (when file (tramp-file-name-multi-method v)))
172 (method (when file (tramp-file-name-method v))) 172 (method (when file (tramp-file-name-method v)))
173 (user (when file (tramp-file-name-user v))) 173 (user (when file (tramp-file-name-user v)))
174 (host (when file (tramp-file-name-host v))) 174 (host (when file (tramp-file-name-host v)))
175 (path (when file (tramp-file-name-path v)))) 175 (localname (when file (tramp-file-name-localname v))))
176 (setq squeezed (delq nil (copy-sequence flags))) 176 (setq squeezed (delq nil (copy-sequence flags)))
177 (when file 177 (when file
178 (setq squeezed (append squeezed (list (file-relative-name 178 (setq squeezed (append squeezed (list (file-relative-name
179 file default-directory))))) 179 file default-directory)))))
180 (let ((w32-quote-process-args t)) 180 (let ((w32-quote-process-args t))
192 (if (integerp status) (format "status %d" status) status)))) 192 (if (integerp status) (format "status %d" status) status))))
193 (if vc-command-messages 193 (if vc-command-messages
194 (message "Running %s...OK" command)) 194 (message "Running %s...OK" command))
195 (vc-exec-after 195 (vc-exec-after
196 `(run-hook-with-args 196 `(run-hook-with-args
197 'vc-post-command-functions ',command ',path ',flags)) 197 'vc-post-command-functions ',command ',localname ',flags))
198 status)))) 198 status))))
199 199
200 200
201 ;; The context for a VC command is the current buffer. 201 ;; The context for a VC command is the current buffer.
202 ;; That makes a test on the buffers file more reliable than a test on the 202 ;; That makes a test on the buffers file more reliable than a test on the
214 "Invoke tramp-vc-do-command for tramp files." 214 "Invoke tramp-vc-do-command for tramp files."
215 (let ((file (symbol-value 'file))) ;pacify byte-compiler 215 (let ((file (symbol-value 'file))) ;pacify byte-compiler
216 (if (or (and (stringp file) (tramp-tramp-file-p file)) 216 (if (or (and (stringp file) (tramp-tramp-file-p file))
217 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) 217 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
218 (setq ad-return-value 218 (setq ad-return-value
219 (apply 'tramp-vc-do-command-new buffer okstatus command 219 (apply 'tramp-vc-do-command-new buffer okstatus command
220 file ;(or file (buffer-file-name)) 220 file ;(or file (buffer-file-name))
221 flags)) 221 flags))
222 ad-do-it))) 222 ad-do-it)))
223 (defadvice vc-do-command 223 (defadvice vc-do-command
224 (around tramp-advice-vc-do-command 224 (around tramp-advice-vc-do-command
227 "Invoke tramp-vc-do-command for tramp files." 227 "Invoke tramp-vc-do-command for tramp files."
228 (let ((file (symbol-value 'file))) ;pacify byte-compiler 228 (let ((file (symbol-value 'file))) ;pacify byte-compiler
229 (if (or (and (stringp file) (tramp-tramp-file-p file)) 229 (if (or (and (stringp file) (tramp-tramp-file-p file))
230 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) 230 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
231 (setq ad-return-value 231 (setq ad-return-value
232 (apply 'tramp-vc-do-command buffer okstatus command 232 (apply 'tramp-vc-do-command buffer okstatus command
233 (or file (buffer-file-name)) last flags)) 233 (or file (buffer-file-name)) last flags))
234 ad-do-it)))) 234 ad-do-it))))
235 ;;-) 235 ;;-)
236 236
237 237
249 (let* ((v (tramp-dissect-file-name (tramp-handle-expand-file-name file))) 249 (let* ((v (tramp-dissect-file-name (tramp-handle-expand-file-name file)))
250 (multi-method (tramp-file-name-multi-method v)) 250 (multi-method (tramp-file-name-multi-method v))
251 (method (tramp-file-name-method v)) 251 (method (tramp-file-name-method v))
252 (user (tramp-file-name-user v)) 252 (user (tramp-file-name-user v))
253 (host (tramp-file-name-host v)) 253 (host (tramp-file-name-host v))
254 (path (tramp-file-name-path v))) 254 (localname (tramp-file-name-localname v)))
255 (save-excursion (set-buffer (get-buffer-create "*vc-info*")) 255 (save-excursion (set-buffer (get-buffer-create "*vc-info*"))
256 (erase-buffer)) 256 (erase-buffer))
257 (let ((exec-path (append vc-path exec-path)) exec-status 257 (let ((exec-path (append vc-path exec-path)) exec-status
258 ;; Add vc-path to PATH for the execution of this command. 258 ;; Add vc-path to PATH for the execution of this command.
259 (process-environment 259 (process-environment
273 (save-excursion 273 (save-excursion
274 (save-window-excursion 274 (save-window-excursion
275 ;; Actually execute remote command 275 ;; Actually execute remote command
276 (tramp-handle-shell-command 276 (tramp-handle-shell-command
277 (mapconcat 'tramp-shell-quote-argument 277 (mapconcat 'tramp-shell-quote-argument
278 (append (list command) args (list path)) " ") 278 (append (list command) args (list localname)) " ")
279 (get-buffer-create"*vc-info*")) 279 (get-buffer-create"*vc-info*"))
280 ;(tramp-wait-for-output) 280 ;(tramp-wait-for-output)
281 ;; Get status from command 281 ;; Get status from command
282 (tramp-send-command multi-method method user host "echo $?") 282 (tramp-send-command multi-method method user host "echo $?")
283 (tramp-wait-for-output) 283 (tramp-wait-for-output)
284 (setq exec-status (read (current-buffer))) 284 (setq exec-status (read (current-buffer)))
285 (message "Command %s returned status %d." command exec-status))) 285 (message "Command %s returned status %d." command exec-status)))
286 286
287 ;; Maybe okstatus can be `async' here. But then, maybe the 287 ;; Maybe okstatus can be `async' here. But then, maybe the
288 ;; async thing is new in Emacs 21, but this function is only 288 ;; async thing is new in Emacs 21, but this function is only
289 ;; used in Emacs 20. 289 ;; used in Emacs 20.
290 (cond ((> exec-status okstatus) 290 (cond ((> exec-status okstatus)
291 (switch-to-buffer (get-file-buffer file)) 291 (switch-to-buffer (get-file-buffer file))
302 "Invoke tramp-vc-simple-command for tramp files." 302 "Invoke tramp-vc-simple-command for tramp files."
303 (let ((file (symbol-value 'file))) ;pacify byte-compiler 303 (let ((file (symbol-value 'file))) ;pacify byte-compiler
304 (if (or (and (stringp file) (tramp-tramp-file-p file)) 304 (if (or (and (stringp file) (tramp-tramp-file-p file))
305 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name)))) 305 (and (buffer-file-name) (tramp-tramp-file-p (buffer-file-name))))
306 (setq ad-return-value 306 (setq ad-return-value
307 (apply 'tramp-vc-simple-command okstatus command 307 (apply 'tramp-vc-simple-command okstatus command
308 (or file (buffer-file-name)) args)) 308 (or file (buffer-file-name)) args))
309 ad-do-it))) 309 ad-do-it)))
310 310
311 311
312 ;; `vc-workfile-unchanged-p' 312 ;; `vc-workfile-unchanged-p'
360 (vc-resynch-buffer filename t t)) 360 (vc-resynch-buffer filename t t))
361 ) 361 )
362 362
363 363
364 ;; Do we need to advise the vc-user-login-name function anyway? 364 ;; Do we need to advise the vc-user-login-name function anyway?
365 ;; This will return the correct login name for the owner of a 365 ;; This will return the correct login name for the owner of a
366 ;; file. It does not deal with the default remote user name... 366 ;; file. It does not deal with the default remote user name...
367 ;; 367 ;;
368 ;; That is, when vc calls (vc-user-login-name), we return the 368 ;; That is, when vc calls (vc-user-login-name), we return the
369 ;; local login name, something that may be different to the remote 369 ;; local login name, something that may be different to the remote
370 ;; default. 370 ;; default.
371 ;; 371 ;;
372 ;; The remote VC operations will occur as the user that we logged 372 ;; The remote VC operations will occur as the user that we logged
373 ;; in with however - not always the same as the local user. 373 ;; in with however - not always the same as the local user.
374 ;; 374 ;;
375 ;; In the end, I did advise the function. This is because, well, 375 ;; In the end, I did advise the function. This is because, well,
376 ;; the thing didn't work right otherwise ;) 376 ;; the thing didn't work right otherwise ;)
377 ;; 377 ;;
378 ;; Daniel Pittman <daniel@danann.net> 378 ;; Daniel Pittman <daniel@danann.net>
379 379
380 (defun tramp-handle-vc-user-login-name (&optional uid) 380 (defun tramp-handle-vc-user-login-name (&optional uid)
415 (setq ad-return-value 415 (setq ad-return-value
416 (save-match-data 416 (save-match-data
417 (tramp-handle-vc-user-login-name uid)))) ; get the owner name 417 (tramp-handle-vc-user-login-name uid)))) ; get the owner name
418 ad-do-it))) ; else call the original 418 ad-do-it))) ; else call the original
419 419
420 420
421 ;; Determine the name of the user owning a file. 421 ;; Determine the name of the user owning a file.
422 (defun tramp-file-owner (filename) 422 (defun tramp-file-owner (filename)
423 "Return who owns FILE (user name, as a string)." 423 "Return who owns FILE (user name, as a string)."
424 (let ((v (tramp-dissect-file-name 424 (let ((v (tramp-dissect-file-name
425 (tramp-handle-expand-file-name filename)))) 425 (tramp-handle-expand-file-name filename))))
426 (if (not (tramp-handle-file-exists-p filename)) 426 (if (not (tramp-handle-file-exists-p filename))
427 nil ; file cannot be opened 427 nil ; file cannot be opened
428 ;; file exists, find out stuff 428 ;; file exists, find out stuff
429 (save-excursion 429 (save-excursion
433 (format "%s -Lld %s" 433 (format "%s -Lld %s"
434 (tramp-get-ls-command (tramp-file-name-multi-method v) 434 (tramp-get-ls-command (tramp-file-name-multi-method v)
435 (tramp-file-name-method v) 435 (tramp-file-name-method v)
436 (tramp-file-name-user v) 436 (tramp-file-name-user v)
437 (tramp-file-name-host v)) 437 (tramp-file-name-host v))
438 (tramp-shell-quote-argument (tramp-file-name-path v)))) 438 (tramp-shell-quote-argument (tramp-file-name-localname v))))
439 (tramp-wait-for-output) 439 (tramp-wait-for-output)
440 ;; parse `ls -l' output ... 440 ;; parse `ls -l' output ...
441 ;; ... file mode flags 441 ;; ... file mode flags
442 (read (current-buffer)) 442 (read (current-buffer))
443 ;; ... number links 443 ;; ... number links