/[emacs]/emacs/lisp/vc-hooks.el
ViewVC logotype

Diff of /emacs/lisp/vc-hooks.el

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.147 by lektu, Wed Feb 5 23:14:06 2003 UTC revision 1.148 by monnier, Wed May 7 17:20:29 2003 UTC
# Line 45  Line 45 
45  (defvar vc-header-alist ())  (defvar vc-header-alist ())
46  (make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header)  (make-obsolete-variable 'vc-header-alist 'vc-BACKEND-header)
47    
48  (defcustom vc-handled-backends '(RCS CVS SCCS)  (defcustom vc-handled-backends '(RCS CVS SVN MCVS SCCS)
49    "*List of version control backends for which VC will be used.    "*List of version control backends for which VC will be used.
50  Entries in this list will be tried in order to determine whether a  Entries in this list will be tried in order to determine whether a
51  file is under that sort of version control.  file is under that sort of version control.
# Line 281  backend is tried first." Line 281  backend is tried first."
281  (defun vc-backend (file)  (defun vc-backend (file)
282    "Return the version control type of FILE, nil if it is not registered."    "Return the version control type of FILE, nil if it is not registered."
283    ;; `file' can be nil in several places (typically due to the use of    ;; `file' can be nil in several places (typically due to the use of
284    ;; code like (vc-backend (buffer-file-name))).    ;; code like (vc-backend buffer-file-name)).
285    (when (stringp file)    (when (stringp file)
286      (let ((property (vc-file-getprop file 'vc-backend)))      (let ((property (vc-file-getprop file 'vc-backend)))
287        ;; Note that internally, Emacs remembers unregistered        ;; Note that internally, Emacs remembers unregistered
# Line 487  in or out whenever you toggle the read-o Line 487  in or out whenever you toggle the read-o
487    (interactive "P")    (interactive "P")
488    (if (or (and (boundp 'vc-dired-mode) vc-dired-mode)    (if (or (and (boundp 'vc-dired-mode) vc-dired-mode)
489            ;; use boundp because vc.el might not be loaded            ;; use boundp because vc.el might not be loaded
490            (vc-backend (buffer-file-name)))            (vc-backend buffer-file-name))
491        (vc-next-action verbose)        (vc-next-action verbose)
492      (toggle-read-only)))      (toggle-read-only)))
493    
# Line 533  Before doing that, check if there are an Line 533  Before doing that, check if there are an
533    ;; If the file on disk is still in sync with the repository,    ;; If the file on disk is still in sync with the repository,
534    ;; and version backups should be made, copy the file to    ;; and version backups should be made, copy the file to
535    ;; another name.  This enables local diffs and local reverting.    ;; another name.  This enables local diffs and local reverting.
536    (let ((file (buffer-file-name)))    (let ((file buffer-file-name))
537      (and (vc-backend file)      (and (vc-backend file)
538           (vc-up-to-date-p file)           (vc-up-to-date-p file)
539           (eq (vc-checkout-model file) 'implicit)           (eq (vc-checkout-model file) 'implicit)
# Line 545  Before doing that, check if there are an Line 545  Before doing that, check if there are an
545    ;; If the file in the current buffer is under version control,    ;; If the file in the current buffer is under version control,
546    ;; up-to-date, and locking is not used for the file, set    ;; up-to-date, and locking is not used for the file, set
547    ;; the state to 'edited and redisplay the mode line.    ;; the state to 'edited and redisplay the mode line.
548    (let ((file (buffer-file-name)))    (let ((file buffer-file-name))
549      (and (vc-backend file)      (and (vc-backend file)
550           (or (and (equal (vc-file-getprop file 'vc-checkout-time)           (or (and (equal (vc-file-getprop file 'vc-checkout-time)
551                           (nth 5 (file-attributes file)))                           (nth 5 (file-attributes file)))
# Line 568  Before doing that, check if there are an Line 568  Before doing that, check if there are an
568  The value is set in the current buffer, which should be the buffer  The value is set in the current buffer, which should be the buffer
569  visiting FILE."  visiting FILE."
570    (interactive (list buffer-file-name))    (interactive (list buffer-file-name))
571    (if (not (vc-backend file))    (let ((backend (vc-backend file)))
572        (setq vc-mode nil)      (if (not backend)
573      (setq vc-mode (concat " " (if vc-display-status          (setq vc-mode nil)
574                                    (vc-call mode-line-string file)        (setq vc-mode (concat " " (if vc-display-status
575                                  (symbol-name (vc-backend file)))))                                      (vc-call mode-line-string file)
576      ;; If the file is locked by some other user, make                                    (symbol-name backend))))
577      ;; the buffer read-only.  Like this, even root        ;; If the file is locked by some other user, make
578      ;; cannot modify a file that someone else has locked.        ;; the buffer read-only.  Like this, even root
579      (and (equal file (buffer-file-name))        ;; cannot modify a file that someone else has locked.
580           (stringp (vc-state file))        (and (equal file buffer-file-name)
581           (setq buffer-read-only t))             (stringp (vc-state file))
582      ;; If the user is root, and the file is not owner-writable,             (setq buffer-read-only t))
583      ;; then pretend that we can't write it        ;; If the user is root, and the file is not owner-writable,
584      ;; even though we can (because root can write anything).        ;; then pretend that we can't write it
585      ;; This way, even root cannot modify a file that isn't locked.        ;; even though we can (because root can write anything).
586      (and (equal file (buffer-file-name))        ;; This way, even root cannot modify a file that isn't locked.
587           (not buffer-read-only)        (and (equal file buffer-file-name)
588           (zerop (user-real-uid))             (not buffer-read-only)
589           (zerop (logand (file-modes (buffer-file-name)) 128))             (zerop (user-real-uid))
590           (setq buffer-read-only t)))             (zerop (logand (file-modes buffer-file-name) 128))
591    (force-mode-line-update)             (setq buffer-read-only t)))
592    (vc-backend file))      (force-mode-line-update)
593        backend))
594    
595  (defun vc-default-mode-line-string (backend file)  (defun vc-default-mode-line-string (backend file)
596    "Return string for placement in modeline by `vc-mode-line' for FILE.    "Return string for placement in modeline by `vc-mode-line' for FILE.
# Line 698  Used in `find-file-not-found-hooks'." Line 699  Used in `find-file-not-found-hooks'."
699    
700  (defun vc-kill-buffer-hook ()  (defun vc-kill-buffer-hook ()
701    "Discard VC info about a file when we kill its buffer."    "Discard VC info about a file when we kill its buffer."
702    (if (buffer-file-name)    (if buffer-file-name
703        (vc-file-clearprops (buffer-file-name))))        (vc-file-clearprops buffer-file-name)))
704    
705  (add-hook 'kill-buffer-hook 'vc-kill-buffer-hook)  (add-hook 'kill-buffer-hook 'vc-kill-buffer-hook)
706    

Legend:
Removed from v.1.147  
changed lines
  Added in v.1.148

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26