aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1995-01-05 22:11:35 +0000
committerRichard M. Stallman1995-01-05 22:11:35 +0000
commit165d7ff45e8a659d2eb6978bc68cc5e74808fdb2 (patch)
tree30c331cd0bc917a83bb89df02eb5c42e4773feed
parent0a840b84de410b50cb24aec333cf730d3e104ef0 (diff)
downloademacs-165d7ff45e8a659d2eb6978bc68cc5e74808fdb2.tar.gz
emacs-165d7ff45e8a659d2eb6978bc68cc5e74808fdb2.zip
(vc-do-command): Change RCS handling so rcsdiff won't strip
away relative-pathname information. This function no longer sets the default directory. Also, mark the *vc* output buffer unmodified. (vc-revert-buffer1): Handle font-lock mode correctly. (vc-diff, vc-print-log): vc-do-command no longer sets the default directory, but doing so is advantageous for these cases. (file-executable-p-18): Better portability to Emacs 18. (vc-directory-exclusion-list, vc-file-tree-walk-internal): Implement the new variable vc-directory-exclusion-list to prune tree walks. Initial value tells it to ignore SCCS and RCS subdirectories.
-rw-r--r--lisp/vc.el100
1 files changed, 64 insertions, 36 deletions
diff --git a/lisp/vc.el b/lisp/vc.el
index b80f632a413..70ce0d5c842 100644
--- a/lisp/vc.el
+++ b/lisp/vc.el
@@ -4,7 +4,7 @@
4 4
5;; Author: Eric S. Raymond <esr@snark.thyrsus.com> 5;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
6;; Maintainer: ttn@netcom.com 6;; Maintainer: ttn@netcom.com
7;; Version: 5.5 + CVS hacks by ceder@lysator.liu.se made in Jan-Feb 1994. 7;; Version: 5.6
8 8
9;; This file is part of GNU Emacs. 9;; This file is part of GNU Emacs.
10 10
@@ -29,10 +29,15 @@
29;; This was designed and implemented by Eric Raymond <esr@snark.thyrsus.com>. 29;; This was designed and implemented by Eric Raymond <esr@snark.thyrsus.com>.
30;; Paul Eggert <eggert@twinsun.com>, Sebastian Kremer <sk@thp.uni-koeln.de>, 30;; Paul Eggert <eggert@twinsun.com>, Sebastian Kremer <sk@thp.uni-koeln.de>,
31;; and Richard Stallman contributed valuable criticism, support, and testing. 31;; and Richard Stallman contributed valuable criticism, support, and testing.
32;; CVS support was added by Per Cederqvist <ceder@lysator.liu.se>
33;; in Jan-Feb 1994.
32;; 34;;
33;; Supported version-control systems presently include SCCS and RCS; 35;; Supported version-control systems presently include SCCS, RCS, and CVS.
34;; the RCS lock-stealing code doesn't work right unless you use RCS 5.6.2 36;; The RCS lock-stealing code doesn't work right unless you use RCS 5.6.2
35;; or newer. Currently (January 1994) that is only a beta test release. 37;; or newer. Currently (January 1994) that is only a beta test release.
38;; Even initial checkins will fail if your RCS version is so old that ci
39;; doesn't understand -t-; this has been known to happen to people running
40;; NExTSTEP 3.0.
36;; 41;;
37;; The RCS code assumes strict locking. You can support the RCS -x option 42;; The RCS code assumes strict locking. You can support the RCS -x option
38;; by adding pairs to the vc-master-templates list. 43;; by adding pairs to the vc-master-templates list.
@@ -93,6 +98,8 @@ value of this flag.")
93 (if (file-exists-p "/usr/sccs") 98 (if (file-exists-p "/usr/sccs")
94 '("/usr/sccs") nil) 99 '("/usr/sccs") nil)
95 "*List of extra directories to search for version control commands.") 100 "*List of extra directories to search for version control commands.")
101(defvar vc-directory-exclusion-list '("SCCS" "RCS")
102 "*Directory names ignored by functions that recursively walk file trees.")
96 103
97(defconst vc-maximum-comment-ring-size 32 104(defconst vc-maximum-comment-ring-size 32
98 "Maximum number of saved comments in the comment ring.") 105 "Maximum number of saved comments in the comment ring.")
@@ -159,6 +166,20 @@ and that its contents match what the master file says.")
159(defvar vc-comment-ring-index nil) 166(defvar vc-comment-ring-index nil)
160(defvar vc-last-comment-match nil) 167(defvar vc-last-comment-match nil)
161 168
169;; Back-portability to Emacs 18
170
171(defun file-executable-p-18 (f)
172 (let ((modes (file-modes f)))
173 (and modes (not (zerop (logand 292))))))
174
175; Conditionally rebind some things for Emacs 18 compatibility
176(if (not (boundp 'minor-mode-map-alist))
177 (progn
178 (setq compilation-old-error-list nil)
179 (fset 'file-executable-p 'file-executable-p-18)
180 (fset 'shrink-window-if-larger-than-buffer 'beginning-of-buffer)
181 ))
182
162;; File property caching 183;; File property caching
163 184
164(defun vc-file-clearprops (file) 185(defun vc-file-clearprops (file)
@@ -203,9 +224,13 @@ and that its contents match what the master file says.")
203 "Execute a version-control command, notifying user and checking for errors. 224 "Execute a version-control command, notifying user and checking for errors.
204The command is successful if its exit status does not exceed OKSTATUS. 225The command is successful if its exit status does not exceed OKSTATUS.
205Output from COMMAND goes to buffer *vc*. The last argument of the command is 226Output from COMMAND goes to buffer *vc*. The last argument of the command is
206the master name of FILE if LAST is 'MASTER, or the basename of FILE if LAST is 227the master name of FILE if LAST is 'MASTER, or the workfile of FILE if LAST is
207'BASE; this is appended to an optional list of FLAGS." 228'WORKFILE; this is appended to an optional list of FLAGS."
208 (setq file (expand-file-name file)) 229 (setq file (expand-file-name file))
230 (let* ((pwd (expand-file-name default-directory))
231 (preflen (length pwd)))
232 (if (string= (substring file 0 preflen) pwd)
233 (setq file (substring file preflen))))
209 (if vc-command-messages 234 (if vc-command-messages
210 (message "Running %s on %s..." command file)) 235 (message "Running %s on %s..." command file))
211 (let ((obuf (current-buffer)) (camefrom (current-buffer)) 236 (let ((obuf (current-buffer)) (camefrom (current-buffer))
@@ -219,19 +244,14 @@ the master name of FILE if LAST is 'MASTER, or the basename of FILE if LAST is
219 244
220 (erase-buffer) 245 (erase-buffer)
221 246
222 ;; This is so that command arguments typed in the *vc* buffer will
223 ;; have reasonable defaults.
224 (setq default-directory (file-name-directory file))
225
226 (mapcar 247 (mapcar
227 (function (lambda (s) (and s (setq squeezed (append squeezed (list s)))))) 248 (function (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
228 flags) 249 flags)
229 (if (and vc-file (eq last 'MASTER)) 250 (if (and vc-file (eq last 'MASTER))
230 (setq squeezed (append squeezed (list vc-file)))) 251 (setq squeezed (append squeezed (list vc-file))))
231 (if (eq last 'BASE) 252 (if (eq last 'WORKFILE)
232 (setq squeezed (append squeezed (list (file-name-nondirectory file))))) 253 (setq squeezed (append squeezed (list file))))
233 (let ((default-directory (file-name-directory (or file "./"))) 254 (let ((exec-path (if vc-path (append exec-path vc-path) exec-path))
234 (exec-path (if vc-path (append exec-path vc-path) exec-path))
235 ;; Add vc-path to PATH for the execution of this command. 255 ;; Add vc-path to PATH for the execution of this command.
236 (process-environment 256 (process-environment
237 (cons (concat "PATH=" (getenv "PATH") 257 (cons (concat "PATH=" (getenv "PATH")
@@ -239,6 +259,7 @@ the master name of FILE if LAST is 'MASTER, or the basename of FILE if LAST is
239 process-environment))) 259 process-environment)))
240 (setq status (apply 'call-process command nil t nil squeezed))) 260 (setq status (apply 'call-process command nil t nil squeezed)))
241 (goto-char (point-max)) 261 (goto-char (point-max))
262 (not-modified)
242 (forward-line -1) 263 (forward-line -1)
243 (if (or (not (integerp status)) (< okstatus status)) 264 (if (or (not (integerp status)) (< okstatus status))
244 (progn 265 (progn
@@ -324,8 +345,16 @@ the master name of FILE if LAST is 'MASTER, or the basename of FILE if LAST is
324 (if buffer-error-marked-p buffer)))) 345 (if buffer-error-marked-p buffer))))
325 (buffer-list))))))) 346 (buffer-list)))))))
326 347
327 ;; the actual revisit 348 (let ((in-font-lock-mode (and (boundp 'font-lock-fontified)
328 (revert-buffer arg no-confirm) 349 font-lock-fontified)))
350 (if in-font-lock-mode
351 (font-lock-mode 0))
352
353 ;; the actual revisit
354 (revert-buffer arg no-confirm)
355
356 (if in-font-lock-mode
357 (font-lock-mode 1)))
329 358
330 ;; Reparse affected compilation buffers. 359 ;; Reparse affected compilation buffers.
331 (while reparse 360 (while reparse
@@ -893,7 +922,7 @@ and two version designators specifying which versions to compare."
893 ;; visited. This plays hell with numerous assumptions in 922 ;; visited. This plays hell with numerous assumptions in
894 ;; the diff.el and compile.el machinery. 923 ;; the diff.el and compile.el machinery.
895 (pop-to-buffer "*vc*") 924 (pop-to-buffer "*vc*")
896 (pop-to-buffer "*vc*") 925 (setq default-directory (file-name-directory file))
897 (if (= 0 (buffer-size)) 926 (if (= 0 (buffer-size))
898 (progn 927 (progn
899 (setq unchanged t) 928 (setq unchanged t)
@@ -1103,10 +1132,6 @@ scan the entire tree of subdirectories of the current directory."
1103 (if verbose "registered" "locked") default-directory)) 1132 (if verbose "registered" "locked") default-directory))
1104 )) 1133 ))
1105 1134
1106; Emacs 18 also lacks these.
1107(or (boundp 'compilation-old-error-list)
1108 (setq compilation-old-error-list nil))
1109
1110;; Named-configuration support for SCCS 1135;; Named-configuration support for SCCS
1111 1136
1112(defun vc-add-triple (name file rev) 1137(defun vc-add-triple (name file rev)
@@ -1198,9 +1223,10 @@ levels in the snapshot."
1198 (while vc-parent-buffer 1223 (while vc-parent-buffer
1199 (pop-to-buffer vc-parent-buffer)) 1224 (pop-to-buffer vc-parent-buffer))
1200 (if (and buffer-file-name (vc-name buffer-file-name)) 1225 (if (and buffer-file-name (vc-name buffer-file-name))
1201 (progn 1226 (let ((file buffer-file-name))
1202 (vc-backend-print-log buffer-file-name) 1227 (vc-backend-print-log file)
1203 (pop-to-buffer (get-buffer-create "*vc*")) 1228 (pop-to-buffer (get-buffer-create "*vc*"))
1229 (setq default-directory (file-name-directory file))
1204 (while (looking-at "=*\n") 1230 (while (looking-at "=*\n")
1205 (delete-char (- (match-end 0) (match-beginning 0))) 1231 (delete-char (- (match-end 0) (match-beginning 0)))
1206 (forward-line -1)) 1232 (forward-line -1))
@@ -1424,7 +1450,7 @@ From a program, any arguments are passed to the `rcs2log' script."
1424 (setq buf (create-file-buffer file)) 1450 (setq buf (create-file-buffer file))
1425 (set-buffer buf)) 1451 (set-buffer buf))
1426 (erase-buffer) 1452 (erase-buffer)
1427 (insert-file-contents file nil) 1453 (insert-file-contents file)
1428 (set-buffer-modified-p nil) 1454 (set-buffer-modified-p nil)
1429 (auto-save-mode nil) 1455 (auto-save-mode nil)
1430 (prog1 1456 (prog1
@@ -1602,7 +1628,7 @@ with RCS)."
1602 ;; should always be nil anyhow. Don't fetch vc-your-latest-version, since 1628 ;; should always be nil anyhow. Don't fetch vc-your-latest-version, since
1603 ;; that is done in vc-find-cvs-master. 1629 ;; that is done in vc-find-cvs-master.
1604 (vc-log-info 1630 (vc-log-info
1605 "cvs" file 'BASE '("status") 1631 "cvs" file 'WORKFILE '("status")
1606 ;; CVS 1.3 says "RCS Version:", other releases "RCS Revision:", 1632 ;; CVS 1.3 says "RCS Version:", other releases "RCS Revision:",
1607 ;; and CVS 1.4a1 says "Repository revision:". The regexp below 1633 ;; and CVS 1.4a1 says "Repository revision:". The regexp below
1608 ;; matches much more, but because of the way vc-log-info is 1634 ;; matches much more, but because of the way vc-log-info is
@@ -1654,7 +1680,7 @@ with RCS)."
1654 (and comment (concat "-t-" comment)) 1680 (and comment (concat "-t-" comment))
1655 file)) 1681 file))
1656 ((eq backend 'CVS) 1682 ((eq backend 'CVS)
1657 (vc-do-command 0 "cvs" file 'BASE ;; CVS 1683 (vc-do-command 0 "cvs" file 'WORKFILE ;; CVS
1658 "add" 1684 "add"
1659 (and comment (not (string= comment "")) 1685 (and comment (not (string= comment ""))
1660 (concat "-m" comment))) 1686 (concat "-m" comment)))
@@ -1737,7 +1763,7 @@ with RCS)."
1737 (unwind-protect 1763 (unwind-protect
1738 (progn 1764 (progn
1739 (apply 'vc-do-command 1765 (apply 'vc-do-command
1740 0 "/bin/sh" file 'BASE "-c" 1766 0 "/bin/sh" file 'WORKFILE "-c"
1741 "exec >\"$1\" || exit; shift; exec cvs update \"$@\"" 1767 "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
1742 "" ; dummy argument for shell's $0 1768 "" ; dummy argument for shell's $0
1743 workfile 1769 workfile
@@ -1746,7 +1772,7 @@ with RCS)."
1746 vc-checkout-switches) 1772 vc-checkout-switches)
1747 (setq failed nil)) 1773 (setq failed nil))
1748 (and failed (file-exists-p filename) (delete-file filename)))) 1774 (and failed (file-exists-p filename) (delete-file filename))))
1749 (apply 'vc-do-command 0 "cvs" file 'BASE 1775 (apply 'vc-do-command 0 "cvs" file 'WORKFILE
1750 (and rev (concat "-r" rev)) 1776 (and rev (concat "-r" rev))
1751 file 1777 file
1752 vc-checkout-switches)) 1778 vc-checkout-switches))
@@ -1791,7 +1817,7 @@ with RCS)."
1791 (concat "-m" comment) 1817 (concat "-m" comment)
1792 vc-checkin-switches) 1818 vc-checkin-switches)
1793 (progn 1819 (progn
1794 (apply 'vc-do-command 0 "cvs" file 'BASE 1820 (apply 'vc-do-command 0 "cvs" file 'WORKFILE
1795 "ci" "-m" comment 1821 "ci" "-m" comment
1796 vc-checkin-switches) 1822 vc-checkin-switches)
1797 (vc-file-setprop file 'vc-checkout-time 1823 (vc-file-setprop file 'vc-checkout-time
@@ -1813,7 +1839,7 @@ with RCS)."
1813 "-f" "-u") 1839 "-f" "-u")
1814 (progn ;; CVS 1840 (progn ;; CVS
1815 (delete-file file) 1841 (delete-file file)
1816 (vc-do-command 0 "cvs" file 'BASE "update")) 1842 (vc-do-command 0 "cvs" file 'WORKFILE "update"))
1817 ) 1843 )
1818 (vc-file-setprop file 'vc-locking-user nil) 1844 (vc-file-setprop file 'vc-locking-user nil)
1819 (message "Reverting %s...done" file) 1845 (message "Reverting %s...done" file)
@@ -1853,14 +1879,14 @@ with RCS)."
1853 file 1879 file
1854 (vc-do-command 0 "prs" file 'MASTER) 1880 (vc-do-command 0 "prs" file 'MASTER)
1855 (vc-do-command 0 "rlog" file 'MASTER) 1881 (vc-do-command 0 "rlog" file 'MASTER)
1856 (vc-do-command 0 "cvs" file 'BASE "rlog"))) 1882 (vc-do-command 0 "cvs" file 'WORKFILE "rlog")))
1857 1883
1858(defun vc-backend-assign-name (file name) 1884(defun vc-backend-assign-name (file name)
1859 ;; Assign to a FILE's latest version a given NAME. 1885 ;; Assign to a FILE's latest version a given NAME.
1860 (vc-backend-dispatch file 1886 (vc-backend-dispatch file
1861 (vc-add-triple name file (vc-latest-version file)) ;; SCCS 1887 (vc-add-triple name file (vc-latest-version file)) ;; SCCS
1862 (vc-do-command 0 "rcs" file 'MASTER (concat "-n" name ":")) ;; RCS 1888 (vc-do-command 0 "rcs" file 'MASTER (concat "-n" name ":")) ;; RCS
1863 (vc-do-command 0 "cvs" file 'BASE "tag" name) ;; CVS 1889 (vc-do-command 0 "cvs" file 'WORKFILE "tag" name) ;; CVS
1864 ) 1890 )
1865 ) 1891 )
1866 1892
@@ -1878,6 +1904,7 @@ with RCS)."
1878 (let* ((command (if (eq backend 'SCCS) 1904 (let* ((command (if (eq backend 'SCCS)
1879 "vcdiff" 1905 "vcdiff"
1880 "rcsdiff")) 1906 "rcsdiff"))
1907 (mode (if (eq backend 'RCS) 'WORKFILE 'MASTER))
1881 (options (append (list (and cmp "--brief") 1908 (options (append (list (and cmp "--brief")
1882 "-q" 1909 "-q"
1883 (and oldvers (concat "-r" oldvers)) 1910 (and oldvers (concat "-r" oldvers))
@@ -1886,10 +1913,10 @@ with RCS)."
1886 (if (listp diff-switches) 1913 (if (listp diff-switches)
1887 diff-switches 1914 diff-switches
1888 (list diff-switches))))) 1915 (list diff-switches)))))
1889 (status (apply 'vc-do-command 2 command file options))) 1916 (status (apply 'vc-do-command 2 command file mode options)))
1890 ;; Some RCS versions don't understand "--brief"; work around this. 1917 ;; Some RCS versions don't understand "--brief"; work around this.
1891 (if (eq status 2) 1918 (if (eq status 2)
1892 (apply 'vc-do-command 1 command file 'MASTER 1919 (apply 'vc-do-command 1 command file 'WORKFILE
1893 (if cmp (cdr options) options)) 1920 (if cmp (cdr options) options))
1894 status))) 1921 status)))
1895 ;; CVS is different. 1922 ;; CVS is different.
@@ -1901,12 +1928,12 @@ with RCS)."
1901 (if (or oldvers newvers) 1928 (if (or oldvers newvers)
1902 (error "No revisions of %s exists" file) 1929 (error "No revisions of %s exists" file)
1903 (apply 'vc-do-command 1930 (apply 'vc-do-command
1904 1 "diff" file 'BASE "/dev/null" 1931 1 "diff" file 'WORKFILE "/dev/null"
1905 (if (listp diff-switches) 1932 (if (listp diff-switches)
1906 diff-switches 1933 diff-switches
1907 (list diff-switches)))) 1934 (list diff-switches))))
1908 (apply 'vc-do-command 1935 (apply 'vc-do-command
1909 1 "cvs" file 'BASE "diff" 1936 1 "cvs" file 'WORKFILE "diff"
1910 (and oldvers (concat "-r" oldvers)) 1937 (and oldvers (concat "-r" oldvers))
1911 (and newvers (concat "-r" newvers)) 1938 (and newvers (concat "-r" newvers))
1912 (if (listp diff-switches) 1939 (if (listp diff-switches)
@@ -1921,7 +1948,7 @@ with RCS)."
1921 file 1948 file
1922 (error "vc-backend-merge-news not meaningful for SCCS files") ;SCCS 1949 (error "vc-backend-merge-news not meaningful for SCCS files") ;SCCS
1923 (error "vc-backend-merge-news not meaningful for RCS files") ;RCS 1950 (error "vc-backend-merge-news not meaningful for RCS files") ;RCS
1924 (vc-do-command 1 "cvs" file 'BASE "update") ;CVS 1951 (vc-do-command 1 "cvs" file 'WORKFILE "update") ;CVS
1925 )) 1952 ))
1926 1953
1927(defun vc-check-headers () 1954(defun vc-check-headers ()
@@ -2041,6 +2068,7 @@ Invoke FUNC f ARGS on each non-directory file f underneath it."
2041 (lambda (f) (or 2068 (lambda (f) (or
2042 (string-equal f ".") 2069 (string-equal f ".")
2043 (string-equal f "..") 2070 (string-equal f "..")
2071 (member f vc-directory-exclusion-list)
2044 (let ((dirf (concat dir f))) 2072 (let ((dirf (concat dir f)))
2045 (or 2073 (or
2046 (file-symlink-p dirf) ;; Avoid possible loops 2074 (file-symlink-p dirf) ;; Avoid possible loops