annotate lisp/packages/sccs.el @ 0:376386a54a3c r19-14

Import from CVS: tag r19-14
author cvs
date Mon, 13 Aug 2007 08:45:50 +0200
parents
children 131b0175ea99
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;; sccs.el -- easy-to-use SCCS control from within Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 ;; @(#)sccs.el 3.5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; but WITHOUT ANY WARRANTY. No author or distributor
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; accepts responsibility to anyone for the consequences of using it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 ;; or for whether it serves any particular purpose or works at all,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; unless he says so in writing. Refer to the GNU Emacs General Public
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; License for full details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; Everyone is granted permission to copy, modify and redistribute
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs, but only under the conditions described in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; GNU Emacs General Public License. A copy of this license is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; supposed to have been given to you along with GNU Emacs so you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; can know your rights and responsibilities. It should be in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; file named COPYING. Among other things, the copyright notice
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; and this notice must be preserved on all copies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;;; #### Chuck -- I say remove this piece of crap! Use VC instead.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Author: Eric S. Raymond (eric@snark.thyrsus.com).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;;; It is distantly derived from an rcs mode written by Ed Simpson
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; ({decvax, seismo}!mcnc!duke!dukecdu!evs) in years gone by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; and revised at MIT's Project Athena.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;;; Modified: Made to work for Lucid Emacs by persons who don't know SCCS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Modified: Ben Wing (Ben.Wing@eng.sun.com) -- fixed up and redid menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; User options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 (defvar sccs-bin-directory nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 "*Directory that holds the SCCS executables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 Initialized automatically the first time you execute an SCCS command,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 if not already set.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 (defvar sccs-max-log-size 510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 "*Maximum allowable size of an SCCS log message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 (defvar sccs-diff-command '("diff" "-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 "*The command/flags list to be used in constructing SCCS diff commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar sccs-headers-wanted '("\%\W\%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*SCCS header keywords to be inserted when sccs-insert-header is executed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 (defvar sccs-insert-static t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 "*Insert a static character string when inserting SCCS headers in C mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 (defvar sccs-mode-expert nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 "*Treat user as expert; suppress yes-no prompts on some things.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Vars the user doesn't need to know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 (defvar sccs-log-entry-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 (defvar sccs-current-major-version nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; Some helper functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defun sccs-name (file &optional letter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "Return the sccs-file name corresponding to a given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 (format "%sSCCS/%s.%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 (concat (file-name-directory (expand-file-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 (or letter "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (concat (file-name-nondirectory (expand-file-name file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (defun sccs-lock-info (file index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 "Return the nth token in a file's SCCS-lock information."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ((pfile (sccs-name file "p")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (and (file-exists-p pfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (find-file pfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (auto-save-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (replace-string " " "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (forward-line index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 (buffer-substring (point) (progn (end-of-line) (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defun sccs-locking-user (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "Return the name of the person currently holding a lock on FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 Return nil if there is no such person."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (sccs-lock-info file 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defun sccs-locked-revision (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Return the revision number currently locked for FILE, nil if none such."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 (sccs-lock-info file 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defmacro error-occurred (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; There has *got* to be a better way to do this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defmacro chmod (perms file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (list 'call-process "chmod" nil nil nil perms file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 (defun sccs-save-vars (sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (find-file "SCCS/emacs-vars.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 (insert "(setq sccs-current-major-version \"" sid "\")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (basic-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 (defun sccs-load-vars ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 (if (error-occurred (load-file "SCCS/emacs-vars.el"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 (setq sccs-current-major-version "1"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (defun sccs-init-bin-directory ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (setq sccs-bin-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (cond ((file-executable-p "/usr/sccs/unget") "/usr/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 ((file-executable-p "/usr/bin/unget") "/usr/bin")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ((file-directory-p "/usr/sccs") "/usr/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ((file-directory-p "/usr/bin/sccs") "/usr/bin/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (t "/usr/bin"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 ;; The following functions do most of the real work
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defun sccs-get-version (file sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "For the given FILE, retrieve a copy of the version with given SID.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 The text is retrieved into a tempfile. Return the tempfile name, or nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 if no such version exists."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (let (oldversion vbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (setq oldversion (sccs-name file (or sid "new")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 (setq vbuf (create-file-buffer oldversion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (if (not (error-occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (sccs-do-command vbuf "get" file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (and sid (concat "-r" sid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 "-p" "-s")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 (set-buffer vbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (write-region (point-min) (point-max) oldversion t 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 oldversion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 (kill-buffer vbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (defun sccs-mode-line (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 "Set the mode line for an SCCS buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 FILE is the file being visited to put in the modeline."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (setq mode-line-process
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (if (file-exists-p (sccs-name file "p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 (format " <SCCS: %s>" (sccs-locked-revision file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ; force update of frame
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (save-excursion (set-buffer (other-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (sit-for 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defun sccs-do-command (buffer command file &rest flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 " Execute an SCCS command, notifying the user and checking for errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 (message (format "Running %s on %s..." command file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (or sccs-bin-directory (sccs-init-bin-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (let ((status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (set-buffer (get-buffer-create buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 (while (and flags (not (car flags)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (setq flags (cdr flags)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (setq flags (append flags (and file (list (sccs-name file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (let ((default-directory (file-name-directory (or file "./")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (exec-path (cons sccs-bin-directory exec-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (apply 'call-process command nil t nil flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (previous-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (if (looking-at "ERROR")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 (previous-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (print (cons command flags))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (next-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (if status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (message (format "Running %s...OK" command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (pop-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (error (format "Running %s...FAILED" command))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (if file (sccs-mode-line file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (defun sccs-shell-command (command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 "Like shell-command except that the *Shell Command Output*buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 is created even if the command does not output anything"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (shell-command command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 (get-buffer-create "*Shell Command Output*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (defun sccs-tree-walk (func &rest optargs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Apply FUNC to each SCCS file under the default directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 If present, OPTARGS are also passed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (sccs-shell-command (concat "/bin/ls -1 " default-directory "SCCS/s.*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 (set-buffer "*Shell Command Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (replace-string "SCCS/s." "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (error "No SCCS files under %s" default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (let ((file (buffer-substring (point) (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (apply func file optargs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 (defun sccs-init ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 (or (current-local-map) (use-local-map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (condition-case nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 ;; If C-c s is already defined by another mode, then we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 ;; will get an error. In that case, just don't do anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (define-key (current-local-map) "\C-cs?" 'describe-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (define-key (current-local-map) "\C-csn" 'sccs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (define-key (current-local-map) "\C-csm" 'sccs-register-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 (define-key (current-local-map) "\C-csh" 'sccs-insert-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (define-key (current-local-map) "\C-csd" 'sccs-revert-diff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (define-key (current-local-map) "\C-csp" 'sccs-prs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (define-key (current-local-map) "\C-csr" 'sccs-revert-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (define-key (current-local-map) "\C-cs\C-d" 'sccs-version-diff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (define-key (current-local-map) "\C-cs\C-p" 'sccs-pending)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (define-key (current-local-map) "\C-cs\C-r" 'sccs-registered)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; Here's the major entry point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (defun sccs (verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 "*Do the next logical SCCS operation on the file in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 You must have an SCCS subdirectory in the same directory as the file being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 operated on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 If the file is not already registered with SCCS, this does an admin -i
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 followed by a get -e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 If the file is registered and not locked by anyone, this does a get -e.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 If the file is registered and locked by the calling user, this pops up a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 buffer for creation of a log message, then does a delta -n on the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 A read-only copy of the changed file is left in place afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 If the file is registered and locked by someone else, an error message is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 returned indicating who has locked it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (sccs-init)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (if (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (do-update revision owner
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (sccs-file (sccs-name (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (sccs-log-buf (get-buffer-create "*SCCS-Log*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (err-msg nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; if there is no SCCS file corresponding, create one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (if (not (file-exists-p sccs-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (sccs-load-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (sccs-admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (verbose (read-string "Initial SID: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ((error-occurred (load-file "SCCS/emacs-vars.el")) "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (t sccs-current-major-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 ;; if there is no lock on the file, assert one and get it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ((not (file-exists-p (sccs-name file "p")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (sccs-get file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (sccs-mode-line file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; a checked-out version exists, but the user may not own the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 ((not (string-equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq owner (sccs-locking-user file)) (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (error "Sorry, %s has that file checked out" owner))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 ;; OK, user owns the lock on the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (t (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 ;; if so, give luser a chance to save before delta-ing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 sccs-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (setq revision (sccs-locked-revision file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 ;; user may want to set nonstandard parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (if verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (if (or sccs-mode-expert (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (format "SID: %s Change revision level? " revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (setq revision (read-string "New revision level: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; OK, let's do the delta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; this excursion returns t if the new version was saved OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (pop-to-buffer (get-buffer-create "*SCCS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 (sccs-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 "Enter log message. Type C-c C-c when done, C-c ? for help.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (and (not (error-occurred (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (not (error-occurred (sccs-delta file revision))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (bury-buffer "*SCCS*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 ;; if the save went OK do some post-checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 "Delta-ed version of file does not match buffer!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 ;; sccs-delta already turned off write-privileges on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;; file, let's not re-fetch it unless there's something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 ;; in it that get would expand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 ;; fooey on this. You always need to refetch the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 ;; file; otherwise weirdness will ensue when you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 ;; trying to do a make. --bpw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 ; (if (sccs-check-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (sccs-get file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (sccs-mode-line file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (run-hooks 'sccs-delta-ok)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (error "There is no file associated with buffer %s" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (defun sccs-insert-last-log ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 "*Insert the log message of the last SCCS check in at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (insert-buffer sccs-log-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 ;;; These functions help the sccs entry point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (defun sccs-get (file writeable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 "Retrieve a copy of the latest delta of the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (sccs-do-command "*SCCS*" "get" file (if writeable "-e")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (defun sccs-admin (file sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "Checks a file into sccs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 FILE is the unmodified name of the file. SID should be the base-level sid to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 check it in under."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 ; give a change to save the file if it's modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (sccs-do-command "*SCCS*" "admin" file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (concat "-i" file) (concat "-r" sid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (chmod "-w" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (if (sccs-check-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 (sccs-get file nil)) ;; expand SCCS headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (sccs-mode-line file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (defun sccs-delta (file &optional rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 "Delta the file specified by FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 The optional argument REV may be a string specifying the new revision level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 \(if nil increment the current level). The file is retained with write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 permissions zeroed. COMMENT is a comment string; if omitted, the contents of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 the current buffer up to point becomes the comment for this delta."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (if (not comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (not (bolp)) (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (newline)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (setq comment (buffer-substring (point-min) (1- (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (sccs-do-command "*SCCS*" "delta" file "-n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 (if rev (format "-r%s" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 (format "-y%s" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (chmod "-w" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 (defun sccs-delta-abort ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 "Abort an SCCS delta command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (if (or sccs-mode-expert (y-or-n-p "Abort the delta? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (error "Delta aborted")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defun sccs-log-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 "Leave the recursive edit of an SCCS log message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (if (< (buffer-size) sccs-max-log-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (copy-to-buffer sccs-log-buf (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (exit-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (goto-char sccs-max-log-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 "Log must be less than %d characters. Point is now at char %d."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 sccs-max-log-size sccs-max-log-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; Additional entry points for examining version histories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (defun sccs-revert-diff (&rest flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 "*Compare the version being edited with the last checked-in revision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 Or, if given a prefix argument, with another specified revision."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (let (old file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (setq old (sccs-get-version (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (read-string "Revision to compare against: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 sccs-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (setq file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (set-buffer (get-buffer-create "*SCCS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 (apply 'call-process (car sccs-diff-command) nil t nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (append (cdr sccs-diff-command) flags (list old) (list file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (delete-file old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (if (equal (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (message (format "No changes to %s since last get." file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (pop-to-buffer "*SCCS*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defun sccs-prs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 "*List the SCCS log of the current buffer in an emacs window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (if (and buffer-file-name (file-exists-p (sccs-name buffer-file-name "s")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (sccs-do-command "*SCCS*" "prs" buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (pop-to-buffer (get-buffer-create "*SCCS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (error "There is no SCCS file associated with this buffer")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (defun sccs-version-diff (file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 "*For FILE, report diffs between two stored deltas REL1 and REL2 of it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (interactive "fFile: \nsOlder version: \nsNewer version: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (string-equal rel1 "") (setq rel1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (if (string-equal rel2 "") (setq rel2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (set-buffer (get-buffer-create "*SCCS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (sccs-vdiff file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (if (equal (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 (message (format "No changes to %s between %s and %s." file rel1 rel2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (pop-to-buffer "*SCCS*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (defun sccs-vdiff (file rel1 rel2 &optional flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 "Compare two deltas into the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 (let (vers1 vers2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 (setq vers1 (sccs-get-version file rel1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 (setq vers2 (if rel2 (sccs-get-version file rel2) file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ; (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 ; (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 ; (not (error-occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 ; (call-process "prs" nil t t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 ; (sccs-name file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 ; )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (apply 'call-process (car sccs-diff-command) nil t t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 (append (cdr sccs-diff-command) flags (list vers1) (list vers2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (condition-case () (delete-file vers1) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (if rel2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (condition-case () (delete-file vers2) (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 ;; SCCS header insertion code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (defun sccs-insert-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 "*Insert headers for use with the Source Code Control System.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 Headers desired are inserted at the start of the buffer, and are pulled from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 the variable sccs-headers-wanted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (or (not (sccs-check-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 (y-or-n-p "SCCS headers already exist. Insert another set?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (run-hooks 'sccs-insert-headers-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (cond ((eq major-mode 'c-mode) (sccs-insert-c-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 ((eq major-mode 'lisp-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 ((eq major-mode 'emacs-lisp-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 ((eq major-mode 'scheme-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 ((eq major-mode 'nroff-mode) (sccs-insert-nroff-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ((eq major-mode 'plain-tex-mode) (sccs-insert-tex-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 ((eq major-mode 'texinfo-mode) (sccs-insert-texinfo-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (t (sccs-insert-generic-header))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (defun sccs-insert-c-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (let (st en)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (insert "/*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (insert " *\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (insert " */\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (if (and sccs-insert-static
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (not (string-match "\\.h$" (buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (insert "#ifndef lint\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 "static char *sccsid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; (setq st (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;; (insert (file-name-nondirectory (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; (setq en (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 ;; (subst-char-in-region st en ?. ?_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (insert " = \"\%\W\%\";\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 "#endif /* lint */\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (run-hooks 'sccs-insert-c-header-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (defun sccs-insert-lisp-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (insert ";;;\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (run-hooks 'sccs-insert-lisp-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (defun sccs-insert-nroff-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (insert ".\\\"\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (run-hooks 'sccs-insert-nroff-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (defun sccs-insert-tex-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (insert "%%\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (run-hooks 'sccs-insert-tex-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (defun sccs-insert-texinfo-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 (insert "@comment\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (run-hooks 'sccs-insert-texinfo-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (defun sccs-insert-generic-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (let* ((comment-start-sccs (or comment-start "#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (comment-end-sccs (or comment-end ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (dont-insert-nl-p (string-match "\n" comment-end-sccs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 (insert comment-start-sccs "\t" s ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 comment-end-sccs (if dont-insert-nl-p "" "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (insert comment-start-sccs comment-end-sccs (if dont-insert-nl-p "" "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (defun sccs-check-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "Check if the current file has any SCCS headers in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 (re-search-forward "%[MIRLBSDHTEGUYFPQCZWA]%" (point-max) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; Status-checking functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (defun sccs-status (prefix legend)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 "List all files underneath the current directory matching a prefix type."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (sccs-shell-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (concat "/bin/ls -1 SCCS/" prefix ".*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (if
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (set-buffer "*Shell Command Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 (if (= (point-max) (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (not (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 "No files are currently %s under %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 legend default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 "The following files are currently " legend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 " under " default-directory ":\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (replace-string (format "SCCS/%s." prefix) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 (pop-to-buffer "*Shell Command Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 (defun sccs-pending ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 "*List all files currently SCCS locked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (sccs-status "p" "locked"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (defun sccs-registered ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 "*List all files currently SCCS registered."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (sccs-status "s" "registered"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (defun sccs-register-file (override)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 "*Register the file visited by the current buffer into SCCS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (if (file-exists-p (sccs-name (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (error "This file is already registered into SCCS.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 sccs-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (sccs-load-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (sccs-admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (override (read-string "Initial SID: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 ((error-occurred (load-file "SCCS/emacs-vars.el")) "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (t sccs-current-major-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 ;; Major functions for release-tracking and generation.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 (defun sccs-release-diff (rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "*Diff all files below default-directory between versions REL1 and REL2.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 The report goes to a shell output buffer which is popped to. If REL2 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 omitted or nil, the comparison is done against the most recent version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (interactive "sOlder version: \nsNewer version: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (if (string-equal rel1 "") (setq rel1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (if (string-equal rel2 "") (setq rel2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (sccs-shell-command (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "/bin/ls -1 " default-directory "SCCS/s.*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (set-buffer "*Shell Command Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (replace-string "SCCS/s." "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (if (eobp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (error "No SCCS files under %s" default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 (let
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ((sccsbuf (get-buffer-create "*SCCS*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 (set-buffer sccsbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (insert (format "Diffs from %s to %s.\n\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (or rel1 "current") (or rel2 "current"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (let ((file (buffer-substring (point) (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (set-buffer sccsbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (sccs-vdiff file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (insert "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (kill-buffer "*Shell Command Output*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (pop-to-buffer sccsbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (insert "\nEnd of diffs.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 (replace-string (format "/SCCS/%s." rel1) "/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (replace-string (format "/SCCS/%s." rel2) "/new/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (replace-string "/SCCS/new." "/new/")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (replace-regexp (concat "^*** " default-directory) "*** ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (replace-regexp (concat "^--- " default-directory) "--- ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (defun sccs-dummy-delta (file sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 "Make a dummy delta to the given FILE with the given SID."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (interactive "sFile: \nsRelease ID: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (if (not (sccs-locked-revision file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (sccs-get file t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 ;; Grottiness alert -- to get around SCCS's obsessive second-guessing we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 ;; have to mung the p-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (let ((pfile (sccs-name file "p")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (chmod "u+w" pfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 (find-file pfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (auto-save-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (replace-regexp "^\\([0-9.]+\\) \\([0-9.]+\\)" (concat "\\1 " sid) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (write-region (point-min) (point-max) pfile t 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (chmod "u-w" pfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 (sccs-delta file sid (concat "Release " sid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (sccs-get file nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (sccs-save-vars sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (defun sccs-delta-release (sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 "*Delta everything underneath the current directory to mark it as a release."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (interactive "sRelease: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 (sccs-tree-walk 'sccs-dummy-delta sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (kill-buffer "*SCCS*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 ;; Miscellaneous other entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (defun sccs-revert-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "*Revert the current buffer's file back to the last saved version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (let ((file (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (if (y-or-n-p (format "Revert file %s to last SCCS revision?" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (delete-file (sccs-name file "p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (rename-file (sccs-get-version file nil) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 (chmod "-w" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (sccs-mode-line file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (defun sccs-rename-file (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 "*Rename a file, taking its SCCS files with it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (interactive "fOld name: \nFNew name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (let ((owner (sccs-locking-user old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (if (and owner (not (string-equal owner (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (error "Sorry, %s has that file checked out" owner))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (rename-file old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (if (file-exists-p (sccs-name old "p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 (rename-file (sccs-name old "p") (sccs-name new "p")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (if (file-exists-p (sccs-name old "s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 (rename-file (sccs-name old "s") (sccs-name new "s")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 ;; Set up key bindings for SCCS use, e.g. while editing log messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (defun sccs-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 "Minor mode for driving the SCCS tools.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778 These bindings are added to the global keymap when you enter this mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 \\[sccs] perform next logical SCCS operation (`sccs') on current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 \\[sccs-register-file] register current file into SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 \\[sccs-insert-headers] insert SCCS headers in current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 \\[sccs-prs] display change history of current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 \\[sccs-revert-buffer] revert buffer to last saved version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 \\[sccs-revert-diff] show difference between buffer and last saved delta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 \\[sccs-pending] show all files currently locked by any user in or below .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 \\[sccs-registered] show all files registered into SCCS in or below .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 \\[sccs-version-diff] show diffs between saved versions for all files in or below .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 When you generate headers into a buffer using C-c h, the value of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 sccs-insert-headers-hook is called before insertion. If the file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 recognized a C or Lisp source, sccs-insert-c-header-hook or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 sccs-insert-lisp-header-hook is called after insertion respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 While you are entering a change log message for a delta, the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 additional bindings will be in effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 \\[sccs-log-exit] proceed with check in, ending log message entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 \\[sccs-insert-last-log] insert log message from last check-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 \\[sccs-delta-abort] abort this delta check-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 Entry to the change-log submode calls the value of text-mode-hook, then
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 the value sccs-mode-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 Global user options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 sccs-mode-expert suppresses some conformation prompts,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 notably for delta aborts and file saves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 sccs-max-log-size specifies the maximum allowable size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 of a log message plus one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 sccs-diff-command A list consisting of the command and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 to be used for generating context diffs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 sccs-headers-wanted which %-keywords to insert when adding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 SCCS headers with C-c h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 sccs-insert-static if non-nil, SCCS keywords inserted in C files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 get stuffed in a static string area so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 what(1) can see them in the compiled object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (use-local-map sccs-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (setq major-mode 'sccs-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (setq mode-name "SCCS Change Log Entry")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (run-hooks 'text-mode-hook 'sccs-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 ;; Initialization code, to be done just once at load-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (if sccs-log-entry-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (setq sccs-log-entry-mode (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 (define-key sccs-log-entry-mode "\C-ci" 'sccs-insert-last-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 (define-key sccs-log-entry-mode "\C-c\C-i" 'sccs-insert-last-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (define-key sccs-log-entry-mode "\C-ca" 'sccs-delta-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (define-key sccs-log-entry-mode "\C-c\C-a" 'sccs-delta-abort)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (define-key sccs-log-entry-mode "\C-c\C-c" 'sccs-log-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (define-key sccs-log-entry-mode "\C-x\C-s" 'sccs-log-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 ;;; Lucid Emacs support
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (defconst sccs-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 '("SCCS Commands"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 ["SCCS" sccs t nil] ; C-c s n
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 ["Insert Headers" sccs-insert-headers t] ; C-c s h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 ["Archive History:" sccs-prs t nil] ; C-c s p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ["Diffs from Archive:" sccs-revert-diff t nil] ; C-c s d
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ["Revert to Archive:" sccs-revert-buffer t nil] ; C-c s r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ["Check In..." sccs-dummy-delta t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 ["Create Archive..." sccs-register-file t] ; C-c s h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 ["Rename Archive..." sccs-rename-file t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ["List Checked-Out Files" sccs-pending t] ; C-c s C-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ["List Registered Files" sccs-registered t] ; C-c s C-r
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 ["Diff Directory" sccs-release-diff t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 ["Delta Directory" sccs-delta-release t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (delete-menu-item '("SCCS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (add-menu '() "SCCS" (cdr sccs-menu)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 (defun sccs-sensitize-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 (let* ((rest (cdr (car (find-menu-item current-menubar '("SCCS")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (file (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (file-name-nondirectory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 (dir (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (if buffer-file-name buffer-file-name default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (sccs-file (and buffer-file-name (sccs-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (known-p (and sccs-file (file-exists-p sccs-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (checked-out-p (and known-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (file-exists-p (sccs-name buffer-file-name "p"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (setq item (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (if (not (vectorp item))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (setq command (aref item 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (if (eq 'sccs command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (aset item 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (cond ((or (null sccs-file) (not known-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 "Create Archive:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 ((not checked-out-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 "Check Out")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 "Check In"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ((and (> (length item) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (string-match "directory" (aref item 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (aset item 3 dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 ((> (length item) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (aset item 3 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (aset item 2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 ((memq command '(sccs-prs))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 known-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 ((memq command '(sccs-revert-diff sccs-revert-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 checked-out-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (setq rest (cdr rest))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (add-hook 'activate-menubar-hook 'sccs-sensitize-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (provide 'sccs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 ;; sccs.el ends here