annotate lisp/packages/generic-sc.el @ 2:ac2d302a0011 r19-15b2

Import from CVS: tag r19-15b2
author cvs
date Mon, 13 Aug 2007 08:46:35 +0200
parents 376386a54a3c
children 0293115a14e9
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 ;;; generic-sc.el --- generic interface to source control systems
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 ;; Author: devin@lucid.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Keywords: tools, unix
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;;; Synched up with: Not in FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; The generic interface provide a common set of functions that can be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;; used to interface with a source control system like SCCS, RCS or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;; CVS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; You chose which source control system to use by calling sc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; The module is based on the sccs.el mode of Eric S. Raymond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; (eric@snark.thyrsus.com) which was distantly derived from an rcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; mode written by Ed Simpson ({decvax, seismo}!mcnc!duke!dukecdu!evs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; in years gone by and revised at MIT's Project Athena.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;;; This can be customized by the user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 (defvar sc-diff-command '("diff")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 "*The command/flags list to be used in constructing diff commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; Duplicated from pcl-cvs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 (defvar cvs-program "cvs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 "*The command name of the cvs program.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 (defvar sc-mode-expert ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 "*Treat user as expert; suppress yes-no prompts on some things.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 (defvar sc-max-log-size 510
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 "*Maximum allowable size of a source control log message.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 (defvar sc-ccase-comment-on '(checkout checkout-dir checkin-dir rename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 new-brtype new-branch checkin-merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 create-label label-sources)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 "*Operations on which comments would be appreciated.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 We check the values checkout, checkout-dir, checkin-dir,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 rename, new-brtype, new-branch, create-label,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 and label-sources as symbols.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 (defvar sc-ccase-reserve nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 "Whether to reserve checkouts or not. By default, this is nil - don't.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 Other values are t - do, and anything else, eg. 'ask - ask.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; default keybindings
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 (defvar sc-prefix-map (lookup-key global-map "\C-xv"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 (if (not (keymapp sc-prefix-map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 (setq sc-prefix-map (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 (define-key global-map "\C-xv" sc-prefix-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 (define-key sc-prefix-map "v" 'sc-next-operation)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 (define-key sc-prefix-map "=" 'sc-show-changes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 (define-key sc-prefix-map "l" 'sc-show-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 (define-key sc-prefix-map "p" 'sc-visit-previous-revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 (define-key sc-prefix-map "u" 'sc-revert-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (define-key sc-prefix-map "d" 'sc-list-registered-files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 (define-key sc-prefix-map "\C-d" 'sc-update-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (define-key sc-prefix-map "\C-r" 'sc-rename-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;;; The user does not change these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (defvar sc-generic-name ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 "Name of the source control system used. Is displayed in the modeline.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 (defvar sc-mode-line-string ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 "Revision number to show in the mode line")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar sc-generic-log-buf ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "Buffer for entering log message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defvar sc-log-entry-keymap ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "Additional keybindings used when entering the log message")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 (defvar sc-can-hack-dir ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 "Does the SC system allow users to play directly with directories")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defvar sc-ccase-mfs-prefixes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "Prefixes known to the system to be MFS ... ignore all others")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 (defmacro sc-chmod (perms file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (list 'call-process "chmod" nil nil nil perms file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defmacro error-occurred (&rest body)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 (list 'condition-case nil (cons 'progn (append body '(nil))) '(error t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;;; User level functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (defun sc-next-operation (verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 "Do the next logical source-control operation on the file in the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 The current subdirectory must be under source control.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 If the file is not already registered with the source control, this registers it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 and checks it out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112 If the file is registered and not locked by anyone, this checks it out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 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
114 buffer for creation of a log message, then checks the file in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 A read-only copy of the changed file is left in place afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 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
117 returned indicating who has locked it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 (if (not buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 (error "There is no file associated with buffer %s" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 (let* (revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 (lock-info (sc-lock-info file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 (sc-generic-log-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 (get-buffer-create (format "*%s-Log*" sc-generic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 (err-msg nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 (if (eq lock-info 'na)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 (error "The file associated with buffer %s is not registered" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; if file is not registered register it and set lock-info to show it's not locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 (if (not lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 (sc-register-file verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134 (setq lock-info (list () ()))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 (cond ((not (car lock-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 ;; if there is no lock on the file, assert one and get it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 (sc-check-out file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (sc-mode-line))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 ((and (not (equal sc-generic-name "CCase"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 (not (equal (car lock-info) (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 ;; file is locked by someone else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 (error "Sorry, %s has that file locked." (car lock-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 ;; OK, user owns the lock on the file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 ;; if so, give user a chance to save before delta-ing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 sc-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 (setq revision (car (cdr lock-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 ;; user may want to set nonstandard parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 (if verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (if (or sc-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (y-or-n-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (format "revision: %s Change revision level? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 (setq revision (read-string "New revision level: "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; OK, let's do the delta
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (let ((buffer (sc-temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (if (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 ;; this excursion returns t if the new version was saved OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (pop-to-buffer 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 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (sc-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 "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
177 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178 (and (not (error-occurred (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (not (error-occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (sc-check-in file revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (buffer-string)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 (bury-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 ;; if the save went OK do some post-checking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 "Checked-in version of file does not match buffer!")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 (sc-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (run-hooks 'sc-check-in-ok))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 (defun sc-insert-last-log ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 "Insert the log message of the last check in at point."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 (insert-buffer sc-generic-log-buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 (defun sc-abort-check-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "Abort a source control check-in command."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (if (or sc-mode-expert (y-or-n-p "Really Abort Check-in? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (abort-recursive-edit))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defun sc-log-exit ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "Proceed with checkin with the contents of the current buffer as message."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 (if (< (buffer-size) sc-max-log-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (copy-to-buffer sc-generic-log-buf (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (exit-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 (goto-char sc-max-log-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Log must be less than %d characters. Point is now at char %d."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 sc-max-log-size (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 ;;; Functions to look at the edit history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (defun sc-show-changes (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 "Compare the version being edited with the last checked-in revision.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 With a prefix argument prompt for revision to compare with."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 ;; check that the file is not modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 sc-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 (let* ((revision (and arg (read-string "Revision to compare against: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 (file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 (name (file-name-nondirectory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (old (sc-get-version-in-temp-file file revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (buffer (sc-temp-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (setq default-directory (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (setq status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (apply 'call-process (car sc-diff-command) () t ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 (append (cdr sc-diff-command) (list old) (list file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (if (not (or (eq 0 status) (eq 1 status))) ; see man diff.1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (display-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (error "diff FAILED")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 (delete-file old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (if (equal (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (format "No changes to %s since last update."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (insert "==== Diffs for " file "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (insert "==== ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (mapcar '(lambda (i) (insert i " ")) sc-diff-command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (insert name "<" (or revision "current") ">" " " name "\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (display-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (defun sc-show-revision-changes ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 "Prompt for a revision to diff against."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (sc-show-changes 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (defun sc-version-diff-file (file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 "For FILE, report diffs between two revisions REL1 and REL2 of it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 (interactive "fFile: \nsOlder version: \nsNewer version: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 (if (string-equal rel1 "") (setq rel1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if (string-equal rel2 "") (setq rel2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (let ((buffer (sc-temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 (let ((v1 (sc-get-version-in-temp-file file rel1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 (v2 (if rel2 (sc-get-version-in-temp-file file rel2) file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 (and v1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 v2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 (apply 'call-process (car sc-diff-command) nil t t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (append (cdr sc-diff-command) (list v1) (list v2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (condition-case () (delete-file v1) (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (if rel2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (condition-case () (delete-file v2) (error nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (if (equal (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (format "No changes to %s between %s and %s." file rel1 rel2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (display-buffer buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun sc-show-history ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "List the edit history of the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (if (not file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (error "There is no file associated with buffer %s" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (if (not (sc-lock-info file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (error "The file is not registered in the source control system"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (let ((buffer (sc-temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 (sc-history file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 (display-buffer buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 (defun sc-visit-previous-revision (revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 "Show a previous revision of the current file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 (interactive "sShow previous revision number: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (if (not file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (error "There is no file associated with buffer %s" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (let ((other-file (sc-get-version-in-temp-file file revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 (buffer-name (concat (file-name-nondirectory file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 "<" sc-generic-name " " revision ">")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (pop-to-buffer (get-buffer-create buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 (insert-file other-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 ;; get the same major mode as the original file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (setq buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 (normal-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 (setq buffer-file-name ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (set-buffer-modified-p ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (delete-file other-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (defun sc-revert-file ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 "Revert the current buffer's file back to the last saved version."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (if (y-or-n-p (format "Revert file %s to last checked-in revision?" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (sc-revert file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (sc-mode-line)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 ;; Functions to get directory level information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (defun sc-list-all-locked-files (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 "List all files currently locked under the revision control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 With prefix arg list only the files locked by the user."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (let* ((locker (and arg (user-login-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 (buffer (sc-tree-walk 'sc-list-file-if-locked locker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 (if (= (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (insert "No files locked ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (insert "Files locked "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (if locker
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (insert "by " locker " "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (insert "in " default-directory "\n\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (display-buffer buffer)))
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 sc-list-locked-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 "List all files currently locked by me"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (sc-list-all-locked-files 4))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (defun sc-list-registered-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 "List all files currently registered under the revision control system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (let ((buffer (sc-tree-walk 'sc-list-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (if (= (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (insert "No files registered in " sc-generic-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371 " in " default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (insert "Files registered in " sc-generic-name " in " default-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 "\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (display-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (defun sc-update-directory ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 "Updates the current directory by getting the latest copies of the files"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (save-some-buffers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (let ((buffer (sc-tree-walk 'sc-update-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (if (= (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (insert "No files needed to be updated in " default-directory "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (insert "Files updated in " default-directory "\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 (display-buffer buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 ;; Miscellaneous other entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun sc-register-file (verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "Register the file visited by the current buffer into source control.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Prefix argument register it under an explicit revision number."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (if (not file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (error "There is no file associated with buffer %s" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (let ((lock-info (sc-lock-info file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (revision ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (if lock-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (error "This file is already registered into %s" sc-generic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 ;; propose to save the file if it's modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 sc-mode-expert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 ;; get the revision number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (if verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 (setq revision (read-string "Initial Revision Number: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (sc-register file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (sc-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (defun sc-rename-file (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 "Rename a file, taking its source control archive with it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (interactive "fOld name: \nFNew name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (let ((owner (sc-locking-user old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (if (and owner (not (string-equal owner (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (error "Sorry, %s has that file checked out" owner)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (if sc-can-hack-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (rename-file old new t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (sc-rename old new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (defun sc-rename-this-file (new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 "Rename the file of the current buffer, taking its source control archive with it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (interactive "FNew name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (sc-rename-file buffer-file-name new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 (let ((old-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 (new-buffer (find-file-noselect new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 (set-window-buffer (selected-window) new-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (pop-to-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (bury-buffer old-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;;; Mode independent functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 ;;; All those sc-... functions FUNCALL the corresponding sc-generic-... function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ;;; The variables are set to functions that do the SCCS, RCS or CVS commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;;; depending on the mode chosen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (defvar sc-generic-lock-info ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 "Function to implement sc-lock-info")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (defun sc-lock-info (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 "Return a list of the current locker and current locked revision for FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 Returns NIL if FILE is not registered in the source control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 Return (NIL NIL) if FILE is registered but not locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 Return (locker revision) if file is locked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (funcall sc-generic-lock-info file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defvar sc-generic-register ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 "Function to implement sc-register")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 (defun sc-register (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 "Register FILE under source control with initial revision REVISION."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 (funcall sc-generic-register file revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defvar sc-generic-check-out ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 "Function to implement sc-check-out")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 (defun sc-check-out (file lockp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 "Checks out the latest version of FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 If LOCKP is not NIL, FILE is also locked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (funcall sc-generic-check-out file lockp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (defvar sc-generic-get-version ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 "Function to implement sc-get-version")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (defun sc-get-version (file buffer revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 "Insert a previous revison of FILE in BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 REVISION is the revision number requested."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (funcall sc-generic-get-version file buffer revision))
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 (defvar sc-generic-check-in ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 "Function to implement sc-check-in")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (defun sc-check-in (file revision message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 "Check in FILE with revision REVISION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 MESSAGE is a string describing the changes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 (funcall sc-generic-check-in file revision message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (defvar sc-generic-history ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 "Function to implement sc-history")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (defun sc-history (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 "Insert the edit history of FILE in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 (funcall sc-generic-history file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (defvar sc-generic-tree-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 "Function to implement sc-tree-list")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (defun sc-tree-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 "List in the current buffer the files registered in the source control system"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (funcall sc-generic-tree-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (defvar sc-generic-new-revision-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 "Function to implement sc-new-revision-p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (defun sc-new-revision-p (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 "True if a new revision of FILE was checked in since we last got a copy of it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (funcall sc-generic-new-revision-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defvar sc-generic-revert ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 "Function to implement sc-revert")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 (defun sc-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 "Cancel a check out of FILE and get back the latest checked in version"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (funcall sc-generic-revert file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (defvar sc-generic-rename ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 "Function to implement sc-rename")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (defun sc-rename (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 "Rename the source control archives for OLD to NEW"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 (funcall sc-generic-rename old new))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (defvar sc-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 "Menu to use")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 ;;; Utilities functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (defun sc-do-command (buffer message command file sc-file &rest flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 "Execute a command, notifying the user and checking for errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (message (format "Running %s on %s..." message file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (let ((status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (set-buffer (get-buffer-create buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (setq flags (append flags (and file (list sc-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (setq flags (delq () flags))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (let ((default-directory (file-name-directory (or file "./"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (eq (apply 'call-process command nil t nil flags) 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (if status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (message (format "Running %s...OK" message))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (insert command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 (mapcar '(lambda (i) (insert " " i)) flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 (insert "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (display-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (error (format "Running %s...FAILED" message)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (defun sc-enter-comment ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 "Enter a comment. Return it as a string."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (let ((buffer (sc-temp-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (setq sc-generic-log-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (get-buffer-create (format "*%s-Log*" sc-generic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 ;; this excursion returns t if the new version was saved OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (pop-to-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (sc-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 "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
575 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (and (not (error-occurred (recursive-edit)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (let ((bs (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (if (> (length bs) 0) bs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (bury-buffer buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 (defun sc-locking-user (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 "Return the login name of the locker of FILE. Return nil if FILE is not locked"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (car (sc-lock-info file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (defun sc-locked-revision (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 "Return the revision number currently locked for FILE, nil if FILE is not locked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 (car (cdr (sc-lock-info file))))
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 sc-mode-line ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 "Set the mode line for the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 FILE is the file being visited."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 (let* ((file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (lock-info (sc-lock-info file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 ;; ensure that the global mode string is not NIL
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (or global-mode-string (setq global-mode-string '("")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 ;; ensure that our variable is in the global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (or (memq 'sc-mode-line-string global-mode-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (setq global-mode-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (append global-mode-string '(sc-mode-line-string))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 (make-local-variable 'sc-mode-line-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 (setq sc-mode-line-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 (cond ((or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 (eq lock-info 'na)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 (null lock-info)) ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 ((null (car lock-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (format " <%s:>" sc-generic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ((equal (car lock-info) (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 (format " <%s: %s>" sc-generic-name (car (cdr lock-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 (format " <%s: %s>" sc-generic-name (car lock-info)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 (defun sc-temp-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 "Return a temporary buffer to use for output"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615 (get-buffer-create (format "*%s*" sc-generic-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 (defun sc-tree-walk (func &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 "Apply FUNC to the files registered in the source control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 FUNC is passed the file path and ARGS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 (let* ((buffer-name (format "*%s directory*" sc-generic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 (buffer (get-buffer-create buffer-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 (dir default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623 files)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 ;; recreate the directory buffer in the right directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (setq default-directory dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 ;; get a list of all the registered files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (sc-tree-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 ;; remove the "not found" messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 (while (search-forward "not found" () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (beginning-of-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (kill-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 ;; check if any file is listed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if (= (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (error "No registered files under %s" default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 ;; build the list of files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 (setq files ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642 (while (not (eobp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (let ((file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 (buffer-substring (point) (progn (end-of-line) (point)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (setq files (cons file files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 (forward-line 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 (setq files (nreverse files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;; let the function output information in the buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (erase-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 (display-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 ;; apply the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (while files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (apply func (car files) args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (setq files (cdr files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 buffer)))
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 sc-get-version-in-temp-file (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 "For the given FILE, retrieve a copy of the version with given REVISION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 The text is retrieved into a tempfile. Return the tempfile name."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (let* ((oldversion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (make-temp-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (concat (or (ccase-protect-expanded-name revision) "current")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 "-"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 (file-name-nondirectory file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 "-")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (vbuf (get-buffer-create oldversion)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (sc-get-version file vbuf revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 (set-buffer vbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (write-region (point-min) (point-max) oldversion t 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 (kill-buffer vbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 (sc-chmod "-w" oldversion)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 oldversion))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; Functions used to get directory level information
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (defun sc-insert-file-lock-info (file lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (insert (car lock-info) ":" (car (cdr lock-info)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (indent-to-column 16 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (insert (file-name-nondirectory file) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (defun sc-list-file-if-locked (file &optional arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 "List all files underneath the current directory matching a prefix type."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (let ((lock-info (sc-lock-info file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 (if (and lock-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 (car lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 (or (null arg) (equal arg (car lock-info))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 (sc-insert-file-lock-info file lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 (sit-for 0)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 (defun sc-list-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 (let ((lock-info (sc-lock-info file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (cond ((eq lock-info 'na)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
697 (indent-to-column 16 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
698 (insert (file-name-nondirectory file) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
699 ((car lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
700 (sc-insert-file-lock-info file lock-info))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 ((sc-new-revision-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (insert "needs update")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (indent-to-column 16 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (insert (file-name-nondirectory file) "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (indent-to-column 16 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (insert (file-name-nondirectory file) "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (sit-for 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 ;;; Function to update one file from the archive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (defun sc-update-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 "get the latest version of the file if a new one was checked-in"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (if (sc-new-revision-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (let ((file-name (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 ;; get the latest copy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (rename-file (sc-get-version-in-temp-file file nil) file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (let ((b (get-file-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (if b
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (set-buffer b)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (revert-buffer nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (sc-mode-line))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 ;; show the file was updated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (insert "updated")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 (indent-to-column 16 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 (insert file-name "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 (sit-for 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 ;; Set up key bindings for use while editing log messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 (if sc-log-entry-keymap
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (setq sc-log-entry-keymap (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 (define-key sc-log-entry-keymap "\C-ci" 'sc-insert-last-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 (define-key sc-log-entry-keymap "\C-c\C-i" 'sc-insert-last-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 (define-key sc-log-entry-keymap "\C-ca" 'sc-abort-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 (define-key sc-log-entry-keymap "\C-c\C-a" 'sc-abort-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 (define-key sc-log-entry-keymap "\C-c\C-c" 'sc-log-exit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 (define-key sc-log-entry-keymap "\C-x\C-s" 'sc-log-exit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (defvar sc-mode-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 "*Function or functions to run on entry to sc-mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 (defvar sc-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745 "The currently active source control mode. Use M-x sc-mode to set it")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (defun sc-mode (system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 "Toggle sc-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 SYSTEM can be sccs, rcs or cvs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 Cvs requires the pcl-cvs package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 The following commands are available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 \\[sc-next-operation] perform next logical source control operation on current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 \\[sc-show-changes] compare the version being edited with an older one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 \\[sc-version-diff-file] compare two older versions of a file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 \\[sc-show-history] display change history of current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 \\[sc-visit-previous-revision] display an older revision of current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 \\[sc-revert-file] revert buffer to last checked-in version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 \\[sc-list-all-locked-files] show all files locked in current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 \\[sc-list-locked-files] show all files locked by you in current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 \\[sc-list-registered-files] show all files under source control in current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 \\[sc-update-directory] get fresh copies of files checked-in by others in current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 \\[sc-rename-file] rename the current file and its source control file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 While you are entering a change log message for a check in, sc-log-entry-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 will be in effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770 Global user options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 sc-diff-command A list consisting of the command and flags
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 to be used for generating context diffs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 sc-mode-expert suppresses some conformation prompts,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 notably for delta aborts and file saves.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 sc-max-log-size specifies the maximum allowable size
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 of a log message plus one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 When using SCCS you have additional commands and options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 \\[sccs-insert-headers] insert source control headers in current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 When you generate headers into a buffer using \\[sccs-insert-headers],
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 the value of sc-insert-headers-hook is called before insertion. If the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 file is recognized a C or Lisp source, sc-insert-c-header-hook or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 sc-insert-lisp-header-hook is called after insertion respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 sccs-headers-wanted which %-keywords to insert when adding
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
789 headers with C-c h
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790 sccs-insert-static if non-nil, keywords inserted in C files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 get stuffed in a static string area so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 what(1) can see them in the compiled object code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 When using CVS you have additional commands
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 \\[sc-cvs-update-directory] update the current directory using pcl-cvs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 \\[sc-cvs-file-status] show the CVS status of current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (if sc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 '(())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (intern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (read-string "Turn on source control mode on for: " "SCCS")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (cond ((eq system ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 (remove-hook 'find-file-hooks 'sc-mode-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (delete-menu-item (list sc-generic-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 (remove-hook 'activate-menubar-hook 'sc-sensitize-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 (setq sc-mode ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (sc-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 (sc-mode ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (sc-mode system))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 (setq system (intern (upcase (symbol-name system))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 (let ((f (intern (format "sc-set-%s-mode" system))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (if (not (fboundp f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 "No source control interface for \"%s\". \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 Please use SCCS, RCS, CVS, or Atria."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 system)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (funcall f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (add-hook 'find-file-hooks 'sc-mode-line)
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
823 (add-submenu '() (cons sc-generic-name sc-menu))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (add-hook 'activate-menubar-hook 'sc-sensitize-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (run-hooks 'sc-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 (setq sc-mode system))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (defun sc-log-entry-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 "Major mode for editing log message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 These bindings are available when entering the log message
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 \\[sc-log-exit] proceed with check in, ending log message entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 \\[sc-insert-last-log] insert log message from last check-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 \\[sc-abort-check-in] abort this check-in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 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
837 the value sc-log-entry-mode-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (use-local-map sc-log-entry-keymap)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (setq major-mode 'sc-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (setq mode-name "Source Control Change Log Entry")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (run-hooks 'text-mode-hook 'sc-log-entry-mode-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 ;;; SCCS specific part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 ;; Find a reasonable default for the SCCS bin directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (defvar sccs-bin-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (cond ((file-executable-p "/usr/sccs/unget") "/usr/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ((file-executable-p "/usr/bin/unget") "/usr/bin")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ((file-directory-p "/usr/sccs") "/usr/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ((file-directory-p "/usr/bin/sccs") "/usr/bin/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (t "/usr/bin"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 "*Directory where to find the sccs executables")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (defvar sccs-headers-wanted '("\%\W\%")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 "*SCCS header keywords to be inserted when sccs-insert-header is executed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (defvar sccs-insert-static t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 "*Insert a static character string when inserting source control headers in C mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 Only relevant for the SCCS mode.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 ;; Vars the user doesn't need to know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 (defvar sccs-log-entry-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (defvar sccs-current-major-version nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 ;; Some helper functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (defun sccs-name (file &optional letter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 "Return the sccs-file name corresponding to a given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 (if (null file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (let ((expanded-file (expand-file-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (format "%sSCCS/%s.%s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880 (concat (file-name-directory expanded-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 (or letter "s")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882 (concat (file-name-nondirectory expanded-file))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 (defun sccs-lock-info (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 "Lock-info method for SCCS. See sc-generic-lock-info"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (let ((sccs-file (sccs-name file "s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (lock-file (sccs-name file "p")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (cond ((or (null file) (not (file-exists-p sccs-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 ((not (file-exists-p lock-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (list () ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 (set-buffer (get-buffer-create "*SCCS tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (insert-file lock-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (while (search-forward " " () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (replace-match "\n" () t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (let ((revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (buffer-substring (point) (progn (end-of-line) (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903 (progn (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (buffer-substring (point)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 (progn (end-of-line) (point))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (list name revision)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 (defun sccs-do-command (buffer command file &rest flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 "Execute an SCCS command, notifying the user and checking for errors."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (let ((exec-path (cons sccs-bin-directory exec-path)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (apply 'sc-do-command buffer command command file (sccs-name file) flags)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (defun sccs-admin (file sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 "Checks a file into sccs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 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
918 check it in under."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 ;; give a change to save the file if it's modified
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (y-or-n-p (format "%s has been modified. Write it out? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (save-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (sccs-do-command "*SCCS*" "admin" file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925 (concat "-i" file) (concat "-r" sid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (sc-chmod "-w" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 ;; expand SCCS headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (sccs-check-out file nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (defun sccs-register (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (sccs-load-vars)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (if (and (not (file-exists-p "SCCS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (y-or-n-p "Directory SCCS does not exist, create it?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (make-directory "SCCS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (sccs-admin file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (revision revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 ((error-occurred (load-file "SCCS/emacs-vars.el")) "1")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (t sccs-current-major-version))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941 (defun sccs-check-out (file lockp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 "Retrieve a copy of the latest version of the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943 (sccs-do-command "*SCCS*" "get" file (if lockp "-e")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (defun sccs-get-version (file buffer revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 (sccs-do-command buffer "get" file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 (and revision (concat "-r" revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 "-p" "-s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 (defun sccs-check-in (file revision comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 "Check-in a given version of the given file with the given comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (sccs-do-command "*SCCS*" "delta" file "-n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (format "-r%s" revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (format "-y%s" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (sc-chmod "-w" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 ;; sccs-delta already turned off write-privileges on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 ;; file, let's not re-fetch it unless there's something
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 ;; in it that get would expand
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 (let ((buffer (get-file-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (if buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (sccs-check-out file nil))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (defun sccs-history (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (sccs-do-command (current-buffer) "prs" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 ;; There has *got* to be a better way to do this...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 (defun sccs-save-vars (sid)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 (find-file "SCCS/emacs-vars.el")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 (insert "(setq sccs-current-major-version \"" sid "\")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 (basic-save-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (defun sccs-load-vars ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if (error-occurred (load-file "SCCS/emacs-vars.el"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (setq sccs-current-major-version "1")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 ;; SCCS header insertion code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (defun sccs-insert-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 "*Insert headers for use with the Source Code Control System.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986 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
987 the variable sccs-headers-wanted"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 (if (or (not (sccs-check-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (y-or-n-p "SCCS headers already exist. Insert another set?"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (run-hooks 'sccs-insert-headers-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (cond ((eq major-mode 'c-mode) (sccs-insert-c-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 ((eq major-mode 'lisp-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 ((eq major-mode 'emacs-lisp-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 ((eq major-mode 'scheme-mode) (sccs-insert-lisp-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 ((eq major-mode 'nroff-mode) (sccs-insert-nroff-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 ((eq major-mode 'plain-tex-mode) (sccs-insert-tex-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 ((eq major-mode 'texinfo-mode) (sccs-insert-texinfo-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (t (sccs-insert-generic-header))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (defun sccs-insert-c-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (let (st en)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (insert "/*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (insert " *\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (insert " */\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (if (and sccs-insert-static
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (not (string-match "\\.h$" buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 (insert "#ifndef lint\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 "static char *sccsid")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 ;; (setq st (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 ;; (insert (file-name-nondirectory buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 ;; (setq en (point))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 ;; (subst-char-in-region st en ?. ?_)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (insert " = \"\%\W\%\";\n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 "#endif /* lint */\n\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (run-hooks 'sccs-insert-c-header-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 (defun sccs-insert-lisp-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 (insert ";;;\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (run-hooks 'sccs-insert-lisp-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (defun sccs-insert-nroff-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (insert ".\\\"\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (run-hooks 'sccs-insert-nroff-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (defun sccs-insert-tex-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (insert "%%\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047 (run-hooks 'sccs-insert-tex-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049 (defun sccs-insert-texinfo-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (insert "@comment\t" s "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1054 (run-hooks 'sccs-insert-texinfo-header-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (defun sccs-insert-generic-header ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (let* ((comment-start-sccs (or comment-start "#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (comment-end-sccs (or comment-end ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (dont-insert-nl-p (string-match "\n" comment-end-sccs)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (mapcar '(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (insert comment-start-sccs "\t" s ""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 comment-end-sccs (if dont-insert-nl-p "" "\n")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 sccs-headers-wanted)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (insert comment-start-sccs comment-end-sccs (if dont-insert-nl-p "" "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (defun sccs-check-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 "Check if the current file has any SCCS headers in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 (let ((case-fold-search ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (re-search-forward "%[MIRLBSDHTEGUYFPQCZWA]%" (point-max) t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 (defun sccs-tree-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 "List all the registered files in the current directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (call-process "/bin/sh" () t () "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (concat "/bin/ls -1 " default-directory "SCCS/s.*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (while (search-forward "SCCS/s." () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (replace-match "" () t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 (defun sccs-new-revision-p (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 "True if the SCCS archive is more recent than the file itself"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083 (file-newer-than-file-p (sccs-name file) file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 (defun sccs-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086 "Cancel a check-out and get a fresh copy of the file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 (delete-file (sccs-name file "p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (sccs-do-command "*SCCS*" "get" file "-s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 (defun sccs-rename (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092 "Rename the SCCS archives for OLD to NEW"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (if (file-exists-p (sccs-name old "p"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (rename-file (sccs-name old "p") (sccs-name new "p") t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (if (file-exists-p (sccs-name old "s"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (rename-file (sccs-name old "s") (sccs-name new "s") t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 ;;; RCS specific part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 ;; Some helper functions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 (defun rcs-name (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 "Return the rcs-file corresponding to a given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (if (null file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107 (let* ((name (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (rcs-file (concat name ",v")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 (if (and (not (file-exists-p rcs-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 (file-exists-p (concat (file-name-directory name) "RCS")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 (setq rcs-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 (format "%sRCS/%s,v" (file-name-directory name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 (file-name-nondirectory name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 rcs-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 (defun rcs-lock-info (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 "Lock-info method for RCS. See sc-generic-lock-info"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 (let ((rcs-file (rcs-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 locks-regexp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (if (or (null rcs-file) (not (file-exists-p rcs-file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1123 (set-buffer (get-buffer-create "*RCS tmp*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1124 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (call-process "rlog" () t () "-L" "-h" rcs-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (if (looking-at "\n.*Working file")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 ;; RCS 4.x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (setq locks-regexp "^locks:")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 ;; RCS 5.x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (setq locks-regexp "^locks:.*$\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (if (not (re-search-forward locks-regexp () t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (list () ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (if (not (looking-at (concat "[\t ]*\\([^:]*\\): \\([0-9\\.]*\\)")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (list () ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 (list (buffer-substring (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137 (buffer-substring (match-beginning 2) (match-end 2)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 (defun rcs-register (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 (if (and (not (file-exists-p "RCS"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 (y-or-n-p "Directory RCS does not exist, create it?"))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
1143 (make-directory "RCS"))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144 (sc-do-command "*RCS*" "ci" "ci" file (rcs-name file) "-u"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 (defun rcs-check-out (file lockp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (sc-do-command "*RCS*" "co" "co" file (rcs-name file) (if lockp "-l")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (defun rcs-get-version (file buffer revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (sc-do-command buffer "co" "co" file (rcs-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 (if revision (concat "-p" revision) "-p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 "-q"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (defun rcs-check-in (file revision comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 "Check-in a given version of the given file with the given comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (sc-do-command "*RCS*" "ci" "ci" file (rcs-name file) "-f"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (format "-m%s" comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (if (equal revision (sc-locked-revision file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 "-u"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (format "-u%s" revision))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (defun rcs-history (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (sc-do-command (current-buffer) "rlog" "rlog" file (rcs-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 (defun rcs-tree-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 "List all the registered files in the current directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (call-process "/bin/sh" () t () "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (concat "/bin/ls -1 " default-directory "RCS/*,v"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (call-process "/bin/sh" () t () "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (concat "/bin/ls -1 " default-directory "*,v"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (while (search-forward "RCS/" () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (replace-match "" () t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (while (search-forward ",v" () t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (replace-match "" () t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (defun rcs-new-revision-p (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 "True if the archive is more recent than the file itself"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (file-newer-than-file-p (rcs-name file) file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (defun rcs-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 "Cancel a check-out and get a fresh copy of the file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (sc-do-command "*RCS*" "rcs" "rcs" file (rcs-name file) "-u")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (sc-do-command "*RCS*" "co" "co" file (rcs-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 (defun rcs-rename (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189 "Rename the archives for OLD to NEW"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (if (file-exists-p (rcs-name old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 (rename-file (rcs-name old) (rcs-name new) t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 ;;; CVS specific part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 ;;; As we rely on pcl-cvs for the directory level functions the menu is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 ;;; much shorter in CVS mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (defun cvs-lock-info (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 "Lock-info method for CVS, different from RCS and SCCS modes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 File are never locked in CVS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (list () ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 (defun cvs-register (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206 (sc-do-command "*CVS*" "cvs add" cvs-program file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 (file-name-nondirectory file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208 "add" "-mInitial revision"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (defun cvs-check-out (file lockp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (defun cvs-get-version (file buffer revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (sc-do-command buffer "cvs update" cvs-program file file "update"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (if revision (concat "-r" revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 "-p" "-q"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (defun cvs-check-in (file revision comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 "Check-in a given version of the given file with the given comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (sc-do-command "*CVS*" "cvs commit" cvs-program file file "commit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (and revision (format "-r%s" revision))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 (format "-m%s" comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (defun cvs-history (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (sc-do-command (current-buffer) "cvs log" cvs-program file file "log"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 (defun cvs-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228 "Cancel a check-out and get a fresh copy of the file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 (sc-do-command "*CVS*" "cvs update" cvs-program file file "update"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (defun sc-cvs-update-directory ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 "Update the current directory by calling cvs-update from pcl-cvs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 (cvs-update default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (defun sc-cvs-file-status ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 "Show the CVS status of the current file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 (if (not buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241 (error "There is no file associated with buffer %s" (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243 (sc-do-command "*CVS*" "cvs status" cvs-program file file "status" "-v"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 (set-buffer "*CVS*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 (goto-char (point-min)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (display-buffer "*CVS*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 ;;; ClearCase specific part
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 (defun ccase-is-registered-3 (fod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253 (if (or (not fod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 (not (file-readable-p fod)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 'na
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 (let ((dirs sc-ccase-mfs-prefixes)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 (f nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 (file (expand-file-name fod)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 (while (and (null f) dirs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (if (string-match (car dirs) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (setq f t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (setq dirs (cdr dirs))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (if (null f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 'na
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (sc-do-command "*CCase*" "describe" "cleartool" fod fod "describe")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (set-buffer "*CCase*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 (let ((s (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ((string-match "@@" s) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 ((string-match "^Unix" s) 'na)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 (t nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 )))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 (defun ccase-is-registered (fod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (eq (ccase-is-registered-3 fod) t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (defun ccase-lock-info (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (let ((cc (ccase-is-registered-3 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (if (eq cc 't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (set-buffer "*CCase*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 (setq s (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286 (if (string-match "@@[^\n]*CHECKEDOUT\" from \\([^ ]*\\)[^\n]*\n[^\n]* by \\([^(\n]*\\) (" s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288 (substring s (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 (substring s (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (list nil nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 cc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (defun ccase-maybe-comment (tag)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (if (memq tag sc-ccase-comment-on)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (sc-enter-comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (defun ccase-register (file revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 "Registers the file. We don't support the revision argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 Also, we have to checkout the directory first."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 ;; probably need proper error handling to catch the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 ;; cases where we co the directory, but don't get to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 ;; ci it back (want to uco in this case)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (let ((dpath (file-name-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (if (not (ccase-is-registered dpath))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (error "Cannot register file outside of VOB")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (sc-do-command "*CCase*" "co - dir" "cleartool" dpath dpath "co")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (sc-do-command "*CCase*" "register" "cleartool" file file "mkelem")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (sc-do-command "*CCase*" "ci - dir" "cleartool" dpath dpath "ci"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (defun ccase-check-out (file lockp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311 "Checks out the latest version of FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 If LOCKP is not NIL, FILE is also locked."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (let ((comment (ccase-maybe-comment 'checkout)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 (sc-do-command "*CCase*" "co" "cleartool" file file "co"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 (if comment comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 ;; this locking does not correspond to what we actually want. It's a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 ;; hack from the days when this was SCCS-only
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (if (ccase-reserve-p) "-res" "-unr"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (defun ccase-reserve-p ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 "Determine whether the user wants a reserved or unreserved checkout"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 ((eq sc-ccase-reserve t) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 ((eq sc-ccase-reserve nil) nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (t (y-or-n-p "Reserve Checkout? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (defun ccase-get-version (file buffer revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 "Insert a previous revison of FILE in BUFFER.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 REVISION is the revision number requested."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (delete-region (point-min) (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (insert-file-contents (concat file "@@/" revision)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 (defun ccase-check-in (file revision message)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 "Check in FILE with revision REVISION.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 MESSAGE is a string describing the changes."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 ;; we ignore revision since we can't use it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (sc-do-command "*CCase*" "ci" "cleartool" file file "ci" "-c" message (if sc-mode-expert "-ide"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (defun ccase-history (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 "Insert the edit history of FILE in the current buffer."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (sc-do-command (buffer-name) "history" "cleartool" file file "lsh")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 (defun ccase-tree-list ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 "List in the current buffer the files registered in the source control system"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 ;;; This isn't going to fly as a practicality. We abstract everything out.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 ;; (sc-do-command (buffer-name) "listing" "cleartool" (default-directory) (default-directory) "ls" "-r" "-short" "-vis" "-nxname")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (defun ccase-new-revision-p (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 "True if a new revision of FILE was checked in since we last got a copy of it"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 (let (pos newfile res br1 br2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360 (sc-do-command "*CCase*" "Describe" "cleartool" file file "des")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 (set-buffer "*CCase*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 (if (setq pos (search-forward-regexp "@@\\([^ \"]*\\)CHECKEDOUT\" from \\([^ ]*\\) (\\([a-z]*\\))" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 ;; (if (setq pos (search-forward-regexp "@@\\([^ \"]*\\)CHECKEDOUT\"" nil t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 (setq res (buffer-substring (match-beginning 3) (match-end 3)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 (if (equal res "unreserved")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 (setq newfile (concat file "@@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 "LATEST"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (setq br1 (buffer-substring (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (sc-do-command "*CCase*" "Describe" "cleartool" file newfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 "des")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (search-forward-regexp "@@\\([^ \"]*\\)" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (setq br2 (buffer-substring (match-beginning 1) (match-end 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (not (equal br1 br2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (error "%s not currently checked out" file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (defun ccase-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 "Cancel a check out of FILE and get back the latest checked in version"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (sc-do-command "*CCase*" "uco" "cleartool" file file "unco")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (defun ccase-rename (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 "Rename the source control archives for OLD to NEW"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (let ((dpath (file-name-directory old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (comment (ccase-maybe-comment 'rename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (if (not (ccase-is-registered dpath))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 (error "Cannot rename file outside of VOB")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (sc-do-command "*CCase*" "co - dir" "cleartool" dpath dpath "co"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (if comment comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (sc-do-command "*CCase*" "mv" "cleartool" new new "mv"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (if comment comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (sc-do-command "*CCase*" "ci - dir" "cleartool" dpath dpath "ci"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (if comment comment)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (defun sc-ccase-checkout-dir ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 "Checkout the directory this file is in"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (let ((dpath default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (comment (ccase-maybe-comment 'checkout-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (if (not (ccase-is-registered dpath))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 (error "Cannot checkout directory outside of VOB")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 (sc-do-command "*CCase*" "co - dir" "cleartool" dpath dpath "co"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (if comment comment)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (defun sc-ccase-checkin-dir ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 "Checkin the directory this file is in"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 (let ((dpath default-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (comment (ccase-maybe-comment 'checkin-dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (if (not (ccase-is-registered dpath))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 (error "Cannot checkout directory outside of VOB")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 (sc-do-command "*CCase*" "ci - dir" "cleartool" dpath dpath "ci"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 (if comment comment)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 (defun sc-ccase-editcs ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 "Edit Config Spec for this view"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 (sc-do-command "*CCase-cs*" "catcs" "cleartool" "" nil "catcs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1430 (switch-to-buffer-other-window "*CCase-cs*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1431 (local-set-key "\C-c\C-c" 'exit-recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1432 (recursive-edit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1433 (set-buffer "*CCase-cs*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1434 (let ((name (make-temp-name "/tmp/configspec")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (write-region (point-min) (point-max) name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 (kill-buffer "*CCase-cs*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 (sc-do-command "*CCase*" "setcs" "cleartool" name name "setcs"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 (defun sc-ccase-new-brtype (brt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 "Create a new branch type"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (interactive "sBranch Name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (let ((comment (ccase-maybe-comment 'new-brtype)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (sc-do-command "*CCase*" "mkbrt" "cleartool" brt brt "mkbrtype"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (if comment comment))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 (defun sc-ccase-new-branch (brch)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 "Create a new branch for element"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (interactive "sBranch: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (let ((file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (comment (ccase-maybe-comment 'new-branch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (sc-do-command "*CCase*" "mkbrch" "cleartool" file file "mkbranch"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (if comment comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 brch)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (defun sc-ccase-checkin-merge ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 "Merge in changes to enable checkin"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 (let ((file (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (comment (ccase-maybe-comment 'checkin-merge)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (sc-do-command "*CCase*" "Describe" "cleartool" file file "des")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (set-buffer "*CCase*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (if (search-forward-regexp "@@\\([^ \"]*\\)CHECKEDOUT\" from \\([^ ]*\\) (\\([a-z]*\\))" nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (sc-do-command "*CCase*" "Merging" "cleartool" file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (concat (buffer-substring (match-beginning 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (match-end 1)) "LATEST")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 "merge"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (if comment "-c" "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 (if comment comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 "-abort" "-to" file "-ver")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 (revert-buffer t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (display-buffer "*CCase*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (error "File %s not checked out" file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (defun sc-ccase-version-tree ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 "List version tree for file"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 (let ((p (buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 (sc-do-command "*CCase*" "lsvtree" "cleartool" p p "lsvtree")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487 (display-buffer "*CCase*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489 (defun ccase-protect-expanded-name (revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 "Protect ccase extended names from being used as temp names. Munge /s into :s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 (if (equal sc-generic-name "CCase")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493 (if (string-match "/" revision)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (let ((str (substring revision 0)) ;; copy string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 i)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 (while (setq i (string-match "/" str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 (aset str i 58)) ; 58 is for :
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 str)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 (defun sc-ccase-list-locked-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 (sc-do-command "*CCase directory*" "listing" "cleartool" (default-directory) nil "lsco" "-cview"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 (defun sc-ccase-list-all-locked-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 (sc-do-command "*CCase directory*" "listing" "cleartool" (default-directory) nil "lsco"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 (defun sc-ccase-list-registered-files ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 "List files registered in clearcase"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (sc-do-command "*CCase directory*" "listing" "cleartool" (default-directory) nil "ls" "-r" "-vis" "-nxname"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 ;;; Instantiation and installation of the menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 ;;; Set the menubar for Lucid Emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 (defvar sc-default-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 '(["NEXT-OPERATION" sc-next-operation t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 ["Update Current Directory" sc-update-directory t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 ["Revert File" sc-revert-file t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 ["Rename File" sc-rename-this-file t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 ["Show Changes" sc-show-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 ["Show Changes Since Revision..." sc-show-revision-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 ["Visit Previous Revision..." sc-visit-previous-revision t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 ["Show Edit History" sc-show-history t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ["List Locked Files" sc-list-locked-files t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 ["List Locked Files Any User" sc-list-all-locked-files t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 ["List Registered Files" sc-list-registered-files t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 "Menubar entry for using the revision control system.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 (defvar sc-cvs-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 '(["Update Current Directory" sc-cvs-update-directory t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ["Revert File" sc-revert-file t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 ["Show Changes" sc-show-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ["Show Changes Since Revision..." sc-show-revision-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 ["Visit Previous Revision..." sc-visit-previous-revision t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 ["Show File Status" sc-cvs-file-status t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 ["Show Edit History" sc-show-history t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 "Menubar entry for using the revision control system with CVS.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (defvar sc-ccase-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 '(["NEXT-OPERATION" sc-next-operation t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 ["Revert File" sc-revert-file t nil]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 ["Checkin Merge" sc-ccase-checkin-merge t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 ["Show Changes" sc-show-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 ["Show Changes Since Revision..." sc-show-revision-changes t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 ["Visit Previous Revision..." sc-visit-previous-revision t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 ["Show Edit History" sc-show-history t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 "----"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 ("Directories"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 ["Checkout Directory" sc-ccase-checkout-dir t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 ["Checkin Directory" sc-ccase-checkin-dir t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 ["Rename File..." sc-rename-this-file t nil])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558 ("Configs"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 ["Edit Config Spec..." sc-ccase-editcs t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ["Create New Branch..." sc-ccase-new-brtype t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 ["Make New Branch..." sc-ccase-new-branch t])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 ("Listings"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 ["List Version Tree" sc-ccase-version-tree t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 ["List Locked Files" sc-ccase-list-locked-files t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 ["List Locked Files Any User" sc-ccase-list-all-locked-files t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 ["List Registered Files" sc-ccase-list-registered-files t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 "Menubar entry for using the revision control system.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 (defun sc-sensitize-menu ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (let* ((rest (cdr (car
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (find-menu-item current-menubar (list sc-generic-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (case-fold-search t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 (file (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 (file-name-nondirectory buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577 (dir (file-name-directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (if buffer-file-name buffer-file-name default-directory)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 (lock-info (sc-lock-info buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 nested-rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (while rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (setq item (car rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (if (listp item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 (setq nested-rest (cons (cdr rest) nested-rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (setq rest (cdr item)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (if (vectorp item)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 (setq command (aref item 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (cond ((eq 'sc-next-operation command)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (aset item 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (cond ((eq lock-info 'na) "Not Available")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 ((not lock-info) "Register File")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 ((not (car lock-info)) "Check out File")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (t "Check in File")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ;; if locked by somebody else disable the next-operation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 (if (or (not buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 (eq lock-info 'na)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 (and (car lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 (not (equal sc-generic-name "CCase"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 (not (equal (car lock-info) (user-login-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 (aset item 2 ())
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 (aset item 2 t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ((eq lock-info 'na) (aset item 2 ()))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ((> (length item) 3)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 (aset item 3 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (t nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (if (not (eq lock-info 'na))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 (let ((enable-file-items
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 (if (member sc-generic-name '("CVS" "CCase"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (if lock-info t ()))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (if (memq command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 '(sc-force-check-in-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 sc-register-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618 sc-revert-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 sc-rename-this-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 sc-show-history
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 sc-show-changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 sc-show-revision-changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623 sc-visit-previous-revision
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 sc-cvs-file-status
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 sc-ccase-checkout-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 sc-ccase-checkin-dir
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 sc-ccase-editcs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628 sc-ccase-new-brtype
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 sc-ccase-new-branch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 sc-ccase-checkin-merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 sc-ccase-needs-merge
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 sc-ccase-merge-changes
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633 sc-ccase-create-label
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 sc-ccase-label-sources
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 sc-ccase-version-tree
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 sc-list-locked-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 sc-list-all-locked-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 sc-ccase-list-registered-files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640 (aset item 2 enable-file-items))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (if (not (setq rest (cdr rest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642 (if nested-rest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 (setq rest (car nested-rest))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 (setq nested-rest (cdr nested-rest)))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 ;;; Function to decide which Source control to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (defun sc-set-SCCS-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (setq sc-generic-name "SCCS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (setq sc-can-hack-dir t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (setq sc-generic-lock-info 'sccs-lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (setq sc-generic-register 'sccs-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 (setq sc-generic-check-out 'sccs-check-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656 (setq sc-generic-get-version 'sccs-get-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (setq sc-generic-check-in 'sccs-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 (setq sc-generic-history 'sccs-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (setq sc-generic-tree-list 'sccs-tree-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (setq sc-generic-new-revision-p 'sccs-new-revision-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 (setq sc-generic-revert 'sccs-revert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (setq sc-generic-rename 'sccs-rename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (setq sc-menu
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (cons (car sc-default-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 (cons ["Insert Headers" sccs-insert-headers t]
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (cdr sc-default-menu))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667 (define-key sc-prefix-map "h" 'sccs-insert-headers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668 (define-key sc-prefix-map "\C-d" 'sc-update-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 (defun sc-set-RCS-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 (setq sc-generic-name "RCS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 (setq sc-can-hack-dir t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 (setq sc-generic-lock-info 'rcs-lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 (setq sc-generic-register 'rcs-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 (setq sc-generic-check-out 'rcs-check-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 (setq sc-generic-get-version 'rcs-get-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 (setq sc-generic-check-in 'rcs-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (setq sc-generic-history 'rcs-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 (setq sc-generic-tree-list 'rcs-tree-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 (setq sc-generic-new-revision-p 'rcs-new-revision-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (setq sc-generic-revert 'rcs-revert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (setq sc-generic-rename 'rcs-rename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (setq sc-menu sc-default-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 (define-key sc-prefix-map "\C-d" 'sc-update-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 (defun sc-set-CVS-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 (require 'pcl-cvs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (setq sc-generic-name "CVS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (setq sc-can-hack-dir t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 (setq sc-generic-lock-info 'cvs-lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (setq sc-generic-register 'cvs-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (setq sc-generic-check-out 'cvs-check-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 (setq sc-generic-get-version 'cvs-get-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 (setq sc-generic-check-in 'cvs-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 (setq sc-generic-history 'cvs-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 (setq sc-generic-tree-list 'cvs-tree-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 (setq sc-generic-new-revision-p 'cvs-new-revision-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (setq sc-generic-revert 'cvs-revert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (setq sc-generic-rename 'cvs-rename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 (setq sc-menu sc-cvs-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 (define-key sc-prefix-map "\C-d" 'sc-cvs-update-directory)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 (define-key sc-prefix-map "s" 'sc-cvs-file-status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 (defun sc-set-CLEARCASE-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (setq sc-generic-name "CCase")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 (setq sc-can-hack-dir nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 (setq sc-generic-lock-info 'ccase-lock-info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 (setq sc-generic-register 'ccase-register)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 (setq sc-generic-check-out 'ccase-check-out)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 (setq sc-generic-get-version 'ccase-get-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 (setq sc-generic-check-in 'ccase-check-in)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 (setq sc-generic-history 'ccase-history)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (setq sc-generic-tree-list 'ccase-tree-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 (setq sc-generic-new-revision-p 'ccase-new-revision-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 (setq sc-generic-revert 'ccase-revert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 (setq sc-generic-rename 'ccase-rename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 (setq sc-menu sc-ccase-menu)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 ;; caching for file directory types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 (set-buffer (get-buffer-create "*CCase*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 (shell-command-on-region (point-min) (point-max) "df -t mfs | sed -n 's%.*[ ]\\(/[^ ]*\\)$%\\1%p'" t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (let (x l)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (while (condition-case nil (setq x (read (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 (error nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 (setq l (cons (prin1-to-string x) l)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 (setq sc-ccase-mfs-prefixes (nreverse l))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 (defun sc-set-ATRIA-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 (sc-set-CLEARCASE-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 (defun sc-set-CCASE-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735 (sc-set-CLEARCASE-mode))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 ;; the module is sucessfully loaded!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (provide 'generic-sc)