aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorEric S. Raymond2008-05-06 00:37:31 +0000
committerEric S. Raymond2008-05-06 00:37:31 +0000
commitbe636037294fc681546f3b94d3b2e3e59bf0eedb (patch)
treee55a6d2504476bd92dfec43c1d67e32245936a7e /lisp
parentf44407aa4bab98e037cd1728cafb5575a1bc0482 (diff)
downloademacs-be636037294fc681546f3b94d3b2e3e59bf0eedb.tar.gz
emacs-be636037294fc681546f3b94d3b2e3e59bf0eedb.zip
Move the fileset staleness check from vc-next-action to
vc-dispatcher-selection-set.
Diffstat (limited to 'lisp')
-rw-r--r--lisp/vc-dispatcher.el39
-rw-r--r--lisp/vc.el47
2 files changed, 39 insertions, 47 deletions
diff --git a/lisp/vc-dispatcher.el b/lisp/vc-dispatcher.el
index 6dd459ddf74..b680421ac07 100644
--- a/lisp/vc-dispatcher.el
+++ b/lisp/vc-dispatcher.el
@@ -1602,6 +1602,16 @@ U - if the cursor is on a file: unmark all the files with the same VC state
1602 1602
1603(put 'vc-dir-mode 'mode-class 'special) 1603(put 'vc-dir-mode 'mode-class 'special)
1604 1604
1605(defun vc-buffer-sync (&optional not-urgent)
1606 "Make sure the current buffer and its working file are in sync.
1607NOT-URGENT means it is ok to continue if the user says not to save."
1608 (when (buffer-modified-p)
1609 (if (or vc-suppress-confirm
1610 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
1611 (save-buffer)
1612 (unless not-urgent
1613 (error "Aborted")))))
1614
1605(defun vc-dispatcher-browsing () 1615(defun vc-dispatcher-browsing ()
1606 "Are we in a directory browser buffer?" 1616 "Are we in a directory browser buffer?"
1607 (or vc-dired-mode (eq major-mode 'vc-dir-mode))) 1617 (or vc-dired-mode (eq major-mode 'vc-dir-mode)))
@@ -1623,6 +1633,7 @@ If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked,
1623return the list of VC files in those directories instead of 1633return the list of VC files in those directories instead of
1624the directories themselves. 1634the directories themselves.
1625Otherwise, throw an error." 1635Otherwise, throw an error."
1636 (let ((files
1626 (cond 1637 (cond
1627 ;; Browsing with dired 1638 ;; Browsing with dired
1628 (vc-dired-mode 1639 (vc-dired-mode
@@ -1668,7 +1679,33 @@ Otherwise, throw an error."
1668 ((and allow-ineligible (not (eligible buffer-file-name))) 1679 ((and allow-ineligible (not (eligible buffer-file-name)))
1669 (list buffer-file-name)) 1680 (list buffer-file-name))
1670 ;; No good set here, throw error 1681 ;; No good set here, throw error
1671 (t (error "No fileset is available here.")))) 1682 (t (error "No fileset is available here.")))))
1683 ;; We assume, in order to avoid unpleasant surprises to the user,
1684 ;; that a fileset is not in good shape to be handed to the user if the
1685 ;; buffers visting the fileset don't match the on-disk contents.
1686 (dolist (file files)
1687 (let ((visited (get-file-buffer file)))
1688 (when visited
1689 (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
1690 (switch-to-buffer-other-window visited)
1691 (set-buffer visited))
1692 ;; Check relation of buffer and file, and make sure
1693 ;; user knows what he's doing. First, finding the file
1694 ;; will check whether the file on disk is newer.
1695 ;; Ignore buffer-read-only during this test, and
1696 ;; preserve find-file-literally.
1697 (let ((buffer-read-only (not (file-writable-p file))))
1698 (find-file-noselect file nil find-file-literally))
1699 (if (not (verify-visited-file-modtime (current-buffer)))
1700 (if (yes-or-no-p (format "Replace %s on disk with buffer contents? " file))
1701 (write-file buffer-file-name)
1702 (error "Aborted"))
1703 ;; Now, check if we have unsaved changes.
1704 (vc-buffer-sync t)
1705 (when (buffer-modified-p)
1706 (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
1707 (error "Aborted")))))))
1708 files))
1672 1709
1673;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246 1710;; arch-tag: 7d08b17f-5470-4799-914b-bfb9fcf6a246
1674;;; vc-dispatcher.el ends here 1711;;; vc-dispatcher.el ends here
diff --git a/lisp/vc.el b/lisp/vc.el
index 830951538ea..30d8b18046c 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -1046,19 +1046,7 @@ Only files already under version control are noticed."
1046(defun vc-deduce-fileset (&optional allow-directory-wildcard allow-unregistered 1046(defun vc-deduce-fileset (&optional allow-directory-wildcard allow-unregistered
1047 include-files-not-directories) 1047 include-files-not-directories)
1048 "Deduce a set of files and a backend to which to apply an operation. 1048 "Deduce a set of files and a backend to which to apply an operation.
1049 1049Return (BACKEND . FILESET)."
1050Return (BACKEND . FILESET).
1051If we're in VC-dired mode, the fileset is the list of marked files.
1052Otherwise, if we're looking at a buffer visiting a version-controlled file,
1053the fileset is a singleton containing this file.
1054If neither of these things is true, but ALLOW-DIRECTORY-WILDCARD is on
1055and we're in a dired buffer, select the current directory.
1056If none of these conditions is met, but ALLOW_UNREGISTERED is on and the
1057visited file is not registered, return a singleton fileset containing it.
1058If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked,
1059return the list of files VC files in those directories instead of
1060the directories themselves.
1061Otherwise, throw an error."
1062 (let* ((fileset (vc-dispatcher-selection-set 1050 (let* ((fileset (vc-dispatcher-selection-set
1063 #'vc-registered 1051 #'vc-registered
1064 allow-directory-wildcard 1052 allow-directory-wildcard
@@ -1101,16 +1089,6 @@ Otherwise, throw an error."
1101 (or (eq (vc-checkout-model backend (list file)) 'implicit) 1089 (or (eq (vc-checkout-model backend (list file)) 'implicit)
1102 (memq (vc-state file) '(edited needs-merge conflict)))))) 1090 (memq (vc-state file) '(edited needs-merge conflict))))))
1103 1091
1104(defun vc-buffer-sync (&optional not-urgent)
1105 "Make sure the current buffer and its working file are in sync.
1106NOT-URGENT means it is ok to continue if the user says not to save."
1107 (when (buffer-modified-p)
1108 (if (or vc-suppress-confirm
1109 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
1110 (save-buffer)
1111 (unless not-urgent
1112 (error "Aborted")))))
1113
1114(defun vc-compatible-state (p q) 1092(defun vc-compatible-state (p q)
1115 "Controls which states can be in the same commit." 1093 "Controls which states can be in the same commit."
1116 (or 1094 (or
@@ -1169,29 +1147,6 @@ merge in the changes into your working copy."
1169 file (vc-state file) (car files) state)) 1147 file (vc-state file) (car files) state))
1170 (unless (eq (vc-checkout-model backend (list file)) model) 1148 (unless (eq (vc-checkout-model backend (list file)) model)
1171 (error "Fileset has mixed checkout models")))) 1149 (error "Fileset has mixed checkout models"))))
1172 ;; Check for buffers in the fileset not matching the on-disk contents.
1173 (dolist (file files)
1174 (let ((visited (get-file-buffer file)))
1175 (when visited
1176 (if (or vc-dired-mode (eq major-mode 'vc-dir-mode))
1177 (switch-to-buffer-other-window visited)
1178 (set-buffer visited))
1179 ;; Check relation of buffer and file, and make sure
1180 ;; user knows what he's doing. First, finding the file
1181 ;; will check whether the file on disk is newer.
1182 ;; Ignore buffer-read-only during this test, and
1183 ;; preserve find-file-literally.
1184 (let ((buffer-read-only (not (file-writable-p file))))
1185 (find-file-noselect file nil find-file-literally))
1186 (if (not (verify-visited-file-modtime (current-buffer)))
1187 (if (yes-or-no-p (format "Replace %s on disk with buffer contents? " file))
1188 (write-file buffer-file-name)
1189 (error "Aborted"))
1190 ;; Now, check if we have unsaved changes.
1191 (vc-buffer-sync t)
1192 (when (buffer-modified-p)
1193 (or (y-or-n-p (message "Use %s on disk, keeping modified buffer? " file))
1194 (error "Aborted")))))))
1195 ;; Do the right thing 1150 ;; Do the right thing
1196 (cond 1151 (cond
1197 ((eq state 'missing) 1152 ((eq state 'missing)