aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChong Yidong2013-01-06 10:58:57 +0800
committerChong Yidong2013-01-06 10:58:57 +0800
commit58ba7b1b558e4803100905bd5fff0004e4ddd261 (patch)
tree4178391df8457041a8c8a89ea8c20a9a45005799
parent56ed110a17fc377f1d0a39eb3f01e4fd03a65709 (diff)
downloademacs-58ba7b1b558e4803100905bd5fff0004e4ddd261.tar.gz
emacs-58ba7b1b558e4803100905bd5fff0004e4ddd261.zip
Try to handle buffer/file modifications which conflict with VCS locking.
* vc/vc-hooks.el (vc-after-save): DTRT for locking VCSes. * vc/vc.el (vc-next-action): Detect buffer modifications conflicting with locking VCS operation. Fixes: debbugs:11490
-rw-r--r--lisp/ChangeLog7
-rw-r--r--lisp/vc/vc-hooks.el28
-rw-r--r--lisp/vc/vc.el15
3 files changed, 37 insertions, 13 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index f2c6b569126..fe3c252c306 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,10 @@
12013-01-06 Chong Yidong <cyd@gnu.org>
2
3 * vc/vc.el (vc-next-action): Detect buffer modifications
4 conflicting with locking VCS operation (Bug#11490).
5
6 * vc/vc-hooks.el (vc-after-save): DTRT for locking VCSes.
7
12013-01-05 Michael Albinus <michael.albinus@gmx.de> 82013-01-05 Michael Albinus <michael.albinus@gmx.de>
2 9
3 * net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls): 10 * net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls):
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 5a2b47bb34f..99436303fa2 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -703,19 +703,21 @@ Before doing that, check if there are any old backups and get rid of them."
703 ;; the state to 'edited and redisplay the mode line. 703 ;; the state to 'edited and redisplay the mode line.
704 (let* ((file buffer-file-name) 704 (let* ((file buffer-file-name)
705 (backend (vc-backend file))) 705 (backend (vc-backend file)))
706 (and backend 706 (cond
707 (or (and (equal (vc-file-getprop file 'vc-checkout-time) 707 ((null backend))
708 (nth 5 (file-attributes file))) 708 ((eq (vc-checkout-model backend (list file)) 'implicit)
709 ;; File has been saved in the same second in which 709 ;; If the file was saved in the same second in which it was
710 ;; it was checked out. Clear the checkout-time 710 ;; checked out, clear the checkout-time to avoid confusion.
711 ;; to avoid confusion. 711 (if (equal (vc-file-getprop file 'vc-checkout-time)
712 (vc-file-setprop file 'vc-checkout-time nil)) 712 (nth 5 (file-attributes file)))
713 t) 713 (vc-file-setprop file 'vc-checkout-time nil))
714 (eq (vc-checkout-model backend (list file)) 'implicit) 714 (if (vc-state-refresh file backend)
715 (vc-state-refresh file backend) 715 (vc-mode-line file backend)))
716 (vc-mode-line file backend)) 716 ;; If we saved an unlocked file on a locking based VCS, that
717 ;; Try to avoid unnecessary work, a *vc-dir* buffer is 717 ;; file is not longer up-to-date.
718 ;; present if this is true. 718 ((eq (vc-file-getprop file 'vc-state) 'up-to-date)
719 (vc-file-setprop file 'vc-state nil)))
720 ;; Resynch *vc-dir* buffers, if any are present.
719 (when vc-dir-buffers 721 (when vc-dir-buffers
720 (vc-dir-resynch-file file)))) 722 (vc-dir-resynch-file file))))
721 723
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index fe259806267..9b8b94916c4 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -659,6 +659,10 @@
659(eval-when-compile 659(eval-when-compile
660 (require 'dired)) 660 (require 'dired))
661 661
662(declare-function dired-get-filename "dired" (&optional localp noerror))
663(declare-function dired-move-to-filename "dired" (&optional err eol))
664(declare-function dired-marker-regexp "dired" ())
665
662(unless (assoc 'vc-parent-buffer minor-mode-alist) 666(unless (assoc 'vc-parent-buffer minor-mode-alist)
663 (setq minor-mode-alist 667 (setq minor-mode-alist
664 (cons '(vc-parent-buffer vc-parent-buffer-name) 668 (cons '(vc-parent-buffer vc-parent-buffer-name)
@@ -1072,6 +1076,17 @@ For old-style locking-based version control systems, like RCS:
1072 ;; among all the `files'. 1076 ;; among all the `files'.
1073 (model (nth 4 vc-fileset))) 1077 (model (nth 4 vc-fileset)))
1074 1078
1079 ;; If a buffer has unsaved changes, a checkout would discard those
1080 ;; changes, so treat the buffer as having unlocked changes.
1081 (when (and (not (eq model 'implicit)) (eq state 'up-to-date))
1082 (let ((files files))
1083 (while files
1084 (let ((buffer (get-file-buffer (car files))))
1085 (and buffer
1086 (buffer-modified-p buffer)
1087 (setq state 'unlocked-changes
1088 files nil))))))
1089
1075 ;; Do the right thing 1090 ;; Do the right thing
1076 (cond 1091 (cond
1077 ((eq state 'missing) 1092 ((eq state 'missing)