Commit e02d8ae7 authored by Dan Nicolaescu's avatar Dan Nicolaescu
Browse files

* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...

(vc-dir-resynch-file): ... this.  Update callers.
Use vc-string-prefix-p.  Ignore directory args.
(vc-string-prefix-p): CSE.
(vc-resynch-buffer): Restore conditional.

* vc-hooks.el (vc-after-save): Improve test.
(vc-mode-line): Fix indentation.
parent 3b738106
2008-05-27 Dan Nicolaescu <dann@ics.uci.edu>
* vc-dispatcher.el (vc-directory-resynch-file): Rename to ...
(vc-dir-resynch-file): ... this. Update callers.
Use vc-string-prefix-p. Ignore directory args.
(vc-string-prefix-p): CSE.
(vc-resynch-buffer): Restore conditional.
* vc-hooks.el (vc-after-save): Improve test.
(vc-mode-line): Fix indentation.
2008-05-27 Chong Yidong <cyd@stupidchicken.com> 2008-05-27 Chong Yidong <cyd@stupidchicken.com>
* calendar/parse-time.el (parse-time-months) * calendar/parse-time.el (parse-time-months)
......
...@@ -503,7 +503,10 @@ editing!" ...@@ -503,7 +503,10 @@ editing!"
(when buffer (when buffer
(with-current-buffer buffer (with-current-buffer buffer
(vc-resynch-window file keep noquery))))) (vc-resynch-window file keep noquery)))))
(vc-directory-resynch-file file)) ;; Try to avoid unnecessary work, a *vc-dir* buffer is only present
;; if this is true.
(when (memq 'vc-dir-resynch-file after-save-hook)
(vc-dir-resynch-file file)))
(defun vc-buffer-sync (&optional not-urgent) (defun vc-buffer-sync (&optional not-urgent)
"Make sure the current buffer and its working file are in sync. "Make sure the current buffer and its working file are in sync.
...@@ -580,7 +583,7 @@ the buffer contents as a comment." ...@@ -580,7 +583,7 @@ the buffer contents as a comment."
(unless nocomment (unless nocomment
(run-hooks 'vc-logentry-check-hook)) (run-hooks 'vc-logentry-check-hook))
;; Sync parent buffer in case the user modified it while editing the comment. ;; Sync parent buffer in case the user modified it while editing the comment.
;; But not if it is a vc-directory buffer. ;; But not if it is a vc-dir buffer.
(with-current-buffer vc-parent-buffer (with-current-buffer vc-parent-buffer
(or (vc-dispatcher-browsing) (vc-buffer-sync))) (or (vc-dispatcher-browsing) (vc-buffer-sync)))
(unless vc-log-operation (unless vc-log-operation
...@@ -1025,8 +1028,9 @@ If a prefix argument is given, move by that many lines." ...@@ -1025,8 +1028,9 @@ If a prefix argument is given, move by that many lines."
(funcall mark-unmark-function))) (funcall mark-unmark-function)))
(defun vc-string-prefix-p (prefix string) (defun vc-string-prefix-p (prefix string)
(and (>= (length string) (length prefix)) (let ((lpref (length prefix)))
(eq t (compare-strings prefix nil nil string nil (length prefix))))) (and (>= (length string) lpref)
(eq t (compare-strings prefix nil nil string nil lpref)))))
(defun vc-dir-parent-marked-p (arg) (defun vc-dir-parent-marked-p (arg)
;; Return nil if none of the parent directories of arg is marked. ;; Return nil if none of the parent directories of arg is marked.
...@@ -1289,34 +1293,38 @@ If it is a file, return the file itself." ...@@ -1289,34 +1293,38 @@ If it is a file, return the file itself."
(push (expand-file-name (vc-dir-fileinfo->name crt-data)) result)) (push (expand-file-name (vc-dir-fileinfo->name crt-data)) result))
result)) result))
(defun vc-directory-resynch-file (&optional fname) (defun vc-dir-resynch-file (&optional fname)
"Update the entries for FILE in any directory buffers that list it." "Update the entries for FILE in any directory buffers that list it."
(let ((file (or fname (expand-file-name buffer-file-name)))) (let ((file (or fname (expand-file-name buffer-file-name))))
;; The vc-dir case (if (file-directory-p file)
(let ((found-vc-dir-buf nil)) ;; FIXME: Maybe this should never happen?
(save-excursion ;; FIXME: But it is useful to update the state of a directory
(dolist (status-buf (buffer-list)) ;; (more precisely the files in the directory) after some VC
(set-buffer status-buf) ;; operations.
;; look for a vc-dir buffer that might show this file. nil
(when (eq major-mode 'vc-dir-mode) (let ((found-vc-dir-buf nil))
(setq found-vc-dir-buf t) (save-excursion
(let ((ddir (expand-file-name default-directory))) (dolist (status-buf (buffer-list))
;; This test is cvs-string-prefix-p (set-buffer status-buf)
(when (eq t (compare-strings file nil (length ddir) ddir nil nil)) ;; look for a vc-dir buffer that might show this file.
(let* (when (derived-mode-p 'vc-dir-mode)
((file-short (substring file (length ddir))) (setq found-vc-dir-buf t)
(state (let ((ddir (expand-file-name default-directory)))
(funcall (vc-client-object->file-to-state vc-client-mode) (when (vc-string-prefix-p ddir file)
file)) (let*
(extra ((file-short (substring file (length ddir)))
(funcall (vc-client-object->file-to-extra vc-client-mode) (state
file)) (funcall (vc-client-object->file-to-state vc-client-mode)
(entry file))
(list file-short state extra))) (extra
(vc-dir-update (list entry) status-buf)))))) (funcall (vc-client-object->file-to-extra vc-client-mode)
;; We didn't find any vc-dir buffers, remove the hook, it is file))
;; not needed. (entry
(unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-directory-resynch-file)))))) (list file-short state extra)))
(vc-dir-update (list entry) status-buf))))))
;; We didn't find any vc-dir buffers, remove the hook, it is
;; not needed.
(unless found-vc-dir-buf (remove-hook 'after-save-hook 'vc-dir-resynch-file)))))))
(defun vc-dir-mode (client-object) (defun vc-dir-mode (client-object)
"Major mode for dispatcher directory buffers. "Major mode for dispatcher directory buffers.
...@@ -1351,7 +1359,7 @@ U - if the cursor is on a file: unmark all the files with the same state ...@@ -1351,7 +1359,7 @@ U - if the cursor is on a file: unmark all the files with the same state
(set (make-local-variable 'vc-ewoc) (set (make-local-variable 'vc-ewoc)
(ewoc-create (vc-client-object->file-to-info client-object) (ewoc-create (vc-client-object->file-to-info client-object)
(vc-client-object->headers client-object))) (vc-client-object->headers client-object)))
(add-hook 'after-save-hook 'vc-directory-resynch-file) (add-hook 'after-save-hook 'vc-dir-resynch-file)
;; Make sure that if the directory buffer is killed, the update ;; Make sure that if the directory buffer is killed, the update
;; process running in the background is also killed. ;; process running in the background is also killed.
(add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t) (add-hook 'kill-buffer-query-functions 'vc-dir-kill-query nil t)
......
...@@ -745,7 +745,7 @@ Before doing that, check if there are any old backups and get rid of them." ...@@ -745,7 +745,7 @@ Before doing that, check if there are any old backups and get rid of them."
(vc-call-backend backend 'make-version-backups-p file) (vc-call-backend backend 'make-version-backups-p file)
(vc-make-version-backup file))))) (vc-make-version-backup file)))))
(declare-function vc-directory-resynch-file "vc-dispatcher" (&optional fname)) (declare-function vc-dir-resynch-file "vc-dispatcher" (&optional fname))
(defun vc-after-save () (defun vc-after-save ()
"Function to be called by `basic-save-buffer' (in files.el)." "Function to be called by `basic-save-buffer' (in files.el)."
...@@ -766,10 +766,10 @@ Before doing that, check if there are any old backups and get rid of them." ...@@ -766,10 +766,10 @@ Before doing that, check if there are any old backups and get rid of them."
(eq (vc-checkout-model backend (list file)) 'implicit) (eq (vc-checkout-model backend (list file)) 'implicit)
(vc-file-setprop file 'vc-state 'edited) (vc-file-setprop file 'vc-state 'edited)
(vc-mode-line file) (vc-mode-line file)
(when (featurep 'vc) ;; Try to avoid unnecessary work, a *vc-dir* buffer is only
;; If VC is not loaded, then there can't be ;; present if this is true.
;; any directory buffer to synchronize. (when (memq 'vc-dir-resynch-file after-save-hook)
(vc-directory-resynch-file file))))) (vc-dir-resynch-file file)))))
(defvar vc-menu-entry (defvar vc-menu-entry
'(menu-item "Version Control" vc-menu-map '(menu-item "Version Control" vc-menu-map
...@@ -819,9 +819,9 @@ visiting FILE." ...@@ -819,9 +819,9 @@ visiting FILE."
;; If the user is root, and the file is not owner-writable, ;; If the user is root, and the file is not owner-writable,
;; then pretend that we can't write it ;; then pretend that we can't write it
;; even though we can (because root can write anything). ;; even though we can (because root can write anything).
;; This way, even root cannot modify a file that isn't locked. ;; This way, even root cannot modify a file that isn't locked.
(and (equal file buffer-file-name) (and (equal file buffer-file-name)
(not buffer-read-only) (not buffer-read-only)
(zerop (user-real-uid)) (zerop (user-real-uid))
(zerop (logand (file-modes buffer-file-name) 128)) (zerop (logand (file-modes buffer-file-name) 128))
(setq buffer-read-only t))) (setq buffer-read-only t)))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment