changeset 87826:06bebff4deab

Add a TODO note about vc-state. (vc-next-action): Register 'unregistered and 'ignored files. Use when and unless instead of if where appropriate. (vc-start-entry): Fix typo. (vc-status): Autoload it.
author Dan Nicolaescu <dann@ics.uci.edu>
date Fri, 18 Jan 2008 14:12:44 +0000
parents 2427d974638e
children 1fb61371633b
files lisp/ChangeLog lisp/vc.el
diffstat 2 files changed, 46 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Fri Jan 18 07:23:26 2008 +0000
+++ b/lisp/ChangeLog	Fri Jan 18 14:12:44 2008 +0000
@@ -1,3 +1,11 @@
+2008-01-18  Dan Nicolaescu  <dann@ics.uci.edu>
+
+	* vc.el: Add a TODO note about vc-state.
+	(vc-next-action): Register 'unregistered and 'ignored files.  Use
+	when and unless instead of if where appropriate.
+	(vc-start-entry): Fix typo.
+	(vc-status): Autoload it.
+
 2008-01-18  Glenn Morris  <rgm@gnu.org>
 
 	* ffap.el (ffap-alist): Remove space from RFC regexp.
@@ -12,7 +20,7 @@
 	* ibuffer.el (ibuffer-mode): Fix typo in previous change.
 
 2008-01-17 Vinicius Jose Latorre <viniciusjl@ig.com.br>
-2008-01-17 Miles Bader <miles@gnu.org>
+	   Miles Bader <miles@gnu.org>
 
 	* blank-mode.el: New file.  Minor mode to visualise (HARD) SPACE,
 	TAB, NEWLINE.  Miles Bader <miles@gnu.org> wrote the original code
--- a/lisp/vc.el	Fri Jan 18 07:23:26 2008 +0000
+++ b/lisp/vc.el	Fri Jan 18 14:12:44 2008 +0000
@@ -537,6 +537,9 @@
 ;; - make it easier to write logs, maybe C-x 4 a should add to the log
 ;;   buffer if there's one instead of the ChangeLog.
 ;;
+;; - make vc-state for all backends return 'unregistered instead of
+;;   nil for unregistered files, then update vc-next-action.
+;;
 ;; - deal with push/pull operations.
 ;;
 ;; - decide if vc-status should replace vc-dired.
@@ -1434,9 +1437,9 @@
 	 revision)
     ;; Verify that the fileset is homogenous
     (dolist (file (cdr files))
-      (if (not (vc-compatible-state (vc-state file) state))
-	  (error "Fileset is in a mixed-up state"))
-      (if (not (eq (vc-checkout-model file) model))
+      (unless (vc-compatible-state (vc-state file) state)
+	(error "Fileset is in a mixed-up state"))
+      (unless (eq (vc-checkout-model file) model)
 	  (error "Fileset has mixed checkout models")))
     ;; Check for buffers in the fileset not matching the on-disk contents.
     (dolist (file files)
@@ -1458,13 +1461,15 @@
 		(error "Aborted"))
 	    ;; Now, check if we have unsaved changes.
 	    (vc-buffer-sync t)
-	    (if (buffer-modified-p)
-		(or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
-		    (error "Aborted")))))))
+	    (when (buffer-modified-p)
+	      (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
+		  (error "Aborted")))))))
     ;; Do the right thing
     (cond
      ;; Files aren't registered
-     ((not state)
+     ((or (not state)  ;; RCS uses nil for unregistered files.
+	  (eq state 'unregistered)
+	  (eq state 'ignored))
       (mapc 'vc-register files))
      ;; Files are up-to-date, or need a merge and user specified a revision
      ((or (eq state 'up-to-date) (and verbose (eq state 'needs-patch)))
@@ -1488,32 +1493,30 @@
       (let ((ready-for-commit files))
 	;; If files are edited but read-only, give user a chance to correct
 	(dolist (file files)
-	  (if (not (file-writable-p file))
-	      (progn
-		;; Make the file+buffer read-write.
-		(unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file))
-		  (error "Aborted"))
-		(set-file-modes file (logior (file-modes file) 128))
-		(let ((visited (get-file-buffer file)))
-		  (if visited
-		      (with-current-buffer visited
-			(toggle-read-only -1)))))))
+	  (unless (file-writable-p file)
+	    ;; Make the file+buffer read-write.
+	    (unless (y-or-n-p (format "%s is edited but read-only; make it writable and continue?" file))
+	      (error "Aborted"))
+	    (set-file-modes file (logior (file-modes file) 128))
+	    (let ((visited (get-file-buffer file)))
+	      (when visited
+		(with-current-buffer visited
+		  (toggle-read-only -1))))))
 	;; Allow user to revert files with no changes
 	(save-excursion
           (dolist (file files)
             (let ((visited (get-file-buffer file)))
               ;; For files with locking, if the file does not contain
               ;; any changes, just let go of the lock, i.e. revert.
-              (if (and (not (eq model 'implicit))
-                       (vc-workfile-unchanged-p file)
-                       ;; If buffer is modified, that means the user just
-                       ;; said no to saving it; in that case, don't revert,
-                       ;; because the user might intend to save after
-                       ;; finishing the log entry and committing.
-                       (not (and visited (buffer-modified-p))))
-                  (progn
-                    (vc-revert-file file)
-                    (delete file ready-for-commit))))))
+              (when (and (not (eq model 'implicit))
+			 (vc-workfile-unchanged-p file)
+			 ;; If buffer is modified, that means the user just
+			 ;; said no to saving it; in that case, don't revert,
+			 ;; because the user might intend to save after
+			 ;; finishing the log entry and committing.
+			 (not (and visited (buffer-modified-p))))
+		(vc-revert-file file)
+		(delete file ready-for-commit)))))
 	;; Remaining files need to be committed
 	(if (not ready-for-commit)
 	    (message "No files remain to be committed")
@@ -1539,16 +1542,16 @@
 			  "%s is not up-to-date.  Get latest revision? "
 			  (file-name-nondirectory file)))
 	    (vc-checkout file (eq model 'implicit) t)
-	  (if (and (not (eq model 'implicit))
-		   (yes-or-no-p "Lock this revision? "))
-	      (vc-checkout file t)))))
+	  (when (and (not (eq model 'implicit))
+		     (yes-or-no-p "Lock this revision? "))
+	    (vc-checkout file t)))))
      ;; needs-merge
      ((eq state 'needs-merge)
       (dolist (file files)
-	(if (yes-or-no-p (format
+	(when (yes-or-no-p (format
 			  "%s is not up-to-date.  Merge in changes now? "
 			  (file-name-nondirectory file)))
-	    (vc-maybe-resolve-conflicts file (vc-call merge-news file)))))
+	  (vc-maybe-resolve-conflicts file (vc-call merge-news file)))))
 
      ;; unlocked-changes
      ((eq state 'unlocked-changes)
@@ -1697,7 +1700,7 @@
 entered COMMENT.  If COMMENT is t, also do action immediately with an
 empty comment.  Remember the file's buffer in `vc-parent-buffer'
 \(current one if no file).  AFTER-HOOK specifies the local value
-for vc-log-operation-hook."
+for `vc-log-after-operation-hook'."
   (let ((parent
          (if (eq major-mode 'vc-dired-mode)
              ;; If we are called from VC dired, the parent buffer is
@@ -2562,6 +2565,7 @@
   ;; Must be in sync with vc-status-printer.
   (forward-char 25))
 
+;;;###autoload
 (defun vc-status (dir)
   "Show the VC status for DIR."
   (interactive "DVC status for directory: ")