Commits

Anonymous committed 84a9555

Patch from Albert L. Ting <alt@artisan.com>

  • Participants
  • Parent commits dfaad5d
  • Tags vc-1_27

Comments (0)

Files changed (4)

+2001-04-26  Albert L. Ting  <alt@artisan.com>
+
+	* vc.el (vc-do-command): 
+	(vc-revert-buffer):
+	Fix a bug that could cause files to be moved to another
+	directory.
+
+2001-04-26  Albert L. Ting  <alt@artisan.com>
+
+	* vc-hooks.el (vc-mode-face): New.
+	(vc-mode-ext): New.
+	(vc-mode-line): Use them.
+
 2001-02-14  Steve Youngs  <youngs@xemacs.org>
 
 	* vc.el: Require compile, sendmail & ediff-util.
 # the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 # Boston, MA 02111-1307, USA.
 
-VERSION = 1.26
+VERSION = 1.27
 AUTHOR_VERSION =
 MAINTAINER = XEmacs Development Team <xemacs-beta@xemacs.org>
 PACKAGE = vc
   :type 'boolean
   :group 'vc)
 
+(defcustom vc-mode-face 'highlight
+  "*Face used to display vc mode line, or nil/default for none"
+  :type 'face
+  :group 'vc)
+
 (defun vc-mistrust-permissions (file)
   ;; Access function to the above.
   (or (eq vc-mistrust-permissions 't)
 	     t)
 	 (vc-mode-line file))))
 
+(defvar vc-mode-ext (detach-extent (make-extent 0 0 "")))
+
 (defun vc-mode-line (file &optional label)
   "Set `vc-mode' to display type of version control for FILE.
 The value is set in the current buffer, which should be the buffer
   (let ((vc-type (vc-backend file)))
     (setq vc-mode
 	  (and vc-type
-	       (concat " " (or label (symbol-name vc-type)) 
-		       (and vc-display-status (vc-status file)))))
+	       (let* ((str 
+		       (concat (or label (symbol-name vc-type)) 
+			       (and vc-display-status (vc-status file))))
+		      (test-str "^\\(CVS\\|RCS\\|SCCS\\)-")
+		      (not-locked (string-match test-str str)))
+		 (if (or not-locked (not vc-mode-face))
+		     (concat " " str)
+		   (progn
+		     (set-extent-face vc-mode-ext vc-mode-face)
+		     (list " " (cons vc-mode-ext str)))))))
     ;; If the file is locked by some other user, make
     ;; the buffer read-only.  Like this, even root
     ;; cannot modify a file that someone else has locked.
       (message "Running %s on %s..." command file))
   (let ((obuf (current-buffer)) (camefrom (current-buffer))
 	(squeezed nil)
-	(vc-file (and file (vc-name file)))
 	(olddir default-directory)
-	status)
+	vc-file status)
     (set-buffer (get-buffer-create buffer))
     (set (make-local-variable 'vc-parent-buffer) camefrom)
     (set (make-local-variable 'vc-parent-buffer-name)
     (mapcar
      (function (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
      flags)
-    (if (and vc-file (eq last 'MASTER))
+    ;; do NOT call vc-name until (eq last 'MASTER).  vc-name calls vc-backend,
+    ;; which sets the file's 'vc-backend prop.  If we preset vc-file in the
+    ;; let statement above, the 'vc-backend prop also gets set when (eq last
+    ;; 'WORKFILE), which is too soon (occurs when one does a vc-register).
+    (if (and (eq last 'MASTER) file (setq vc-file (vc-name file)))
 	(setq squeezed (append squeezed (list vc-file))))
     (if (eq last 'WORKFILE)
 	(progn
 	;; This operation should always ask for confirmation.
 	(vc-suppress-confirm nil)
 	(obuf (current-buffer)) (changed (vc-diff nil t)))
-    (if (and changed (not (yes-or-no-p "Discard changes? ")))
-	(progn
+
+    (if changed
+        (unwind-protect
+            (if (not (yes-or-no-p "Discard changes? "))
+                (error "Revert cancelled"))
 	  (if (and (window-dedicated-p (selected-window))
 		   (one-window-p t 'selected-frame))
 	      (make-frame-invisible (selected-frame))
-	    (delete-window))
-	  (error "Revert cancelled"))
-      (set-buffer obuf))
-    (if changed
-	(if (and (window-dedicated-p (selected-window))
-		 (one-window-p t 'selected-frame))
-	    (make-frame-invisible (selected-frame))
-	  (delete-window)))
+	    (delete-window))))
+    (set-buffer obuf)
     (vc-backend-revert file)
-    (vc-resynch-window file t t)
-    )
+    (vc-resynch-window file t t))
   )
 
 ;;;###autoload