Commit | Line | Data |
---|---|---|
7a004b71 GM |
1 | ;;; vc-sccs.el --- support for SCCS version-control |
2 | ||
0d30b337 | 3 | ;; Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, |
5df4f04c | 4 | ;; 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011 |
59465d84 | 5 | ;; Free Software Foundation, Inc. |
7a004b71 GM |
6 | |
7 | ;; Author: FSF (see vc.el for full credits) | |
8 | ;; Maintainer: Andre Spiegel <spiegel@gnu.org> | |
bd78fa1d | 9 | ;; Package: vc |
7a004b71 | 10 | |
7a004b71 GM |
11 | ;; This file is part of GNU Emacs. |
12 | ||
eb3fa2cf | 13 | ;; GNU Emacs is free software: you can redistribute it and/or modify |
7a004b71 | 14 | ;; it under the terms of the GNU General Public License as published by |
eb3fa2cf GM |
15 | ;; the Free Software Foundation, either version 3 of the License, or |
16 | ;; (at your option) any later version. | |
7a004b71 GM |
17 | |
18 | ;; GNU Emacs is distributed in the hope that it will be useful, | |
19 | ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
20 | ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
21 | ;; GNU General Public License for more details. | |
22 | ||
23 | ;; You should have received a copy of the GNU General Public License | |
eb3fa2cf | 24 | ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
7a004b71 GM |
25 | |
26 | ;;; Commentary: | |
27 | ||
1043ce19 DN |
28 | ;; Proper function of the SCCS diff commands requires the shellscript vcdiff |
29 | ;; to be installed somewhere on Emacs's path for executables. | |
30 | ;; | |
31 | ||
7a004b71 GM |
32 | ;;; Code: |
33 | ||
f1180544 | 34 | (eval-when-compile |
a1e9f194 AS |
35 | (require 'vc)) |
36 | ||
f1180544 | 37 | ;;; |
8f98485f AS |
38 | ;;; Customization options |
39 | ;;; | |
40 | ||
14b11401 SM |
41 | ;; ;; Maybe a better solution is to not use "get" but "sccs get". |
42 | ;; (defcustom vc-sccs-path | |
43 | ;; (let ((path ())) | |
44 | ;; (dolist (dir '("/usr/sccs" "/usr/lib/sccs" "/usr/libexec/sccs")) | |
45 | ;; (if (file-directory-p dir) | |
46 | ;; (push dir path))) | |
47 | ;; path) | |
48 | ;; "List of extra directories to search for SCCS commands." | |
49 | ;; :type '(repeat directory) | |
50 | ;; :group 'vc) | |
51 | ||
7a004b71 | 52 | (defcustom vc-sccs-register-switches nil |
12fcd25a | 53 | "Switches for registering a file in SCCS. |
a7cafade | 54 | A string or list of strings passed to the checkin program by |
12fcd25a GM |
55 | \\[vc-register]. If nil, use the value of `vc-register-switches'. |
56 | If t, use no switches." | |
57 | :type '(choice (const :tag "Unspecified" nil) | |
58 | (const :tag "None" t) | |
7a004b71 | 59 | (string :tag "Argument String") |
12fcd25a | 60 | (repeat :tag "Argument List" :value ("") string)) |
a7cafade | 61 | :version "21.1" |
7a004b71 GM |
62 | :group 'vc) |
63 | ||
a1e9f194 | 64 | (defcustom vc-sccs-diff-switches nil |
3edf7a64 GM |
65 | "String or list of strings specifying switches for SCCS diff under VC. |
66 | If nil, use the value of `vc-diff-switches'. If t, use no switches." | |
67 | :type '(choice (const :tag "Unspecified" nil) | |
68 | (const :tag "None" t) | |
a1e9f194 | 69 | (string :tag "Argument String") |
3edf7a64 | 70 | (repeat :tag "Argument List" :value ("") string)) |
a1e9f194 AS |
71 | :version "21.1" |
72 | :group 'vc) | |
73 | ||
67141a37 | 74 | (defcustom vc-sccs-header '("%W%") |
9201cc28 | 75 | "Header keywords to be inserted by `vc-insert-headers'." |
8b7c8991 | 76 | :type '(repeat string) |
67141a37 | 77 | :version "24.1" ; no longer consult the obsolete vc-header-alist |
7a004b71 GM |
78 | :group 'vc) |
79 | ||
80 | ;;;###autoload | |
81 | (defcustom vc-sccs-master-templates | |
6bdad9ae | 82 | (purecopy '("%sSCCS/s.%s" "%ss.%s" vc-sccs-search-project-dir)) |
9201cc28 | 83 | "Where to look for SCCS master files. |
7a004b71 GM |
84 | For a description of possible values, see `vc-check-master-templates'." |
85 | :type '(choice (const :tag "Use standard SCCS file names" | |
86 | ("%sSCCS/s.%s" "%ss.%s" vc-sccs-search-project-dir)) | |
87 | (repeat :tag "User-specified" | |
88 | (choice string | |
89 | function))) | |
a7cafade | 90 | :version "21.1" |
7a004b71 GM |
91 | :group 'vc) |
92 | ||
8f98485f AS |
93 | \f |
94 | ;;; | |
95 | ;;; Internal variables | |
96 | ;;; | |
97 | ||
099bd78a SM |
98 | (defconst vc-sccs-name-assoc-file "VC-names") |
99 | ||
8f98485f | 100 | \f |
8cdd17b4 ER |
101 | ;;; Properties of the backend |
102 | ||
14b11401 | 103 | (defun vc-sccs-revision-granularity () 'file) |
70e2f6c7 | 104 | (defun vc-sccs-checkout-model (files) 'locking) |
8cdd17b4 | 105 | |
8f98485f AS |
106 | ;;; |
107 | ;;; State-querying functions | |
108 | ;;; | |
109 | ||
14b11401 SM |
110 | ;; The autoload cookie below places vc-sccs-registered directly into |
111 | ;; loaddefs.el, so that vc-sccs.el does not need to be loaded for | |
112 | ;; every file that is visited. The definition is repeated below | |
113 | ;; so that Help and etags can find it. | |
9ef33737 AS |
114 | |
115 | ;;;###autoload (defun vc-sccs-registered(f) (vc-default-registered 'SCCS f)) | |
af65391b | 116 | (defun vc-sccs-registered (f) (vc-default-registered 'SCCS f)) |
7a004b71 GM |
117 | |
118 | (defun vc-sccs-state (file) | |
119 | "SCCS-specific function to compute the version control state." | |
3702367b ER |
120 | (if (not (vc-sccs-registered file)) |
121 | 'unregistered | |
122 | (with-temp-buffer | |
123 | (if (vc-insert-file (vc-sccs-lock-file file)) | |
124 | (let* ((locks (vc-sccs-parse-locks)) | |
125 | (working-revision (vc-working-revision file)) | |
126 | (locking-user (cdr (assoc working-revision locks)))) | |
127 | (if (not locking-user) | |
128 | (if (vc-workfile-unchanged-p file) | |
129 | 'up-to-date | |
130 | 'unlocked-changes) | |
131 | (if (string= locking-user (vc-user-login-name file)) | |
132 | 'edited | |
133 | locking-user))) | |
134 | 'up-to-date)))) | |
7a004b71 GM |
135 | |
136 | (defun vc-sccs-state-heuristic (file) | |
137 | "SCCS-specific state heuristic." | |
138 | (if (not (vc-mistrust-permissions file)) | |
139 | ;; This implementation assumes that any file which is under version | |
140 | ;; control and has -rw-r--r-- is locked by its owner. This is true | |
141 | ;; for both RCS and SCCS, which keep unlocked files at -r--r--r--. | |
142 | ;; We have to be careful not to exclude files with execute bits on; | |
143 | ;; scripts can be under version control too. Also, we must ignore the | |
144 | ;; group-read and other-read bits, since paranoid users turn them off. | |
bbd88348 AS |
145 | (let* ((attributes (file-attributes file 'string)) |
146 | (owner-name (nth 2 attributes)) | |
7a004b71 GM |
147 | (permissions (nth 8 attributes))) |
148 | (if (string-match ".r-..-..-." permissions) | |
149 | 'up-to-date | |
150 | (if (string-match ".rw..-..-." permissions) | |
151 | (if (file-ownership-preserved-p file) | |
152 | 'edited | |
bbd88348 | 153 | owner-name) |
8bfde4be AS |
154 | ;; Strange permissions. |
155 | ;; Fall through to real state computation. | |
156 | (vc-sccs-state file)))) | |
157 | (vc-sccs-state file))) | |
7a004b71 | 158 | |
c1b51374 | 159 | (defun vc-sccs-dir-status (dir update-function) |
4b1a01b3 DN |
160 | ;; FIXME: this function should be rewritten, using `vc-expand-dirs' |
161 | ;; is not TRTD because it returns files from multiple backends. | |
162 | ;; It should also return 'unregistered files. | |
163 | ||
164 | ;; Doing lots of individual VC-state calls is painful, but | |
5a9de6d0 | 165 | ;; there is no better option in SCCS-land. |
90e9ca17 DN |
166 | (let ((flist (vc-expand-dirs (list dir))) |
167 | (result nil)) | |
168 | (dolist (file flist) | |
169 | (let ((state (vc-state file)) | |
170 | (frel (file-relative-name file))) | |
4b1a01b3 DN |
171 | (when (and (eq (vc-backend file) 'SCCS) |
172 | (not (eq state 'up-to-date))) | |
173 | (push (list frel state) result)))) | |
c1b51374 | 174 | (funcall update-function result))) |
90e9ca17 | 175 | |
ac3f4c6f ER |
176 | (defun vc-sccs-working-revision (file) |
177 | "SCCS-specific version of `vc-working-revision'." | |
7a004b71 | 178 | (with-temp-buffer |
5b5afd50 | 179 | ;; The working revision is always the latest revision number. |
8bfde4be AS |
180 | ;; To find this number, search the entire delta table, |
181 | ;; rather than just the first entry, because the | |
5b5afd50 | 182 | ;; first entry might be a deleted ("R") revision. |
8bfde4be | 183 | (vc-insert-file (vc-name file) "^\001e\n\001[^s]") |
7a004b71 GM |
184 | (vc-parse-buffer "^\001d D \\([^ ]+\\)" 1))) |
185 | ||
7a004b71 | 186 | (defun vc-sccs-workfile-unchanged-p (file) |
fa63cb6d | 187 | "SCCS-specific implementation of `vc-workfile-unchanged-p'." |
2888a97e | 188 | (zerop (apply 'vc-do-command "*vc*" 1 "vcdiff" (vc-name file) |
a1e9f194 | 189 | (list "--brief" "-q" |
ac3f4c6f | 190 | (concat "-r" (vc-working-revision file)))))) |
7a004b71 | 191 | |
7a004b71 | 192 | \f |
8f98485f AS |
193 | ;;; |
194 | ;;; State-changing functions | |
195 | ;;; | |
7a004b71 | 196 | |
14b11401 SM |
197 | (defun vc-sccs-do-command (buffer okstatus command file-or-list &rest flags) |
198 | ;; (let ((load-path (append vc-sccs-path load-path))) | |
199 | ;; (apply 'vc-do-command buffer okstatus command file-or-list flags)) | |
2888a97e | 200 | (apply 'vc-do-command (or buffer "*vc*") okstatus "sccs" file-or-list command flags)) |
14b11401 | 201 | |
8cdd17b4 ER |
202 | (defun vc-sccs-create-repo () |
203 | "Create a new SCCS repository." | |
204 | ;; SCCS is totally file-oriented, so all we have to do is make the directory | |
205 | (make-directory "SCCS")) | |
206 | ||
207 | (defun vc-sccs-register (files &optional rev comment) | |
208 | "Register FILES into the SCCS version-control system. | |
7a004b71 | 209 | REV is the optional revision number for the file. COMMENT can be used |
8cdd17b4 | 210 | to provide an initial description of FILES. |
12fcd25a GM |
211 | Passes either `vc-sccs-register-switches' or `vc-register-switches' |
212 | to the SCCS command. | |
7a004b71 | 213 | |
8cdd17b4 | 214 | Automatically retrieve a read-only version of the files with keywords |
7a004b71 | 215 | expanded if `vc-keep-workfiles' is non-nil, otherwise, delete the workfile." |
8cdd17b4 | 216 | (dolist (file files) |
dc0f87c9 | 217 | (let* ((dirname (or (file-name-directory file) "")) |
7a004b71 GM |
218 | (basename (file-name-nondirectory file)) |
219 | (project-file (vc-sccs-search-project-dir dirname basename))) | |
220 | (let ((vc-name | |
221 | (or project-file | |
dc0f87c9 | 222 | (format (car vc-sccs-master-templates) dirname basename)))) |
14b11401 | 223 | (apply 'vc-sccs-do-command nil 0 "admin" vc-name |
8cdd17b4 | 224 | (and rev (not (string= rev "")) (concat "-r" rev)) |
7a004b71 | 225 | "-fb" |
0cccd8ff | 226 | (concat "-i" (file-relative-name file)) |
7a004b71 | 227 | (and comment (concat "-y" comment)) |
dc0f87c9 | 228 | (vc-switches 'SCCS 'register))) |
7a004b71 GM |
229 | (delete-file file) |
230 | (if vc-keep-workfiles | |
14b11401 | 231 | (vc-sccs-do-command nil 0 "get" (vc-name file)))))) |
7a004b71 | 232 | |
8f98485f AS |
233 | (defun vc-sccs-responsible-p (file) |
234 | "Return non-nil if SCCS thinks it would be responsible for registering FILE." | |
235 | ;; TODO: check for all the patterns in vc-sccs-master-templates | |
236 | (or (file-directory-p (expand-file-name "SCCS" (file-name-directory file))) | |
237 | (stringp (vc-sccs-search-project-dir (or (file-name-directory file) "") | |
238 | (file-name-nondirectory file))))) | |
239 | ||
4624de78 | 240 | (defun vc-sccs-checkin (files rev comment) |
8f98485f | 241 | "SCCS-specific version of `vc-backend-checkin'." |
e7290559 | 242 | (dolist (file (vc-expand-dirs files)) |
14b11401 | 243 | (apply 'vc-sccs-do-command nil 0 "delta" (vc-name file) |
8cdd17b4 ER |
244 | (if rev (concat "-r" rev)) |
245 | (concat "-y" comment) | |
246 | (vc-switches 'SCCS 'checkin)) | |
247 | (if vc-keep-workfiles | |
14b11401 | 248 | (vc-sccs-do-command nil 0 "get" (vc-name file))))) |
8f98485f | 249 | |
ac3f4c6f | 250 | (defun vc-sccs-find-revision (file rev buffer) |
14b11401 | 251 | (apply 'vc-sccs-do-command |
52876673 SM |
252 | buffer 0 "get" (vc-name file) |
253 | "-s" ;; suppress diagnostic output | |
254 | "-p" | |
255 | (and rev | |
256 | (concat "-r" | |
257 | (vc-sccs-lookup-triple file rev))) | |
dc0f87c9 | 258 | (vc-switches 'SCCS 'checkout))) |
52876673 SM |
259 | |
260 | (defun vc-sccs-checkout (file &optional editable rev) | |
5b5afd50 | 261 | "Retrieve a copy of a saved revision of SCCS controlled FILE. |
e7290559 | 262 | If FILE is a directory, all version-controlled files beneath are checked out. |
1862f9ef | 263 | EDITABLE non-nil means that the file should be writable and |
52876673 | 264 | locked. REV is the revision to check out." |
a2a413ad | 265 | (if (file-directory-p file) |
e7290559 ER |
266 | (mapc 'vc-sccs-checkout (vc-expand-dirs (list file))) |
267 | (let ((file-buffer (get-file-buffer file)) | |
268 | switches) | |
269 | (message "Checking out %s..." file) | |
270 | (save-excursion | |
271 | ;; Change buffers to get local value of vc-checkout-switches. | |
272 | (if file-buffer (set-buffer file-buffer)) | |
273 | (setq switches (vc-switches 'SCCS 'checkout)) | |
274 | ;; Save this buffer's default-directory | |
275 | ;; and use save-excursion to make sure it is restored | |
276 | ;; in the same buffer it was saved in. | |
277 | (let ((default-directory default-directory)) | |
278 | (save-excursion | |
279 | ;; Adjust the default-directory so that the check-out creates | |
280 | ;; the file in the right place. | |
281 | (setq default-directory (file-name-directory file)) | |
282 | ||
283 | (and rev (or (string= rev "") | |
284 | (not (stringp rev))) | |
285 | (setq rev nil)) | |
286 | (apply 'vc-sccs-do-command nil 0 "get" (vc-name file) | |
287 | (if editable "-e") | |
288 | (and rev (concat "-r" (vc-sccs-lookup-triple file rev))) | |
289 | switches)))) | |
290 | (message "Checking out %s...done" file)))) | |
7a004b71 | 291 | |
5b5afd50 | 292 | (defun vc-sccs-rollback (files) |
e7290559 ER |
293 | "Roll back, undoing the most recent checkins of FILES. Directories |
294 | are expanded to all version-controlled subfiles." | |
295 | (setq files (vc-expand-dirs files)) | |
8cdd17b4 | 296 | (if (not files) |
5a0c3f56 | 297 | (error "SCCS backend doesn't support directory-level rollback")) |
8cdd17b4 | 298 | (dolist (file files) |
ac3f4c6f | 299 | (let ((discard (vc-working-revision file))) |
a2a413ad | 300 | (if (null (yes-or-no-p (format "Remove version %s from %s history? " |
8cdd17b4 ER |
301 | discard file))) |
302 | (error "Aborted")) | |
303 | (message "Removing revision %s from %s..." discard file) | |
14b11401 SM |
304 | (vc-sccs-do-command nil 0 "rmdel" |
305 | (vc-name file) (concat "-r" discard)) | |
306 | (vc-sccs-do-command nil 0 "get" (vc-name file) nil)))) | |
8cdd17b4 | 307 | |
99739bbf | 308 | (defun vc-sccs-revert (file &optional contents-done) |
e7290559 ER |
309 | "Revert FILE to the version it was based on. If FILE is a directory, |
310 | revert all subfiles." | |
a2a413ad | 311 | (if (file-directory-p file) |
e7290559 ER |
312 | (mapc 'vc-sccs-revert (vc-expand-dirs (list file))) |
313 | (vc-sccs-do-command nil 0 "unget" (vc-name file)) | |
314 | (vc-sccs-do-command nil 0 "get" (vc-name file)) | |
315 | ;; Checking out explicit revisions is not supported under SCCS, yet. | |
316 | ;; We always "revert" to the latest revision; therefore | |
317 | ;; vc-working-revision is cleared here so that it gets recomputed. | |
318 | (vc-file-setprop file 'vc-working-revision nil))) | |
8f98485f | 319 | |
8f98485f AS |
320 | (defun vc-sccs-steal-lock (file &optional rev) |
321 | "Steal the lock on the current workfile for FILE and revision REV." | |
a2a413ad | 322 | (if (file-directory-p file) |
e7290559 ER |
323 | (mapc 'vc-sccs-steal-lock (vc-expand-dirs (list file))) |
324 | (vc-sccs-do-command nil 0 "unget" | |
325 | (vc-name file) "-n" (if rev (concat "-r" rev))) | |
326 | (vc-sccs-do-command nil 0 "get" | |
327 | (vc-name file) "-g" (if rev (concat "-r" rev))))) | |
8f98485f | 328 | |
9b64a7f0 ER |
329 | (defun vc-sccs-modify-change-comment (files rev comment) |
330 | "Modify (actually, append to) the change comments for FILES on a specified REV." | |
e7290559 | 331 | (dolist (file (vc-expand-dirs files)) |
a2a413ad | 332 | (vc-sccs-do-command nil 0 "cdc" (vc-name file) |
14b11401 | 333 | (concat "-y" comment) (concat "-r" rev)))) |
9b64a7f0 | 334 | |
8f98485f AS |
335 | \f |
336 | ;;; | |
337 | ;;; History functions | |
338 | ;;; | |
339 | ||
662c5698 | 340 | (defun vc-sccs-print-log (files buffer &optional shortlog start-revision-ignored limit) |
8cdd17b4 | 341 | "Get change log associated with FILES." |
e7290559 | 342 | (setq files (vc-expand-dirs files)) |
48b27575 DN |
343 | (vc-sccs-do-command buffer 0 "prs" (mapcar 'vc-name files)) |
344 | (when limit 'limit-unsupported)) | |
8cdd17b4 | 345 | |
8cdd17b4 ER |
346 | (defun vc-sccs-diff (files &optional oldvers newvers buffer) |
347 | "Get a difference report using SCCS between two filesets." | |
e7290559 | 348 | (setq files (vc-expand-dirs files)) |
e46e905a GM |
349 | (setq oldvers (vc-sccs-lookup-triple (car files) oldvers)) |
350 | (setq newvers (vc-sccs-lookup-triple (car files) newvers)) | |
59465d84 | 351 | (apply 'vc-do-command (or buffer "*vc-diff*") |
8cdd17b4 | 352 | 1 "vcdiff" (mapcar 'vc-name (vc-expand-dirs files)) |
a1e9f194 AS |
353 | (append (list "-q" |
354 | (and oldvers (concat "-r" oldvers)) | |
355 | (and newvers (concat "-r" newvers))) | |
dc0f87c9 | 356 | (vc-switches 'SCCS 'diff)))) |
8f98485f AS |
357 | |
358 | \f | |
359 | ;;; | |
370fded4 ER |
360 | ;;; Tag system. SCCS doesn't have tags, so we simulate them by maintaining |
361 | ;;; our own set of name-to-revision mappings. | |
8f98485f AS |
362 | ;;; |
363 | ||
370fded4 ER |
364 | (defun vc-sccs-create-tag (backend dir name branchp) |
365 | (when branchp | |
a2a413ad | 366 | (error "SCCS backend %s does not support module branches" backend)) |
370fded4 ER |
367 | (let ((result (vc-tag-precondition dir))) |
368 | (if (stringp result) | |
369 | (error "File %s is not up-to-date" result) | |
370 | (vc-file-tree-walk | |
371 | dir | |
372 | (lambda (f) | |
373 | (vc-sccs-add-triple name f (vc-working-revision f))))))) | |
8f98485f AS |
374 | |
375 | \f | |
376 | ;;; | |
377 | ;;; Miscellaneous | |
378 | ;;; | |
379 | ||
3b64d86b DN |
380 | (defun vc-sccs-previous-revision (file rev) |
381 | (vc-call-backend 'RCS 'previous-revision file rev)) | |
382 | ||
383 | (defun vc-sccs-next-revision (file rev) | |
384 | (vc-call-backend 'RCS 'next-revision file rev)) | |
385 | ||
8f98485f AS |
386 | (defun vc-sccs-check-headers () |
387 | "Check if the current file has any headers in it." | |
388 | (save-excursion | |
389 | (goto-char (point-min)) | |
390 | (re-search-forward "%[A-Z]%" nil t))) | |
391 | ||
392 | (defun vc-sccs-rename-file (old new) | |
393 | ;; Move the master file (using vc-rcs-master-templates). | |
394 | (vc-rename-master (vc-name old) new vc-sccs-master-templates) | |
370fded4 | 395 | ;; Update the tag file. |
8f98485f AS |
396 | (with-current-buffer |
397 | (find-file-noselect | |
398 | (expand-file-name vc-sccs-name-assoc-file | |
399 | (file-name-directory (vc-name old)))) | |
400 | (goto-char (point-min)) | |
401 | ;; (replace-regexp (concat ":" (regexp-quote old) "$") (concat ":" new)) | |
402 | (while (re-search-forward (concat ":" (regexp-quote old) "$") nil t) | |
403 | (replace-match (concat ":" new) nil nil)) | |
404 | (basic-save-buffer) | |
405 | (kill-buffer (current-buffer)))) | |
406 | ||
77bf3f54 DN |
407 | (defun vc-sccs-find-file-hook () |
408 | ;; If the file is locked by some other user, make | |
409 | ;; the buffer read-only. Like this, even root | |
410 | ;; cannot modify a file that someone else has locked. | |
d56fdcd2 DN |
411 | (and (stringp (vc-state buffer-file-name 'SCCS)) |
412 | (setq buffer-read-only t))) | |
77bf3f54 | 413 | |
8f98485f AS |
414 | \f |
415 | ;;; | |
416 | ;;; Internal functions | |
417 | ;;; | |
418 | ||
419 | ;; This function is wrapped with `progn' so that the autoload cookie | |
420 | ;; copies the whole function itself into loaddefs.el rather than just placing | |
421 | ;; a (autoload 'vc-sccs-search-project-dir "vc-sccs") which would not | |
422 | ;; help us avoid loading vc-sccs. | |
423 | ;;;###autoload | |
424 | (progn (defun vc-sccs-search-project-dir (dirname basename) | |
425 | "Return the name of a master file in the SCCS project directory. | |
426 | Does not check whether the file exists but returns nil if it does not | |
427 | find any project directory." | |
428 | (let ((project-dir (getenv "PROJECTDIR")) dirs dir) | |
429 | (when project-dir | |
430 | (if (file-name-absolute-p project-dir) | |
431 | (setq dirs '("SCCS" "")) | |
432 | (setq dirs '("src/SCCS" "src" "source/SCCS" "source")) | |
433 | (setq project-dir (expand-file-name (concat "~" project-dir)))) | |
434 | (while (and (not dir) dirs) | |
435 | (setq dir (expand-file-name (car dirs) project-dir)) | |
436 | (unless (file-directory-p dir) | |
437 | (setq dir nil) | |
438 | (setq dirs (cdr dirs)))) | |
439 | (and dir (expand-file-name (concat "s." basename) dir)))))) | |
440 | ||
441 | (defun vc-sccs-lock-file (file) | |
442 | "Generate lock file name corresponding to FILE." | |
443 | (let ((master (vc-name file))) | |
444 | (and | |
445 | master | |
446 | (string-match "\\(.*/\\)\\(s\\.\\)\\(.*\\)" master) | |
447 | (replace-match "p." t t master 2)))) | |
448 | ||
449 | (defun vc-sccs-parse-locks () | |
450 | "Parse SCCS locks in current buffer. | |
5b5afd50 | 451 | The result is a list of the form ((REVISION . USER) (REVISION . USER) ...)." |
8f98485f AS |
452 | (let (master-locks) |
453 | (goto-char (point-min)) | |
454 | (while (re-search-forward "^\\([0-9.]+\\) [0-9.]+ \\([^ ]+\\) .*\n?" | |
455 | nil t) | |
456 | (setq master-locks | |
457 | (cons (cons (match-string 1) (match-string 2)) master-locks))) | |
458 | ;; FIXME: is it really necessary to reverse ? | |
459 | (nreverse master-locks))) | |
460 | ||
461 | (defun vc-sccs-add-triple (name file rev) | |
462 | (with-current-buffer | |
463 | (find-file-noselect | |
464 | (expand-file-name vc-sccs-name-assoc-file | |
465 | (file-name-directory (vc-name file)))) | |
466 | (goto-char (point-max)) | |
467 | (insert name "\t:\t" file "\t" rev "\n") | |
468 | (basic-save-buffer) | |
469 | (kill-buffer (current-buffer)))) | |
470 | ||
471 | (defun vc-sccs-lookup-triple (file name) | |
370fded4 | 472 | "Return the numeric revision corresponding to a named tag of FILE. |
5b5afd50 | 473 | If NAME is nil or a revision number string it's just passed through." |
8f98485f AS |
474 | (if (or (null name) |
475 | (let ((firstchar (aref name 0))) | |
476 | (and (>= firstchar ?0) (<= firstchar ?9)))) | |
477 | name | |
478 | (with-temp-buffer | |
479 | (vc-insert-file | |
480 | (expand-file-name vc-sccs-name-assoc-file | |
481 | (file-name-directory (vc-name file)))) | |
482 | (vc-parse-buffer (concat name "\t:\t" file "\t\\(.+\\)") 1)))) | |
7a004b71 GM |
483 | |
484 | (provide 'vc-sccs) | |
485 | ||
fa63cb6d | 486 | ;; arch-tag: d751dee3-d7b3-47e1-95e3-7ae98c052041 |
7a004b71 | 487 | ;;; vc-sccs.el ends here |