comparison lisp/vc.el @ 81990:cd7d70b6659e

(vc-delistify): Use mapconcat. (vc-do-command): Minor simplification. (vc-expand-dirs): Use push.
author Stefan Monnier <monnier@iro.umontreal.ca>
date Fri, 20 Jul 2007 03:59:03 +0000
parents 5fe5698ac0fb
children 1350ba0c0448
comparison
equal deleted inserted replaced
81989:f9f0d45ce573 81990:cd7d70b6659e
996 Each function is called inside the buffer in which the command was run 996 Each function is called inside the buffer in which the command was run
997 and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.") 997 and is passed 3 arguments: the COMMAND, the FILE and the FLAGS.")
998 998
999 (defun vc-delistify (filelist) 999 (defun vc-delistify (filelist)
1000 "Smash a FILELIST into a file list string suitable for info messages." 1000 "Smash a FILELIST into a file list string suitable for info messages."
1001 (cond ((not filelist) ".") 1001 (if (not filelist) "." (mapconcat 'identity filelist " ")))
1002 ((= (length filelist) 1) (car filelist))
1003 (t (concat (car filelist) " " (vc-delistify (cdr filelist))))))
1004 1002
1005 (defvar w32-quote-process-args) 1003 (defvar w32-quote-process-args)
1006 ;;;###autoload 1004 ;;;###autoload
1007 (defun vc-do-command (buffer okstatus command file-or-list &rest flags) 1005 (defun vc-do-command (buffer okstatus command file-or-list &rest flags)
1008 "Execute a VC command, notifying user and checking for errors. 1006 "Execute a VC command, notifying user and checking for errors.
1017 a file name or set of files). If an optional list of FLAGS is present, 1015 a file name or set of files). If an optional list of FLAGS is present,
1018 that is inserted into the command line before the filename." 1016 that is inserted into the command line before the filename."
1019 ;; FIXME: file-relative-name can return a bogus result because 1017 ;; FIXME: file-relative-name can return a bogus result because
1020 ;; it doesn't look at the actual file-system to see if symlinks 1018 ;; it doesn't look at the actual file-system to see if symlinks
1021 ;; come into play. 1019 ;; come into play.
1022 (let* ((files 1020 (let* ((files
1023 (mapcar 'file-relative-name 1021 (mapcar (lambda (f) (file-relative-name (expand-file-name f)))
1024 (cond ((not file-or-list) '()) 1022 (if (listp file-or-list) file-or-list (list file-or-list))))
1025 ((listp file-or-list) (mapcar 'expand-file-name file-or-list)) 1023 (full-command
1026 (t (list (expand-file-name file-or-list))))))
1027 (full-command
1028 (concat command " " (vc-delistify flags) " " (vc-delistify files)))) 1024 (concat command " " (vc-delistify flags) " " (vc-delistify files))))
1029 (if vc-command-messages 1025 (if vc-command-messages
1030 (message "Running %s..." full-command)) 1026 (message "Running %s..." full-command))
1031 (save-current-buffer 1027 (save-current-buffer
1032 (unless (or (eq buffer t) 1028 (unless (or (eq buffer t)
1553 t) 1549 t)
1554 1550
1555 (defun vc-expand-dirs (file-or-dir-list) 1551 (defun vc-expand-dirs (file-or-dir-list)
1556 "Expands directories in a file list specification. 1552 "Expands directories in a file list specification.
1557 Only files already under version control are noticed." 1553 Only files already under version control are noticed."
1554 ;; FIXME: Kill this function.
1558 (let ((flattened '())) 1555 (let ((flattened '()))
1559 (dolist (node file-or-dir-list) 1556 (dolist (node file-or-dir-list)
1560 (vc-file-tree-walk node (lambda (f) (if (vc-backend f) (setq flattened (cons f flattened)))))) 1557 (vc-file-tree-walk
1558 node (lambda (f) (if (vc-backend f) (push f flattened)))))
1561 (nreverse flattened))) 1559 (nreverse flattened)))
1562 1560
1563 (defun vc-resynch-window (file &optional keep noquery) 1561 (defun vc-resynch-window (file &optional keep noquery)
1564 "If FILE is in the current buffer, either revert or unvisit it. 1562 "If FILE is in the current buffer, either revert or unvisit it.
1565 The choice between revert (to see expanded keywords) and unvisit depends on 1563 The choice between revert (to see expanded keywords) and unvisit depends on
3490 ;; These things should probably be generally available 3488 ;; These things should probably be generally available
3491 3489
3492 (defun vc-file-tree-walk (dirname func &rest args) 3490 (defun vc-file-tree-walk (dirname func &rest args)
3493 "Walk recursively through DIRNAME. 3491 "Walk recursively through DIRNAME.
3494 Invoke FUNC f ARGS on each VC-managed file f underneath it." 3492 Invoke FUNC f ARGS on each VC-managed file f underneath it."
3493 ;; FIXME: Kill this function.
3495 (vc-file-tree-walk-internal (expand-file-name dirname) func args) 3494 (vc-file-tree-walk-internal (expand-file-name dirname) func args)
3496 (message "Traversing directory %s...done" dirname)) 3495 (message "Traversing directory %s...done" dirname))
3497 3496
3498 (defun vc-file-tree-walk-internal (file func args) 3497 (defun vc-file-tree-walk-internal (file func args)
3499 (if (not (file-directory-p file)) 3498 (if (not (file-directory-p file))
3500 (if (vc-backend file) (apply func file args)) 3499 (if (vc-backend file) (apply func file args))
3501 (message "Traversing directory %s..." (abbreviate-file-name file)) 3500 (message "Traversing directory %s..." (abbreviate-file-name file))
3502 (let ((dir (file-name-as-directory file))) 3501 (let ((dir (file-name-as-directory file)))
3503 (mapcar 3502 (mapcar
3504 (lambda (f) (or 3503 (lambda (f) (or
3505 (string-equal f ".") 3504 (string-equal f ".")
3506 (string-equal f "..") 3505 (string-equal f "..")
3507 (member f vc-directory-exclusion-list) 3506 (member f vc-directory-exclusion-list)
3508 (let ((dirf (expand-file-name f dir))) 3507 (let ((dirf (expand-file-name f dir)))
3509 (or 3508 (or
3510 (file-symlink-p dirf);; Avoid possible loops 3509 (file-symlink-p dirf) ;; Avoid possible loops.
3511 (vc-file-tree-walk-internal dirf func args))))) 3510 (vc-file-tree-walk-internal dirf func args)))))
3512 (directory-files dir))))) 3511 (directory-files dir)))))
3513 3512
3514 (provide 'vc) 3513 (provide 'vc)
3515 3514
3516 ;; DEVELOPER'S NOTES ON CONCURRENCY PROBLEMS IN THIS CODE 3515 ;; DEVELOPER'S NOTES ON CONCURRENCY PROBLEMS IN THIS CODE