Mercurial > emacs
comparison lisp/vc-dispatcher.el @ 94650:276c5ce56449
Move the fileset staleness check from vc-next-action to
vc-dispatcher-selection-set.
author | Eric S. Raymond <esr@snark.thyrsus.com> |
---|---|
date | Tue, 06 May 2008 00:37:31 +0000 |
parents | d0547efd97db |
children | 3a091c58b092 |
comparison
equal
deleted
inserted
replaced
94649:6a4a5b1ca5a1 | 94650:276c5ce56449 |
---|---|
1600 (funcall (vc-client-object->updater client-object))) | 1600 (funcall (vc-client-object->updater client-object))) |
1601 (run-hooks 'vc-dir-mode-hook)) | 1601 (run-hooks 'vc-dir-mode-hook)) |
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. | |
1607 NOT-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))) |
1608 | 1618 |
1609 (defun vc-dispatcher-selection-set (eligible | 1619 (defun vc-dispatcher-selection-set (eligible |
1621 visited file is not registered, return a singleton fileset containing it. | 1631 visited file is not registered, return a singleton fileset containing it. |
1622 If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked, | 1632 If INCLUDE-FILES-NOT-DIRECTORIES then if directories are marked, |
1623 return the list of VC files in those directories instead of | 1633 return the list of VC files in those directories instead of |
1624 the directories themselves. | 1634 the directories themselves. |
1625 Otherwise, throw an error." | 1635 Otherwise, 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 |
1629 (let ((marked (dired-map-over-marks (dired-get-filename) nil))) | 1640 (let ((marked (dired-map-over-marks (dired-get-filename) nil))) |
1630 (if marked | 1641 (if marked |
1666 (list default-directory))) | 1677 (list default-directory))) |
1667 ;; Last, if we're allowing ineligible files and visiting one, select it. | 1678 ;; Last, if we're allowing ineligible files and visiting one, select it. |
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 |