comparison lisp/vc.el @ 93165:c4dc2a72d555

(vc-status-mark-buffer-changed): Add an optional file parameter. (vc-resynch-buffer): Use it. (vc-delete-file): Expand the file name before using it. Be careful to not create a new buffer with the old file contents. Update the VC state after performing the operation.
author Dan Nicolaescu <dann@ics.uci.edu>
date Sun, 23 Mar 2008 21:05:32 +0000
parents 9f29accd415e
children b7cb59b2c42d
comparison
equal deleted inserted replaced
93164:849abb573acb 93165:c4dc2a72d555
1787 (with-current-buffer buffer 1787 (with-current-buffer buffer
1788 (vc-resynch-window file keep noquery))))) 1788 (vc-resynch-window file keep noquery)))))
1789 (vc-dired-resynch-file file) 1789 (vc-dired-resynch-file file)
1790 (when (memq 'vc-status-mark-buffer-changed after-save-hook) 1790 (when (memq 'vc-status-mark-buffer-changed after-save-hook)
1791 (let ((buffer (get-file-buffer file))) 1791 (let ((buffer (get-file-buffer file)))
1792 (with-current-buffer buffer 1792 (vc-status-mark-buffer-changed file))))
1793 (when buffer (vc-status-mark-buffer-changed))))))
1794 1793
1795 1794
1796 (defun vc-start-entry (files rev comment initial-contents msg action &optional after-hook) 1795 (defun vc-start-entry (files rev comment initial-contents msg action &optional after-hook)
1797 "Accept a comment for an operation on FILES revision REV. 1796 "Accept a comment for an operation on FILES revision REV.
1798 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the 1797 If COMMENT is nil, pop up a VC-log buffer, emit MSG, and set the
3152 (interactive) 3151 (interactive)
3153 (ewoc-filter 3152 (ewoc-filter
3154 vc-status 3153 vc-status
3155 (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date))))) 3154 (lambda (crt) (not (eq (vc-status-fileinfo->state crt) 'up-to-date)))))
3156 3155
3157 (defun vc-status-mark-buffer-changed () 3156 (defun vc-status-mark-buffer-changed (&optional fname)
3158 (let* ((file (expand-file-name buffer-file-name)) 3157 (let* ((file (or fname (expand-file-name buffer-file-name)))
3159 (state (and (vc-backend file) (vc-state file))) 3158 (state (and (vc-backend file) (vc-state file)))
3160 (found-vc-status-buf nil)) 3159 (found-vc-status-buf nil))
3161 (save-excursion 3160 (save-excursion
3162 (dolist (status-buf (buffer-list)) 3161 (dolist (status-buf (buffer-list))
3163 (set-buffer status-buf) 3162 (set-buffer status-buf)
3527 (error "New file lacks a version control directory"))))) 3526 (error "New file lacks a version control directory")))))
3528 3527
3529 (defun vc-delete-file (file) 3528 (defun vc-delete-file (file)
3530 "Delete file and mark it as such in the version control system." 3529 "Delete file and mark it as such in the version control system."
3531 (interactive "fVC delete file: ") 3530 (interactive "fVC delete file: ")
3531 (setq file (expand-file-name file))
3532 (let ((buf (get-file-buffer file)) 3532 (let ((buf (get-file-buffer file))
3533 (backend (vc-backend file))) 3533 (backend (vc-backend file)))
3534 (unless backend 3534 (unless backend
3535 (error "File %s is not under version control" 3535 (error "File %s is not under version control"
3536 (file-name-nondirectory file))) 3536 (file-name-nondirectory file)))
3542 (file-name-nondirectory file))) 3542 (file-name-nondirectory file)))
3543 (error "Abort!")) 3543 (error "Abort!"))
3544 (unless (or (file-directory-p file) (null make-backup-files)) 3544 (unless (or (file-directory-p file) (null make-backup-files))
3545 (with-current-buffer (or buf (find-file-noselect file)) 3545 (with-current-buffer (or buf (find-file-noselect file))
3546 (let ((backup-inhibited nil)) 3546 (let ((backup-inhibited nil))
3547 (backup-buffer)))) 3547 (backup-buffer))
3548 ;; If we didn't have a buffer visiting the file before this
3549 ;; command, kill the buffer created by the above
3550 ;; `find-file-noselect' call.
3551 (unless buf (kill-buffer (current-buffer)))))
3548 (vc-call delete-file file) 3552 (vc-call delete-file file)
3549 ;; If the backend hasn't deleted the file itself, let's do it for him. 3553 ;; If the backend hasn't deleted the file itself, let's do it for him.
3550 (if (file-exists-p file) (delete-file file)))) 3554 (if (file-exists-p file) (delete-file file))
3555 ;; Forget what VC knew about the file.
3556 (vc-file-clearprops file)
3557 (vc-resynch-buffer file buf t)))
3551 3558
3552 ;;;###autoload 3559 ;;;###autoload
3553 (defun vc-rename-file (old new) 3560 (defun vc-rename-file (old new)
3554 "Rename file OLD to NEW, and rename its master file likewise." 3561 "Rename file OLD to NEW, and rename its master file likewise."
3555 (interactive "fVC rename file: \nFRename to: ") 3562 (interactive "fVC rename file: \nFRename to: ")