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