changeset 95587:cb8fbc8ef1c5

(vc-update): Use `save-some-buffers' instead of signaling an error on modified buffers.
author Sam Steingold <sds@gnu.org>
date Thu, 05 Jun 2008 15:53:05 +0000
parents 64da3838a9aa
children be81a1d92312
files lisp/ChangeLog lisp/vc.el
diffstat 2 files changed, 19 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Thu Jun 05 14:37:42 2008 +0000
+++ b/lisp/ChangeLog	Thu Jun 05 15:53:05 2008 +0000
@@ -1,3 +1,8 @@
+2008-06-05  Sam Steingold  <sds@gnu.org>
+
+	* vc.el (vc-update): Use `save-some-buffers' instead of signaling
+	an error on modified buffers.
+
 2008-06-05  Stefan Monnier  <monnier@iro.umontreal.ca>
 
 	* progmodes/etags.el (tags-verify-table): Be careful to use and update
--- a/lisp/vc.el	Thu Jun 05 14:37:42 2008 +0000
+++ b/lisp/vc.el	Thu Jun 05 15:53:05 2008 +0000
@@ -375,7 +375,7 @@
 ;;
 ;;   Return a string containing all log entries that were made for FILE.
 ;;   This is used for transferring a file from one backend to another,
-;;   retaining comment information. 
+;;   retaining comment information.
 ;;
 ;; - update-changelog (files)
 ;;
@@ -562,7 +562,7 @@
 ;;   update/merge on a file basis, but on a whole repository basis.
 ;;   vc-update and vc-merge assume the arguments are always files,
 ;;   they don't deal with directories.  Make sure the *vc-dir* buffer
-;;   is updated after these operations. 
+;;   is updated after these operations.
 ;;   At least bzr, git and hg should benefit from this.
 ;;
 ;;;; Improved branch and tag handling:
@@ -571,8 +571,8 @@
 ;;   display the branch name in the mode-line. Replace
 ;;   vc-cvs-sticky-tag with that.
 ;;
-;; - C-x v b does switch to a different backend, but the mode line is not 
-;;   adapted accordingly.  Also, it considers RCS and CVS to be the same, 
+;; - C-x v b does switch to a different backend, but the mode line is not
+;;   adapted accordingly.  Also, it considers RCS and CVS to be the same,
 ;;   which is pretty confusing.
 ;;
 ;; - vc-create-tag and vc-retrieve-tag should update the
@@ -1255,7 +1255,7 @@
 	(when (not (equal buffer-file-name file))
 	  (find-file-other-window file))
 	(if (save-window-excursion
-	      (vc-diff-internal nil 
+	      (vc-diff-internal nil
 				(cons (car vc-fileset) (cons (cadr vc-fileset) (list file)))
 				(vc-working-revision file) nil)
 	      (goto-char (point-min))
@@ -1844,11 +1844,11 @@
 
 (defun vc-default-status-extra-headers (backend dir)
   ;; Be loud by default to remind people to add code to display
-  ;; backend specific headers.  
+  ;; backend specific headers.
   ;; XXX: change this to return nil before the release.
   (concat
    (propertize "Extra      : " 'face 'font-lock-type-face)
-   (propertize "Please add backend specific headers here.  It's easy!" 
+   (propertize "Please add backend specific headers here.  It's easy!"
 	       'face 'font-lock-warning-face)))
 
 (defun vc-dir-headers (backend dir)
@@ -2027,7 +2027,7 @@
 
 (defun vc-make-backend-object (file-or-dir)
   "Create the backend capability object needed by vc-dispatcher."
-  (vc-create-client-object 
+  (vc-create-client-object
    "VC dir"
    (vc-dir-headers vc-dir-backend file-or-dir)
    #'vc-generic-status-printer
@@ -2061,7 +2061,7 @@
 	;(define-key map "A" 'vc-annotate) ;; g is taken by dispatcher refresh
 	(define-key map "x" 'vc-dir-hide-up-to-date))
       )
-    ;; FIXME: Needs to alter a buffer-local map, otherwise clients may clash  
+    ;; FIXME: Needs to alter a buffer-local map, otherwise clients may clash
     (let ((map vc-dir-menu-map))
     ;; VC info details
     (define-key map [sepvcdet] '("--"))
@@ -2284,10 +2284,12 @@
   (let* ((vc-fileset (vc-deduce-fileset))
 	 (backend (car vc-fileset))
 	 (files (cadr vc-fileset)))
+    (save-some-buffers          ; save buffers visiting files
+     nil (lambda ()
+           (and (buffer-modified-p)
+                (let ((file (buffer-file-name)))
+                  (and file (member file files))))))
     (dolist (file files)
-      (when (let ((buf (get-file-buffer file)))
-	      (and buf (buffer-modified-p buf)))
-	(error "Please kill or save all modified buffers before updating."))
       (if (vc-up-to-date-p file)
 	  (vc-checkout file nil t)
 	(if (eq (vc-checkout-model backend (list file)) 'locking)