annotate lisp/packages/generic-sc.el @ 52:461c7ba8286a r19-16-pre1

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