aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lisp/vc-hooks.el81
1 files changed, 51 insertions, 30 deletions
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 24ab7e6345b..de088a6265c 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -454,7 +454,8 @@ value of this flag.")
454 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS))))) 454 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS)))))
455 455
456(defun vc-name (file) 456(defun vc-name (file)
457 "Return the master name of a file, nil if it is not registered." 457 "Return the master name of a file, nil if it is not registered.
458For CVS, the full name of CVS/Entries is returned."
458 (or (vc-file-getprop file 'vc-name) 459 (or (vc-file-getprop file 'vc-name)
459 (let ((name-and-type (vc-registered file))) 460 (let ((name-and-type (vc-registered file)))
460 (if name-and-type 461 (if name-and-type
@@ -587,10 +588,10 @@ value of this flag.")
587 ((eq (vc-backend file) 'CVS) 588 ((eq (vc-backend file) 'CVS)
588 (or (and (eq (vc-checkout-model file) 'manual) 589 (or (and (eq (vc-checkout-model file) 'manual)
589 (vc-lock-from-permissions file)) 590 (vc-lock-from-permissions file))
590 (if (or (eq (vc-cvs-status file) 'up-to-date) 591 (and (equal (vc-file-getprop file 'vc-checkout-time)
591 (eq (vc-cvs-status file) 'needs-checkout)) 592 (nth 5 (file-attributes file)))
592 (vc-file-setprop file 'vc-locking-user 'none) 593 (vc-file-setprop file 'vc-locking-user 'none))
593 (vc-file-setprop file 'vc-locking-user (vc-file-owner file))))) 594 (vc-file-setprop file 'vc-locking-user (vc-file-owner file))))
594 595
595 ((eq (vc-backend file) 'RCS) 596 ((eq (vc-backend file) 'RCS)
596 (let (p-lock) 597 (let (p-lock)
@@ -730,18 +731,32 @@ value of this flag.")
730 vc-master-templates) 731 vc-master-templates)
731 nil))))) 732 nil)))))
732 733
734(defun vc-utc-string (timeval)
735 ;; Convert a time value into universal time, and return it as a
736 ;; human-readable string. This is to compare CVS checkout times
737 ;; with file modification times.
738 (let (utc (high (car timeval)) (low (nth 1 timeval))
739 (offset (car (current-time-zone))))
740 (setq low (- low offset))
741 (setq utc (if (> low 65535)
742 (list (1+ high) (- low 65536))
743 (if (< low 0)
744 (list (1- high) (+ 65536 low))
745 (list high low))))
746 (current-time-string utc)))
747
733(defun vc-find-cvs-master (dirname basename) 748(defun vc-find-cvs-master (dirname basename)
734 ;; Check if DIRNAME/BASENAME is handled by CVS. 749 ;; Check if DIRNAME/BASENAME is handled by CVS.
735 ;; If it is, do a (throw 'found (cons MASTER 'CVS)). 750 ;; If it is, do a (throw 'found (cons MASTER 'CVS)).
736 ;; Note: If the file is ``cvs add''ed but not yet ``cvs commit''ed 751 ;; Note: This function throws the name of CVS/Entries
737 ;; the MASTER will not actually exist yet. The other parts of VC 752 ;; NOT that of the RCS master file (because we wouldn't be able
738 ;; checks for this condition. This function returns nil if 753 ;; to access it under remote CVS).
739 ;; DIRNAME/BASENAME is not handled by CVS. 754 ;; The function returns nil if DIRNAME/BASENAME is not handled by CVS.
740 (if (and vc-handle-cvs 755 (if (and vc-handle-cvs
741 (file-directory-p (concat dirname "CVS/")) 756 (file-directory-p (concat dirname "CVS/"))
742 (file-readable-p (concat dirname "CVS/Entries")) 757 (file-readable-p (concat dirname "CVS/Entries")))
743 (file-readable-p (concat dirname "CVS/Repository"))) 758 (let (buffer time (fold case-fold-search)
744 (let (buffer (fold case-fold-search)) 759 (file (concat dirname basename)))
745 (unwind-protect 760 (unwind-protect
746 (save-excursion 761 (save-excursion
747 (setq buffer (set-buffer (get-buffer-create "*vc-info*"))) 762 (setq buffer (set-buffer (get-buffer-create "*vc-info*")))
@@ -752,23 +767,22 @@ value of this flag.")
752 (setq case-fold-search nil) 767 (setq case-fold-search nil)
753 (cond 768 (cond
754 ((re-search-forward 769 ((re-search-forward
755 (concat "^/" (regexp-quote basename) "/\\([^/]*\\)/") 770 (concat "^/" (regexp-quote basename)
771 "/\\([^/]*\\)/\\([^/]*\\)/")
756 nil t) 772 nil t)
757 (setq case-fold-search fold) ;; restore the old value 773 (setq case-fold-search fold) ;; restore the old value
758 ;; We found it. Store away version number, now 774 ;; We found it. Store away version number now that we
759 ;; that we are anyhow so close to finding it. 775 ;; are anyhow so close to finding it.
760 (vc-file-setprop (concat dirname basename) 776 (vc-file-setprop file
761 'vc-workfile-version 777 'vc-workfile-version
762 (buffer-substring (match-beginning 1) 778 (match-string 1))
763 (match-end 1))) 779 ;; If the file hasn't been modified since checkout,
764 (vc-insert-file (concat dirname "CVS/Repository")) 780 ;; store the checkout-time.
765 (let ((master 781 (setq mtime (nth 5 (file-attributes file)))
766 (concat (file-name-as-directory 782 (if (string= (match-string 2) (vc-utc-string mtime))
767 (buffer-substring (point-min) 783 (vc-file-setprop file 'vc-checkout-time mtime)
768 (1- (point-max)))) 784 (vc-file-setprop file 'vc-checkout-time 0))
769 basename 785 (throw 'found (cons (concat dirname "CVS/Entries") 'CVS)))
770 ",v")))
771 (throw 'found (cons master 'CVS))))
772 (t (setq case-fold-search fold) ;; restore the old value 786 (t (setq case-fold-search fold) ;; restore the old value
773 nil))) 787 nil)))
774 (kill-buffer buffer))))) 788 (kill-buffer buffer)))))
@@ -803,13 +817,20 @@ of the buffer. With prefix argument, ask for version number."
803 ;; The property is computed when the file is visited, so if it 817 ;; The property is computed when the file is visited, so if it
804 ;; is `nil' now, it is certain that the file is NOT 818 ;; is `nil' now, it is certain that the file is NOT
805 ;; version-controlled. 819 ;; version-controlled.
820 (or (and (equal (vc-file-getprop file 'vc-checkout-time)
821 (nth 5 (file-attributes file)))
822 ;; File has been saved in the same second in which
823 ;; it was checked out. Clear the checkout-time
824 ;; to avoid confusion.
825 (vc-file-setprop file 'vc-checkout-time nil))
826 t)
806 (not (vc-locking-user file)) 827 (not (vc-locking-user file))
807 (eq (vc-checkout-model file) 'implicit) 828 (eq (vc-checkout-model file) 'implicit)
808 (vc-file-setprop file 'vc-locking-user (user-login-name)) 829 (vc-file-setprop file 'vc-locking-user (user-login-name))
809 (progn 830 (or (and (eq (vc-backend file) 'CVS)
810 (and (eq (vc-backend file) 'CVS) 831 (vc-file-setprop file 'vc-cvs-status nil))
811 (vc-file-setprop file 'vc-cvs-status nil)) 832 t)
812 (vc-mode-line file))))) 833 (vc-mode-line file))))
813 834
814(defun vc-mode-line (file &optional label) 835(defun vc-mode-line (file &optional label)
815 "Set `vc-mode' to display type of version control for FILE. 836 "Set `vc-mode' to display type of version control for FILE.