]> code.delx.au - gnu-emacs/blobdiff - lisp/vc/vc-dispatcher.el
Merge branch 'emacs-25-merge'
[gnu-emacs] / lisp / vc / vc-dispatcher.el
index 4f8ec2788964869d1ef7ba33c9ccba88f40ac010..b8593e30a5471c915dee2d00fe0ed4239107f014 100644 (file)
@@ -171,6 +171,12 @@ Another is that undo information is not kept."
   (let ((camefrom (current-buffer))
        (olddir default-directory))
     (set-buffer (get-buffer-create buf))
+    (let ((oldproc (get-buffer-process (current-buffer))))
+      ;; If we wanted to wait for oldproc to finish before doing
+      ;; something, we'd have used vc-eval-after.
+      ;; Use `delete-process' rather than `kill-process' because we don't
+      ;; want any of its output to appear from now on.
+      (when oldproc (delete-process oldproc)))
     (kill-all-local-variables)
     (set (make-local-variable 'vc-parent-buffer) camefrom)
     (set (make-local-variable 'vc-parent-buffer-name)
@@ -302,12 +308,6 @@ case, and the process object in the asynchronous case."
                  (eq buffer (current-buffer)))
        (vc-setup-buffer buffer))
       ;; If there's some previous async process still running, just kill it.
-      (let ((oldproc (get-buffer-process (current-buffer))))
-        ;; If we wanted to wait for oldproc to finish before doing
-        ;; something, we'd have used vc-eval-after.
-        ;; Use `delete-process' rather than `kill-process' because we don't
-        ;; want any of its output to appear from now on.
-        (when oldproc (delete-process oldproc)))
       (let ((squeezed (remq nil flags))
            (inhibit-read-only t)
            (status 0))
@@ -580,12 +580,20 @@ editing!"
 (defun vc-buffer-sync (&optional not-urgent)
   "Make sure the current buffer and its working file are in sync.
 NOT-URGENT means it is ok to continue if the user says not to save."
-  (when (buffer-modified-p)
-    (if (or vc-suppress-confirm
-           (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
-       (save-buffer)
-      (unless not-urgent
-       (error "Aborted")))))
+  (let (missing)
+    (when (cond
+           ((buffer-modified-p))
+           ((not (file-exists-p buffer-file-name))
+            (setq missing t)))
+      (if (or vc-suppress-confirm
+              (y-or-n-p (format "Buffer %s %s; save it? "
+                                (buffer-name)
+                                (if missing
+                                    "is missing on disk"
+                                  "modified"))))
+          (save-buffer)
+        (unless not-urgent
+          (error "Aborted"))))))
 
 ;; Command closures
 
@@ -604,11 +612,24 @@ NOT-URGENT means it is ok to continue if the user says not to save."
            (or (log-edit-empty-buffer-p)
                (and (local-variable-p 'vc-log-fileset)
                     (not (equal vc-log-fileset fileset))))
-           `((log-edit-listfun . (lambda ()
-                                    ;; FIXME: Should expand the list
-                                    ;; for directories.
-                                    (mapcar 'file-relative-name
-                                            ',fileset)))
+           `((log-edit-listfun
+               . (lambda ()
+                   ;; FIXME: When fileset includes directories, and
+                   ;; there are relevant ChangeLog files inside their
+                   ;; children, we don't find them.  Either handle it
+                   ;; in `log-edit-insert-changelog-entries' by
+                   ;; walking down the file trees, or somehow pass
+                   ;; `fileset-only-files' from `vc-next-action'
+                   ;; through to this function.
+                   (let ((root (vc-root-dir)))
+                     ;; Returns paths relative to the root, so that
+                     ;; `log-edit-changelog-insert-entries'
+                     ;; substitutes them in correctly later, even when
+                     ;; `vc-checkin' was called from a file buffer, or
+                     ;; a non-root VC-Dir buffer.
+                     (mapcar
+                      (lambda (file) (file-relative-name file root))
+                      ',fileset))))
              (log-edit-diff-function . vc-diff)
              (log-edit-vc-backend . ,backend)
              (vc-log-fileset . ,fileset))