changeset 5212:f8ba69b02832

(vc-workfile-unchanged-p): Add optional argument specifying whether we want to compute the differences if the file is changed. Otherwise, use cmp instead of diff. (vc-next-action-on-file): Use new vc-workfile-unchanged-p option; this avoids recomputing the differences in some cases. (vc-backend-diff): OLDVERS is now optional; all callers changed. New optional argument CMP says to use `cmp' rather than `diff'.
author Paul Eggert <eggert@twinsun.com>
date Fri, 03 Dec 1993 09:30:38 +0000
parents 7124a811b67b
children e080f780f381
files lisp/vc.el
diffstat 1 files changed, 28 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/vc.el	Fri Dec 03 09:29:18 1993 +0000
+++ b/lisp/vc.el	Fri Dec 03 09:30:38 1993 +0000
@@ -340,21 +340,17 @@
 	    (error "Aborted"))
 	(save-buffer))))
 
-(defun vc-workfile-unchanged-p (file)
+(defun vc-workfile-unchanged-p (file &optional want-differences-if-changed)
   ;; Has the given workfile changed since last checkout?
   (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
 	(lastmod (nth 5 (file-attributes file))))
-    (if checkout-time
-     (equal lastmod checkout-time)
-     (if (zerop (vc-backend-diff file nil))
-	 (progn
-	   (vc-file-setprop file 'vc-checkout-time lastmod)
-	   t)
-       (progn
-	   (vc-file-setprop file 'vc-checkout-time '(0 . 0))
-	   nil
-	 ))
-     )))
+    (or (equal checkout-time lastmod)
+	(and (or (not checkout-time) want-differences-if-changed)
+	     (let ((unchanged (zerop (vc-backend-diff file nil nil
+				      (not want-differences-if-changed)))))
+	       ;; 0 stands for an unknown time; it can't match any mod time.
+	       (vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0))
+	       unchanged)))))
 
 (defun vc-next-action-on-file (file verbose &optional comment)
   ;;; If comment is specified, it will be used as an admin or checkin comment.
@@ -372,8 +368,7 @@
      ;; if there is no lock on the file, assert one and get it
      ((not (setq owner (vc-locking-user file)))
       (if (and vc-checkout-carefully
-	       (not (vc-workfile-unchanged-p file))
-	       (not (zerop (vc-backend-diff file nil))))
+	       (not (vc-workfile-unchanged-p file t)))
 	  (if (save-window-excursion
 		(pop-to-buffer "*vc*")
 		(goto-char (point-min))
@@ -777,7 +772,7 @@
       (setq unchanged (vc-workfile-unchanged-p buffer-file-name))
       (if unchanged
 	  (message "No changes to %s since latest version." file)
-	(vc-backend-diff file nil)
+	(vc-backend-diff file)
 	;; Ideally, we'd like at this point to parse the diff so that
 	;; the buffer effectively goes into compilation mode and we
 	;; can visit the old and new change locations via next-error.
@@ -1622,22 +1617,27 @@
    )
   )
 
-(defun vc-backend-diff (file oldvers &optional newvers)
-  ;; Get a difference report between two versions
+(defun vc-backend-diff (file &optional oldvers newvers cmp)
+  ;; Get a difference report between two versions of FILE.
+  ;; Get only a brief comparison report if CMP, a difference report otherwise.
   (if (eq (vc-backend-deduce file) 'SCCS)
       (setq oldvers (vc-lookup-triple file oldvers))
       (setq newvers (vc-lookup-triple file newvers)))
-  (apply 'vc-do-command 1
-	 (or (vc-backend-dispatch file "vcdiff" "rcsdiff")
-	     (vc-registration-error file))
-	 file
-	 "-q"
-	 (and oldvers (concat "-r" oldvers))
-	 (and newvers (concat "-r" newvers))
-	 (if (listp diff-switches)
-	     diff-switches
-	   (list diff-switches))
-  ))
+  (let* ((command (or (vc-backend-dispatch file "vcdiff" "rcsdiff")
+		      (vc-registration-error file)))
+	 (options (append (list (and cmp "--brief")
+				"-q"
+				(and oldvers (concat "-r" oldvers))
+				(and newvers (concat "-r" newvers)))
+			  (and (not cmp)
+			       (if (listp diff-switches)
+				   diff-switches
+				 (list diff-switches)))))
+	 (status (apply 'vc-do-command 2 command file options)))
+    ;; Some RCS versions don't understand "--brief"; work around this.
+    (if (eq status 2)
+	(apply 'vc-do-command 1 command file (if cmp options (cdr options)))
+      status)))
 
 (defun vc-check-headers ()
   "Check if the current file has any headers in it."