aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndré Spiegel1998-04-05 18:43:15 +0000
committerAndré Spiegel1998-04-05 18:43:15 +0000
commitb690900731835efdb7ca755ca6cbea7b5751492c (patch)
treea928d90b43b4acce1689d2c52a60ade8c4a3b7dd
parent666b94132b9d785b4ec6f0ecbfa451168134d150 (diff)
downloademacs-b690900731835efdb7ca755ca6cbea7b5751492c.tar.gz
emacs-b690900731835efdb7ca755ca6cbea7b5751492c.zip
(vc-ensure-vc-buffer): New function.
(vc-registration-error): Replaced by the above. Updated all callers. (file-executable-p-18, file-regular-p-18): Removed.
-rw-r--r--lisp/vc.el197
1 files changed, 75 insertions, 122 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index b14791931a2..503e4f6e290 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -5,7 +5,7 @@
5;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 5;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
6;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de> 6;; Maintainer: Andre Spiegel <spiegel@inf.fu-berlin.de>
7 7
8;; $Id: vc.el,v 1.215 1998/04/01 12:26:43 spiegel Exp rms $ 8;; $Id: vc.el,v 1.216 1998/04/04 05:22:37 rms Exp spiegel $
9 9
10;; This file is part of GNU Emacs. 10;; This file is part of GNU Emacs.
11 11
@@ -318,27 +318,6 @@ If nil, VC itself computes this value when it is first needed."
318(defvar vc-comment-ring-index nil) 318(defvar vc-comment-ring-index nil)
319(defvar vc-last-comment-match nil) 319(defvar vc-last-comment-match nil)
320 320
321;; Back-portability to Emacs 18
322
323(defun file-executable-p-18 (f)
324 (let ((modes (file-modes f)))
325 (and modes (not (zerop (logand 292))))))
326
327(defun file-regular-p-18 (f)
328 (let ((attributes (file-attributes f)))
329 (and attributes (not (car attributes)))))
330
331; Conditionally rebind some things for Emacs 18 compatibility
332(if (not (boundp 'minor-mode-map-alist))
333 (progn
334 (setq compilation-old-error-list nil)
335 (fset 'file-executable-p 'file-executable-p-18)
336 (fset 'shrink-window-if-larger-than-buffer 'beginning-of-buffer)
337 ))
338
339(if (not (fboundp 'file-regular-p))
340 (fset 'file-regular-p 'file-regular-p-18))
341
342;;; Find and compare backend releases 321;;; Find and compare backend releases
343 322
344(defun vc-backend-release (backend) 323(defun vc-backend-release (backend)
@@ -498,10 +477,16 @@ If nil, VC itself computes this value when it is first needed."
498 ;; CVS 477 ;; CVS
499 t)) 478 t))
500 479
501(defun vc-registration-error (file) 480(defun vc-ensure-vc-buffer ()
502 (if file 481 ;; Make sure that the current buffer visits a version-controlled file.
503 (error "File %s is not under version control" file) 482 (if vc-dired-mode
504 (error "Buffer %s is not associated with a file" (buffer-name)))) 483 (set-buffer (find-file-noselect (dired-get-filename)))
484 (while vc-parent-buffer
485 (pop-to-buffer vc-parent-buffer))
486 (if (not (buffer-file-name))
487 (error "Buffer %s is not associated with a file" (buffer-name))
488 (if (not (vc-backend (buffer-file-name)))
489 (error "File %s is not under version control" (buffer-file-name))))))
505 490
506(defvar vc-binary-assoc nil) 491(defvar vc-binary-assoc nil)
507 492
@@ -971,11 +956,8 @@ merge in the changes into your working copy."
971 "Enter a change comment for the marked files." 956 "Enter a change comment for the marked files."
972 'vc-next-action-dired)) 957 'vc-next-action-dired))
973 (throw 'nogo nil))) 958 (throw 'nogo nil)))
974 (while vc-parent-buffer 959 (vc-ensure-vc-buffer)
975 (pop-to-buffer vc-parent-buffer)) 960 (vc-next-action-on-file buffer-file-name verbose)))
976 (if buffer-file-name
977 (vc-next-action-on-file buffer-file-name verbose)
978 (vc-registration-error nil))))
979 961
980;;; These functions help the vc-next-action entry point 962;;; These functions help the vc-next-action entry point
981 963
@@ -1314,15 +1296,9 @@ checked in version of that file. This uses no arguments.
1314With a prefix argument, it reads the file name to use 1296With a prefix argument, it reads the file name to use
1315and two version designators specifying which versions to compare." 1297and two version designators specifying which versions to compare."
1316 (interactive (list current-prefix-arg t)) 1298 (interactive (list current-prefix-arg t))
1317 (if vc-dired-mode 1299 (vc-ensure-vc-buffer)
1318 (set-buffer (find-file-noselect (dired-get-filename))))
1319 (while vc-parent-buffer
1320 (pop-to-buffer vc-parent-buffer))
1321 (if historic 1300 (if historic
1322 (call-interactively 'vc-version-diff) 1301 (call-interactively 'vc-version-diff)
1323 (if (or (null buffer-file-name) (null (vc-name buffer-file-name)))
1324 (error
1325 "There is no version-control master associated with this buffer"))
1326 (let ((file buffer-file-name) 1302 (let ((file buffer-file-name)
1327 unchanged) 1303 unchanged)
1328 (vc-buffer-sync not-urgent) 1304 (vc-buffer-sync not-urgent)
@@ -1423,19 +1399,14 @@ files in or below it."
1423If the current buffer is named `F', the version is named `F.~REV~'. 1399If the current buffer is named `F', the version is named `F.~REV~'.
1424If `F.~REV~' already exists, it is used instead of being re-created." 1400If `F.~REV~' already exists, it is used instead of being re-created."
1425 (interactive "sVersion to visit (default is latest version): ") 1401 (interactive "sVersion to visit (default is latest version): ")
1426 (if vc-dired-mode 1402 (vc-ensure-vc-buffer)
1427 (set-buffer (find-file-noselect (dired-get-filename)))) 1403 (let* ((version (if (string-equal rev "")
1428 (while vc-parent-buffer 1404 (vc-latest-version buffer-file-name)
1429 (pop-to-buffer vc-parent-buffer)) 1405 rev))
1430 (if (and buffer-file-name (vc-name buffer-file-name)) 1406 (filename (concat buffer-file-name ".~" version "~")))
1431 (let* ((version (if (string-equal rev "") 1407 (or (file-exists-p filename)
1432 (vc-latest-version buffer-file-name) 1408 (vc-backend-checkout buffer-file-name nil version filename))
1433 rev)) 1409 (find-file-other-window filename)))
1434 (filename (concat buffer-file-name ".~" version "~")))
1435 (or (file-exists-p filename)
1436 (vc-backend-checkout buffer-file-name nil version filename))
1437 (find-file-other-window filename))
1438 (vc-registration-error buffer-file-name)))
1439 1410
1440;; Header-insertion code 1411;; Header-insertion code
1441 1412
@@ -1445,10 +1416,7 @@ If `F.~REV~' already exists, it is used instead of being re-created."
1445Headers desired are inserted at the start of the buffer, and are pulled from 1416Headers desired are inserted at the start of the buffer, and are pulled from
1446the variable `vc-header-alist'." 1417the variable `vc-header-alist'."
1447 (interactive) 1418 (interactive)
1448 (if vc-dired-mode 1419 (vc-ensure-vc-buffer)
1449 (find-file-other-window (dired-get-filename)))
1450 (while vc-parent-buffer
1451 (pop-to-buffer vc-parent-buffer))
1452 (save-excursion 1420 (save-excursion
1453 (save-restriction 1421 (save-restriction
1454 (widen) 1422 (widen)
@@ -1488,10 +1456,12 @@ the variable `vc-header-alist'."
1488 (replace-match "$\\1$"))) 1456 (replace-match "$\\1$")))
1489 (vc-restore-buffer-context context))) 1457 (vc-restore-buffer-context context)))
1490 1458
1459;;;###autoload
1491(defun vc-resolve-conflicts () 1460(defun vc-resolve-conflicts ()
1492 "Invoke ediff to resolve conflicts in the current buffer. 1461 "Invoke ediff to resolve conflicts in the current buffer.
1493The conflicts must be marked with rcsmerge conflict markers." 1462The conflicts must be marked with rcsmerge conflict markers."
1494 (interactive) 1463 (interactive)
1464 (vc-ensure-vc-buffer)
1495 (let* ((found nil) 1465 (let* ((found nil)
1496 (file-name (file-name-nondirectory buffer-file-name)) 1466 (file-name (file-name-nondirectory buffer-file-name))
1497 (your-buffer (generate-new-buffer 1467 (your-buffer (generate-new-buffer
@@ -1832,58 +1802,50 @@ locked are updated to the latest versions."
1832(defun vc-print-log () 1802(defun vc-print-log ()
1833 "List the change log of the current buffer in a window." 1803 "List the change log of the current buffer in a window."
1834 (interactive) 1804 (interactive)
1835 (if vc-dired-mode 1805 (vc-ensure-vc-buffer)
1836 (set-buffer (find-file-noselect (dired-get-filename)))) 1806 (let ((file buffer-file-name))
1837 (while vc-parent-buffer 1807 (vc-backend-print-log file)
1838 (pop-to-buffer vc-parent-buffer)) 1808 (pop-to-buffer (get-buffer-create "*vc*"))
1839 (if (and buffer-file-name (vc-name buffer-file-name)) 1809 (setq default-directory (file-name-directory file))
1840 (let ((file buffer-file-name)) 1810 (goto-char (point-max)) (forward-line -1)
1841 (vc-backend-print-log file) 1811 (while (looking-at "=*\n")
1842 (pop-to-buffer (get-buffer-create "*vc*")) 1812 (delete-char (- (match-end 0) (match-beginning 0)))
1843 (setq default-directory (file-name-directory file)) 1813 (forward-line -1))
1844 (goto-char (point-max)) (forward-line -1) 1814 (goto-char (point-min))
1845 (while (looking-at "=*\n") 1815 (if (looking-at "[\b\t\n\v\f\r ]+")
1846 (delete-char (- (match-end 0) (match-beginning 0))) 1816 (delete-char (- (match-end 0) (match-beginning 0))))
1847 (forward-line -1)) 1817 (shrink-window-if-larger-than-buffer)
1848 (goto-char (point-min)) 1818 ;; move point to the log entry for the current version
1849 (if (looking-at "[\b\t\n\v\f\r ]+") 1819 (and (not (eq (vc-backend file) 'SCCS))
1850 (delete-char (- (match-end 0) (match-beginning 0)))) 1820 (re-search-forward
1851 (shrink-window-if-larger-than-buffer) 1821 ;; also match some context, for safety
1852 ;; move point to the log entry for the current version 1822 (concat "----\nrevision " (vc-workfile-version file)
1853 (and (not (eq (vc-backend file) 'SCCS)) 1823 "\\(\tlocked by:.*\n\\|\n\\)date: ") nil t)
1854 (re-search-forward 1824 ;; set the display window so that
1855 ;; also match some context, for safety 1825 ;; the whole log entry is displayed
1856 (concat "----\nrevision " (vc-workfile-version file) 1826 (let (start end lines)
1857 "\\(\tlocked by:.*\n\\|\n\\)date: ") nil t) 1827 (beginning-of-line) (forward-line -1) (setq start (point))
1858 ;; set the display window so that 1828 (if (not (re-search-forward "^----*\nrevision" nil t))
1859 ;; the whole log entry is displayed 1829 (setq end (point-max))
1860 (let (start end lines) 1830 (beginning-of-line) (forward-line -1) (setq end (point)))
1861 (beginning-of-line) (forward-line -1) (setq start (point)) 1831 (setq lines (count-lines start end))
1862 (if (not (re-search-forward "^----*\nrevision" nil t)) 1832 (cond
1863 (setq end (point-max)) 1833 ;; if the global information and this log entry fit
1864 (beginning-of-line) (forward-line -1) (setq end (point))) 1834 ;; into the window, display from the beginning
1865 (setq lines (count-lines start end)) 1835 ((< (count-lines (point-min) end) (window-height))
1866 (cond 1836 (goto-char (point-min))
1867 ;; if the global information and this log entry fit 1837 (recenter 0)
1868 ;; into the window, display from the beginning 1838 (goto-char start))
1869 ((< (count-lines (point-min) end) (window-height)) 1839 ;; if the whole entry fits into the window,
1870 (goto-char (point-min)) 1840 ;; display it centered
1871 (recenter 0) 1841 ((< (1+ lines) (window-height))
1872 (goto-char start)) 1842 (goto-char start)
1873 ;; if the whole entry fits into the window, 1843 (recenter (1- (- (/ (window-height) 2) (/ lines 2)))))
1874 ;; display it centered 1844 ;; otherwise (the entry is too large for the window),
1875 ((< (1+ lines) (window-height)) 1845 ;; display from the start
1876 (goto-char start) 1846 (t
1877 (recenter (1- (- (/ (window-height) 2) (/ lines 2))))) 1847 (goto-char start)
1878 ;; otherwise (the entry is too large for the window), 1848 (recenter 0)))))))
1879 ;; display from the start
1880 (t
1881 (goto-char start)
1882 (recenter 0)))))
1883 )
1884 (vc-registration-error buffer-file-name)
1885 )
1886 )
1887 1849
1888;;;###autoload 1850;;;###autoload
1889(defun vc-revert-buffer () 1851(defun vc-revert-buffer ()
@@ -1893,10 +1855,7 @@ to that version. Note that for RCS and CVS, this function does not
1893automatically pick up newer changes found in the master file; 1855automatically pick up newer changes found in the master file;
1894use C-u \\[vc-next-action] RET to do so." 1856use C-u \\[vc-next-action] RET to do so."
1895 (interactive) 1857 (interactive)
1896 (if vc-dired-mode 1858 (vc-ensure-vc-buffer)
1897 (find-file-other-window (dired-get-filename)))
1898 (while vc-parent-buffer
1899 (pop-to-buffer vc-parent-buffer))
1900 (let ((file buffer-file-name) 1859 (let ((file buffer-file-name)
1901 ;; This operation should always ask for confirmation. 1860 ;; This operation should always ask for confirmation.
1902 (vc-suppress-confirm nil) 1861 (vc-suppress-confirm nil)
@@ -1918,13 +1877,8 @@ use C-u \\[vc-next-action] RET to do so."
1918 "Get rid of most recently checked in version of this file. 1877 "Get rid of most recently checked in version of this file.
1919A prefix argument means do not revert the buffer afterwards." 1878A prefix argument means do not revert the buffer afterwards."
1920 (interactive "P") 1879 (interactive "P")
1921 (if vc-dired-mode 1880 (vc-ensure-vc-buffer)
1922 (find-file-other-window (dired-get-filename)))
1923 (while vc-parent-buffer
1924 (pop-to-buffer vc-parent-buffer))
1925 (cond 1881 (cond
1926 ((not (vc-registered (buffer-file-name)))
1927 (vc-registration-error (buffer-file-name)))
1928 ((eq (vc-backend (buffer-file-name)) 'CVS) 1882 ((eq (vc-backend (buffer-file-name)) 'CVS)
1929 (error "Unchecking files under CVS is dangerous and not supported in VC")) 1883 (error "Unchecking files under CVS is dangerous and not supported in VC"))
1930 ((vc-locking-user (buffer-file-name)) 1884 ((vc-locking-user (buffer-file-name))
@@ -2228,8 +2182,9 @@ mode-specific menu. `vc-annotate-color-map' and
2228`vc-annotate-very-old-color' defines the mapping of time to 2182`vc-annotate-very-old-color' defines the mapping of time to
2229colors. `vc-annotate-background' specifies the background color." 2183colors. `vc-annotate-background' specifies the background color."
2230 (interactive "p") 2184 (interactive "p")
2231 (if (not (eq (vc-buffer-backend) 'CVS)) ; This only works with CVS 2185 (vc-ensure-vc-buffer)
2232 (vc-registration-error (buffer-file-name))) 2186 (if (not (eq (vc-backend (buffer-file-name)) 'CVS))
2187 (error "Sorry, vc-annotate is only implemented for CVS"))
2233 (message "Annotating...") 2188 (message "Annotating...")
2234 (let ((temp-buffer-name (concat "*cvs annotate " (buffer-name) "*")) 2189 (let ((temp-buffer-name (concat "*cvs annotate " (buffer-name) "*"))
2235 (temp-buffer-show-function 'vc-annotate-display) 2190 (temp-buffer-show-function 'vc-annotate-display)
@@ -2794,9 +2749,7 @@ THRESHOLD, nil otherwise"
2794 (and newvers (concat "-r" newvers)) 2749 (and newvers (concat "-r" newvers))
2795 (if (listp diff-switches) 2750 (if (listp diff-switches)
2796 diff-switches 2751 diff-switches
2797 (list diff-switches))))) 2752 (list diff-switches))))))))
2798 (t
2799 (vc-registration-error file)))))
2800 2753
2801(defun vc-backend-merge-news (file) 2754(defun vc-backend-merge-news (file)
2802 ;; Merge in any new changes made to FILE. 2755 ;; Merge in any new changes made to FILE.