Try to handle buffer/file modifications which conflict with VCS locking.
[bpt/emacs.git] / lisp / vc / vc.el
index fe25980..9b8b949 100644 (file)
 (eval-when-compile
   (require 'dired))
 
+(declare-function dired-get-filename "dired" (&optional localp noerror))
+(declare-function dired-move-to-filename "dired" (&optional err eol))
+(declare-function dired-marker-regexp "dired" ())
+
 (unless (assoc 'vc-parent-buffer minor-mode-alist)
   (setq minor-mode-alist
        (cons '(vc-parent-buffer vc-parent-buffer-name)
@@ -1072,6 +1076,17 @@ For old-style locking-based version control systems, like RCS:
          ;; among all the `files'.
         (model (nth 4 vc-fileset)))
 
+    ;; If a buffer has unsaved changes, a checkout would discard those
+    ;; changes, so treat the buffer as having unlocked changes.
+    (when (and (not (eq model 'implicit)) (eq state 'up-to-date))
+      (let ((files files))
+       (while files
+         (let ((buffer (get-file-buffer (car files))))
+           (and buffer
+                (buffer-modified-p buffer)
+                (setq state 'unlocked-changes
+                      files nil))))))
+
     ;; Do the right thing
     (cond
      ((eq state 'missing)