annotate lisp/packages/vc.el @ 30:ec9a17fef872 r19-15b98

Import from CVS: tag r19-15b98
author cvs
date Mon, 13 Aug 2007 08:52:29 +0200
parents 4103f0995bd7
children e04119814345
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 ;;; vc.el --- drive a version-control system from within Emacs
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 ;; Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 ;; Author: Eric S. Raymond <esr@snark.thyrsus.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Maintainer: ttn@netcom.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 ;; Version: 5.6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
23 ;; along with XEmacs; see the file COPYING. If not, write to the
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 6
diff changeset
25 ;; Boston, MA 02111-1307, USA.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 ;;; Synched up with: It's not clear at this point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; mly synched this with FSF at version 5.4. Stig did a whole lot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;; of stuff to it since then, and so has the FSF.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; This mode is fully documented in the Emacs user's manual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; This was designed and implemented by Eric Raymond <esr@snark.thyrsus.com>.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; Paul Eggert <eggert@twinsun.com>, Sebastian Kremer <sk@thp.uni-koeln.de>,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; and Richard Stallman contributed valuable criticism, support, and testing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; CVS support was added by Per Cederqvist <ceder@lysator.liu.se>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; in Jan-Feb 1994.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; XEmacs fixes, CVS fixes, and general improvements
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; by Jonathan Stigelman <Stig@hackvan.com>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;; Supported version-control systems presently include SCCS, RCS, and CVS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; The RCS lock-stealing code doesn't work right unless you use RCS 5.6.2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; or newer. Currently (January 1994) that is only a beta test release.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; Even initial checkins will fail if your RCS version is so old that ci
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; doesn't understand -t-; this has been known to happen to people running
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; NExTSTEP 3.0.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;; The RCS code assumes strict locking. You can support the RCS -x option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; by adding pairs to the vc-master-templates list.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; Proper function of the SCCS diff commands requires the shellscript vcdiff
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; to be installed somewhere on Emacs's path for executables.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; If your site uses the ChangeLog convention supported by Emacs, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; function vc-comment-to-change-log should prove a useful checkin hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; This code depends on call-process passing back the subprocess exit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; status. Thus, you need Emacs 18.58 or later to run it. For the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; vc-directory command to work properly as documented, you need 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;; You also need Emacs 19's ring.el.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; The vc code maintains some internal state in order to reduce expensive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; version-control operations to a minimum. Some names are only computed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;; once. If you perform version control operations with RCS/SCCS/CVS while
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; vc's back is turned, or move/rename master files while vc is running,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; vc may get seriously confused. Don't do these things!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; Developer's notes on some concurrency issues are included at the end of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 (require 'vc-hooks)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 (require 'ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 (eval-when-compile (require 'dired)) ; for dired-map-over-marks macro
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 (if (not (assoc 'vc-parent-buffer minor-mode-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 (setq minor-mode-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 (cons '(vc-parent-buffer vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 minor-mode-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; General customization
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 (defvar vc-default-back-end nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 "*Back-end actually used by this interface; may be SCCS or RCS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 The value is only computed when needed to avoid an expensive search.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 (defvar vc-suppress-confirm nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 "*If non-nil, treat user as expert; suppress yes-no prompts on some things.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 (defvar vc-keep-workfiles t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 "*If non-nil, don't delete working files after registering changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 If the back-end is CVS, workfiles are always kept, regardless of the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 value of this flag.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 (defvar vc-initial-comment nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 "*Prompt for initial comment when a file is registered.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98 (defvar vc-command-messages nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 "*Display run messages from back-end commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (defvar vc-mistrust-permissions 'file-symlink-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 "*Don't assume that permissions and ownership track version-control status.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 (defvar vc-checkin-switches nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 "*Extra switches passed to the checkin program by \\[vc-checkin].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 (defvar vc-checkout-switches nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 "*Extra switches passed to the checkout program by \\[vc-checkout].")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 (defvar vc-path
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 (if (file-exists-p "/usr/sccs")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 '("/usr/sccs") nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 "*List of extra directories to search for version control commands.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 (defvar vc-directory-exclusion-list '("SCCS" "RCS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 "*Directory names ignored by functions that recursively walk file trees.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 (defconst vc-maximum-comment-ring-size 32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 "Maximum number of saved comments in the comment ring.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;;; XEmacs - This is dumped into loaddefs.el already.
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
117 ;; Not any more! -sb
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
118 (defvar diff-switches "-c"
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
119 "*A string or list of strings specifying switches to be passed to diff.")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 (defvar vc-checkin-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 "*List of functions called after a checkin is done. See `run-hooks'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
125 ;;;###autoload
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
126 (defvar vc-before-checkin-hook nil
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
127 "*List of functions called before a checkin is done. See `run-hooks'.")
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
128
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 (defvar vc-make-buffer-writable-hook nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 "*List of functions called when a buffer is made writable. See `run-hooks.'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 This hook is only used when the version control system is CVS. It
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 might be useful for sites who uses locking with CVS, or who uses link
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 farms to gold trees.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; Header-insertion hair
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 (defvar vc-header-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 '((SCCS "\%W\%") (RCS "\$Id\$") (CVS "\$Id\$"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 "*Header keywords to be inserted when `vc-insert-headers' is executed.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 (defvar vc-static-header-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141 '(("\\.c$" .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 "\n#ifndef lint\nstatic char vcid[] = \"\%s\";\n#endif /* lint */\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 "*Associate static header string templates with file types. A \%s in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 template is replaced with the first string associated with the file's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 version-control type in `vc-header-alist'.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 (defvar vc-comment-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
148 '((nroff-mode ".\\\"" ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 "*Special comment delimiters to be used in generating vc headers only.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 Add an entry in this list if you need to override the normal comment-start
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151 and comment-end variables. This will only be necessary if the mode language
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 is sensitive to blank lines.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 ;; Default is to be extra careful for super-user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 (defvar vc-checkout-carefully (= (user-uid) 0) ; #### - this prevents preloading!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "*Non-nil means be extra-careful in checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 Verify that the file really is not locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 and that its contents match what the master file says.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 ;; Variables the user doesn't need to know about.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 (defvar vc-log-entry-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 (defvar vc-log-operation nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 (defvar vc-log-after-operation-hook nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 (defvar vc-checkout-writable-buffer-hook 'vc-checkout-writable-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 ;; In a log entry buffer, this is a local variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 ;; that points to the buffer for which it was made
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 ;; (either a file, or a VC dired buffer).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 (defvar vc-parent-buffer nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 (defvar vc-parent-buffer-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 (defvar vc-log-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 (defvar vc-log-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 (defconst vc-name-assoc-file "VC-names")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 (defvar vc-dired-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 (make-variable-buffer-local 'vc-dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 (defvar vc-comment-ring nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 (defvar vc-comment-ring-index nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181 (defvar vc-last-comment-match nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 ;; File property caching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 (defun vc-file-clearprops (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 ;; clear all properties of a given file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 (setplist (intern file vc-file-prop-obarray) nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 (defun vc-clear-context ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 "Clear all cached file properties and the comment ring."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
191 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192 (fillarray vc-file-prop-obarray nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 ;; Note: there is potential for minor lossage here if there is an open
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; log buffer with a nonzero local value of vc-comment-ring-index.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 (setq vc-comment-ring nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 ;; Random helper functions
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 vc-registration-error (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 (error "File %s is not under version control" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 (error "Buffer %s is not associated with a file" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defvar vc-binary-assoc nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 (defun vc-find-binary (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 "Look for a command anywhere on the subprocess-command search path."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 (or (cdr (assoc name vc-binary-assoc))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 ;; XEmacs - use locate-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (let ((full (locate-file name exec-path nil 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 (if full
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 (setq vc-binary-assoc (cons (cons name full) vc-binary-assoc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 full)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 (defun vc-do-command (okstatus command file last &rest flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216 "Execute a version-control command, notifying user and checking for errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 The command is successful if its exit status does not exceed OKSTATUS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 Output from COMMAND goes to buffer *vc*. The last argument of the command is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 the master name of FILE if LAST is 'MASTER, or the workfile of FILE if LAST is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 'WORKFILE; this is appended to an optional list of FLAGS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 (setq file (expand-file-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (let ((camefrom (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 (pwd (file-name-directory (expand-file-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 (squeezed nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (vc-file (and file (vc-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 ;;; #### - don't know why this code was here...to beautify the echo message?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 ;;; the version of code below doesn't break default-directory, but it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 ;;; still might mess up CVS and RCS because they like to operate on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 ;;; files in the current directory. --Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
232 ;;; (if (string-match (concat "^" (regexp-quote pwd)) file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
233 ;;; (setq file (substring file (match-end 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
234 ;;; (setq pwd (file-name-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (if vc-command-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (message "Running %s on %s..." command file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (set-buffer (get-buffer-create "*vc*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 (setq default-directory pwd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 file (file-name-nondirectory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 (set (make-local-variable 'vc-parent-buffer) camefrom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 (concat " from " (buffer-name camefrom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 (function (lambda (s) (and s (setq squeezed (append squeezed (list s))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
249 flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 (if (and vc-file (eq last 'MASTER))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (setq squeezed (append squeezed (list vc-file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (if (eq last 'WORKFILE)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq squeezed (append squeezed (list file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (let ((exec-path (if vc-path (append vc-path exec-path) exec-path))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 ;; Add vc-path to PATH for the execution of this command.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (process-environment (copy-sequence process-environment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 (setenv "PATH" (mapconcat 'identity exec-path ":"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (setq status (apply 'call-process command nil t nil squeezed)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 (set-buffer-modified-p nil) ; XEmacs - fsf uses `not-modified'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 (forward-line -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 (if (or (not (integerp status)) (< okstatus status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 (pop-to-buffer "*vc*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 (shrink-window-if-larger-than-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 (error "Running %s...FAILED (%s)" command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 (if (integerp status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 (format "status %d" status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 (if vc-command-messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 (message "Running %s...OK" command))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 (set-buffer camefrom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 status)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;;; Save a bit of the text around POSN in the current buffer, to help
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 ;;; us find the corresponding position again later. This works even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281 ;;; if all markers are destroyed or corrupted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 (defun vc-position-context (posn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 (list posn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (buffer-size)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285 (buffer-substring posn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 (min (point-max) (+ posn 100)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 ;;; Return the position of CONTEXT in the current buffer, or nil if we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 ;;; couldn't find it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 (defun vc-find-position-by-context (context)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 (let ((context-string (nth 2 context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 (if (equal "" context-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (point-max)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 (let ((diff (- (nth 1 context) (buffer-size))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (if (< diff 0) (setq diff (- diff)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (goto-char (nth 0 context))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 (if (or (search-forward context-string nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 ;; Can't use search-backward since the match may continue
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 ;; after point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301 (progn (goto-char (- (point) diff (length context-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; goto-char doesn't signal an error at
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 ;; beginning of buffer like backward-char would
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (search-forward context-string nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 ;; to beginning of OSTRING
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306 (- (point) (length context-string))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (defun vc-revert-buffer1 (&optional arg no-confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 ;; Most of this was shamelessly lifted from Sebastian Kremer's rcs.el mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; Revert buffer, try to keep point and mark where user expects them in spite
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; of changes because of expanded version-control key words.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; This is quite important since otherwise typeahead won't work as expected.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
315 (let ((point-context (vc-position-context (point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
316 ;; Use mark-marker to avoid confusion in transient-mark-mode.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 ;; XEmacs - mark-marker t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 (mark-context (if (eq (marker-buffer (mark-marker t)) (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (vc-position-context (mark-marker t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 ;; We may want to reparse the compilation buffer after revert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (reparse (and (boundp 'compilation-error-list) ;compile loaded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 ;; Construct a list; each elt is nil or a buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 ;; iff that buffer is a compilation output buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;; that contains markers into the current buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 (lambda (buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (set-buffer buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((errors (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 compilation-old-error-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 compilation-error-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 (buffer-error-marked-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (while (and (consp errors)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 (not buffer-error-marked-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (and (markerp (cdr (car errors)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 (eq buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 (marker-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (cdr (car errors))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (setq buffer-error-marked-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (setq errors (cdr errors)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (if buffer-error-marked-p buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (buffer-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 ;; The FSF version intentionally runs font-lock here. That
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 ;; usually just leads to a correctly font-locked buffer being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 ;; redone. #### We should detect the cases where the font-locking
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 ;; may be incorrect (such as on reverts). We know that it is fine
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 ;; during regular checkin and checkouts.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 ;; the actual revisit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (revert-buffer arg no-confirm)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 ;; Reparse affected compilation buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354 (while reparse
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (if (car reparse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (set-buffer (car reparse))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (let ((compilation-last-buffer (current-buffer)) ;select buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359 ;; Record the position in the compilation buffer of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360 ;; the last error next-error went to.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (error-pos (marker-position
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 (car (car-safe compilation-error-list)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 ;; Reparse the error messages as far as they were parsed before.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (compile-reinitialize-errors '(4) compilation-parsing-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 ;; Move the pointer up to find the error we were at before
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 ;; reparsing. Now next-error should properly go to the next one.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (while (and compilation-error-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (/= error-pos (car (car compilation-error-list))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 (setq compilation-error-list (cdr compilation-error-list))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 (setq reparse (cdr reparse)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 ;; Restore point and mark
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 (let ((new-point (vc-find-position-by-context point-context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 (if new-point (goto-char new-point)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (if mark-context
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (let ((new-mark (vc-find-position-by-context mark-context)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (if new-mark (set-mark new-mark))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 (defun vc-buffer-sync (&optional not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 ;; Make sure the current buffer and its working file are in sync
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 ;; NOT-URGENT means it is ok to continue if the user says not to save.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383 (if (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (if (or vc-suppress-confirm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 (y-or-n-p (format "Buffer %s modified; save it? " (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 (if not-urgent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (error "Aborted")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (defun vc-file-status ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 "Display the current status of the file being visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394 Currently, this is only defined for CVS. The information provided in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 modeline is generally sufficient for RCS and SCCS."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 ;; by Stig@hackvan.com
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 (vc-buffer-sync t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (let ((type (vc-backend-deduce buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 (file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401 (cond ((null type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (message "`%s' is not registered with a version control system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 (message "Buffer `%s' has no associated file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (buffer-name (current-buffer)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 ((eq 'CVS type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 (vc-do-command 0 "cvs" file 'WORKFILE "status" "-v")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (set-buffer "*vc*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ;; reparse the status information, since we have it handy...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 (vc-parse-buffer '("Status: \\(.*\\)") file '(vc-cvs-status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (shrink-window-if-larger-than-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (display-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 ((eq 'CC type)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 (vc-do-command 0 "cleartool" file 'WORKFILE "describe")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (set-buffer "*vc*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (shrink-window-if-larger-than-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (display-buffer (current-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 (ding)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 (message "Operation not yet defined for RCS or SCCS.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (defun vc-workfile-unchanged-p (file &optional want-differences-if-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 ;; Has the given workfile changed since last checkout?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 (cond ((and (eq 'CVS (vc-backend-deduce file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (not want-differences-if-changed))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (let ((status (vc-file-getprop file 'vc-cvs-status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; #### - should this have some kind of timeout? how often does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; this get called? possibly the cached information should be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;; flushed out of hand. The only concern is the VC menu, which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 ;; may indirectly call this function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (or status ; #### - caching is error-prone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (setq status (car (vc-log-info "cvs" file 'WORKFILE '("status")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 '("Status: \\(.*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 '(vc-cvs-status)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (string= status "Up-to-date")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 (let ((checkout-time (vc-file-getprop file 'vc-checkout-time))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (lastmod (nth 5 (file-attributes file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 unchanged)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (or (equal checkout-time lastmod)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 (and (or (not checkout-time) want-differences-if-changed)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450 (setq unchanged
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 (zerop (vc-backend-diff file nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 (not want-differences-if-changed))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 ;; 0 stands for an unknown time; it can't match any mod time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (vc-file-setprop file 'vc-checkout-time (if unchanged lastmod 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 unchanged))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457 (defun vc-next-action-on-file (file verbose &optional comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 ;;; If comment is specified, it will be used as an admin or checkin comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 (let ((vc-file (vc-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (vc-type (vc-backend-deduce file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461 owner version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 ;; if there is no master file corresponding, create one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 ((not vc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (vc-register verbose comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 ;; if there is no lock on the file, assert one and get it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 ((and (not (eq vc-type 'CVS)) ;There are no locks in CVS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (not (setq owner (vc-locking-user file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 (if (and vc-checkout-carefully
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 (not (vc-workfile-unchanged-p file t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (if (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 (pop-to-buffer "*vc*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (insert (format "Changes to %s since last lock:\n\n" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (not (beep))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 "File has unlocked changes, claim lock retaining changes? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (progn (vc-backend-steal file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 (vc-mode-line file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (if (not (yes-or-no-p "Revert to checked-in version, instead? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (error "Checkout aborted.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 (vc-revert-buffer1 t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (vc-checkout-writable-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 (vc-checkout-writable-buffer file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; a checked-out version exists, but the user may not own the lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ((and (not (eq vc-type 'CVS)) ;There are no locks in CVS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (not (string-equal owner (user-login-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (if comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (error "Sorry, you can't steal the lock on %s this way" file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (vc-steal-lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (and verbose (read-string "Version to steal: "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 owner))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; changes to the master file needs to be merged back into the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 ;; working file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 ((and (eq vc-type 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 ;; "0" means "added, but not yet committed"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 (not (string= (vc-file-getprop file 'vc-your-latest-version) "0"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (vc-fetch-properties file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 (not (string= (vc-file-getprop file 'vc-your-latest-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (vc-file-getprop file 'vc-latest-version)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (vc-buffer-sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (if (yes-or-no-p (format "%s is not up-to-date. Merge in changes now? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (buffer-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (if (and (buffer-modified-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (not (yes-or-no-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 "Buffer %s modified; merge file on disc anyhow? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 (buffer-name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (error "Merge aborted"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 (if (not (zerop (vc-backend-merge-news file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 ;; Overlaps detected - what now? Should use some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 ;; fancy RCS conflict resolving package, or maybe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 ;; emerge, but for now, simply warn the user with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 ;; message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (message "Conflicts detected!"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (vc-resynch-window file t (not (buffer-modified-p))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (error "%s needs update" (buffer-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 ((and buffer-read-only (eq vc-type 'CVS))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (toggle-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; Sites who make link farms to a read-only gold tree (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 ;; something similar) can use the hook below to break the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 ;; sym-link.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (run-hooks 'vc-make-buffer-writable-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 ;; OK, user owns the lock on the file (or we are running CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (find-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 ;; give luser a chance to save before checking in.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (vc-buffer-sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 ;; Revert if file is unchanged and buffer is too.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 ;; If buffer is modified, that means the user just said no
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 ;; to saving it; in that case, don't revert,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 ;; because the user might intend to save
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 ;; after finishing the log entry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (if (and (vc-workfile-unchanged-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (not (buffer-modified-p)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (if (eq vc-type 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 (message "No changes to %s" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (vc-backend-revert file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 ;; DO NOT revert the file without asking the user!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (vc-resynch-window file t nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 ;; user may want to set nonstandard parameters
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 (if verbose
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (setq version (read-string "New version level: ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 ;; OK, let's do the checkin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (vc-checkin file version comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (defun vc-next-action-dired (file rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 ;; We've accepted a log comment, now do a vc-next-action using it on all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 ;; marked files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (set-buffer vc-parent-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (dired-map-over-marks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (save-window-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (let ((file (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (message "Processing %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 (vc-next-action-on-file file nil comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 (message "Processing %s...done" file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 ;; Here's the major entry point.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (defun vc-next-action (verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 "Do the next logical checkin or checkout operation on the current file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 For RCS and SCCS files:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 If the file is not already registered, this registers it for version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 control and then retrieves a writable, locked copy for editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 If the file is registered and not locked by anyone, this checks out
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588 a writable and locked file ready for editing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589 If the file is checked out and locked by the calling user, this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 first checks to see if the file has changed since checkout. If not,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 it performs a revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592 If the file has been changed, this pops up a buffer for entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 of a log message; when the message has been entered, it checks in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 resulting changes along with the log message as change commentary. If
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 the variable `vc-keep-workfiles' is non-nil (which is its default), a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 read-only copy of the changed file is left in place afterwards.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 If the file is registered and locked by someone else, you are given
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 the option to steal the lock.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 For CVS files:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 If the file is not already registered, this registers it for version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 control. This does a \"cvs add\", but no \"cvs commit\".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 If the file is added but not committed, it is committed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 If the file has not been changed, neither in your working area or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605 in the repository, a message is printed and nothing is done.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606 If your working file is changed, but the repository file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 unchanged, this pops up a buffer for entry of a log message; when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 message has been entered, it checks in the resulting changes along
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
609 with the logmessage as change commentary. A writable file is retained.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
610 If the repository file is changed, you are asked if you want to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
611 merge in the changes into your working copy.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
612
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
613 The following is true regardless of which version control system you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
614 are using:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
615
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
616 If you call this from within a VC dired buffer with no files marked,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
617 it will operate on the file in the current line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
618 If you call this from within a VC dired buffer, and one or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
619 files are marked, it will accept a log message and then operate on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
620 each one. The log message will be used as a comment for any register
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
621 or checkin operations, but ignored when doing checkouts. Attempted
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
622 lock steals will raise an error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
624 For checkin, a prefix argument lets you specify the version number to use."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
625 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
626 (catch 'nogo
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
627 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
628 (let ((files (dired-get-marked-files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
629 (if (= (length files) 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
630 (find-file-other-window (car files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
631 (vc-start-entry nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
632 "Enter a change comment for the marked files."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
633 'vc-next-action-dired)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
634 (throw 'nogo nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
635 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
636 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
637 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
638 (vc-next-action-on-file buffer-file-name verbose)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
639 (vc-registration-error nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
641 ;;; These functions help the vc-next-action entry point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
643 (defun vc-checkout-writable-buffer (&optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
644 "Retrieve a writable copy of the latest version of the current buffer's file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
645 (vc-checkout (or file (buffer-file-name)) t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 (defun vc-register (&optional override comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 "Register the current file into your version-control system."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 (let ((master (vc-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 (and master (file-exists-p master)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654 (error "This file is already registered"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 (and master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 (not (y-or-n-p "Previous master file has vanished. Make a new one? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 (error "This file is already registered")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 ;; Watch out for new buffers of size 0: the corresponding file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659 ;; does not exist yet, even though buffer-modified-p is nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 (if (and (not (buffer-modified-p))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 (zerop (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 (not (file-exists-p buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 (set-buffer-modified-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 (vc-buffer-sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 (vc-admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 (and override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 (read-string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 (format "Initial version level for %s: " buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 (defun vc-resynch-window (file &optional keep noquery)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 ;; If the given file is in the current buffer,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 ;; either revert on it so we see expanded keyworks,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 ;; or unvisit it (depending on vc-keep-workfiles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 ;; NOQUERY if non-nil inhibits confirmation for reverting.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 ;; NOQUERY should be t *only* if it is known the only difference
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 ;; between the buffer and the file is due to RCS rather than user editing!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 (and (string= buffer-file-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 (if keep
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 (vc-revert-buffer1 t noquery)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 (vc-mode-line buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 (kill-buffer (current-buffer))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
688 (defun vc-start-entry (file rev comment msg action &optional after-hook before-hook)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 ;; Accept a comment for an operation on FILE revision REV. If COMMENT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 ;; is nil, pop up a VC-log buffer, emit MSG, and set the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 ;; action on close to ACTION; otherwise, do action immediately.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 ;; Remember the file's buffer in vc-parent-buffer (current one if no file).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 ;; AFTER-HOOK specifies the local value for vc-log-operation-hook.
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
694 ;; BEFORE-HOOK specifies a hook to run before even asking for the
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
695 ;; checkin comments.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 (let ((parent (if file (find-file-noselect file) (current-buffer))))
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
697 (when before-hook
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
698 (save-excursion
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
699 (set-buffer parent)
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
700 (run-hooks before-hook)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701 (if comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 (set-buffer (get-buffer-create "*VC-log*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 (pop-to-buffer (get-buffer-create "*VC-log*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704 (set (make-local-variable 'vc-parent-buffer) parent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 (concat " from " (buffer-name vc-parent-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 (vc-mode-line (or file " (no file)"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
708 (vc-log-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
709 (make-local-variable 'vc-log-after-operation-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
710 (if after-hook
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
711 (setq vc-log-after-operation-hook after-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
712 (setq vc-log-operation action)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
713 (setq vc-log-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
714 (setq vc-log-version rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
715 (if comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
716 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
718 (if (eq comment t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 (vc-finish-logentry t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
720 (insert comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
721 (vc-finish-logentry nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
722 (message "%s Type C-c C-c when done." msg))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724 (defun vc-admin (file rev &optional comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 "Check a file into your version-control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 FILE is the unmodified name of the file. REV should be the base version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 level to check it in under. COMMENT, if specified, is the checkin comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
728 (vc-start-entry file rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729 (or comment (not vc-initial-comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 "Enter initial comment." 'vc-backend-admin
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
731 nil 'vc-before-checkin-hook))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 (defun vc-checkout (file &optional writable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 "Retrieve a copy of the latest version of the given file."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 ;; XEmacs - ftp is suppressed by the check for a filename handler in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 ;; vc-registered, so this is needless surplussage
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 ;; If ftp is on this system and the name matches the ange-ftp format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 ;; for a remote file, the user is trying something that won't work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 ;; (if (and (string-match "^/[^/:]+:" file) (vc-find-binary "ftp"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 ;; (error "Sorry, you can't check out files over FTP"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 (vc-backend-checkout file writable)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 (if (string-equal file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
743 (vc-resynch-window file t t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
744 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
745
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
746 (defun vc-steal-lock (file rev &optional owner)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
747 "Steal the lock on the current workfile."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
748 (let (file-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
749 (if (not owner)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
750 (setq owner (vc-locking-user file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
751 (if rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
752 (setq file-description (format "%s:%s" file rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
753 (setq file-description file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
754 (if (not (y-or-n-p (format "Take the lock on %s from %s? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
755 file-description owner)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
756 (error "Steal cancelled"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
757 (pop-to-buffer (get-buffer-create "*VC-mail*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
758 (setq default-directory (expand-file-name "~/"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
759 (auto-save-mode auto-save-default)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
760 (mail-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
761 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
762 (mail-setup owner (format "Stolen lock on %s" file-description) nil nil nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
763 (list (list 'vc-finish-steal file rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
764 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
765 (insert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
766 (format "I stole the lock on %s, " file-description)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
767 (current-time-string)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
768 ".\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
769 (message "Please explain why you stole the lock. Type C-c C-c when done.")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
770
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
771 ;; This is called when the notification has been sent.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
772 (defun vc-finish-steal (file version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
773 (vc-backend-steal file version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
774 (if (get-file-buffer file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
775 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
776 (set-buffer (get-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
777 (vc-resynch-window file t t))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
778
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
779 (defun vc-checkin (file &optional rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
780 "Check in the file specified by FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
781 The optional argument REV may be a string specifying the new version level
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
782 \(if nil increment the current level). The file is either retained with write
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
783 permissions zeroed, or deleted (according to the value of `vc-keep-workfiles').
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
784 If the back-end is CVS, a writable workfile is always kept.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
785 COMMENT is a comment string; if omitted, a buffer is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
786 popped up to accept a comment."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
787 (vc-start-entry file rev comment
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
788 "Enter a change comment." 'vc-backend-checkin
30
ec9a17fef872 Import from CVS: tag r19-15b98
cvs
parents: 24
diff changeset
789 'vc-checkin-hook 'vc-before-checkin-hook))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
790
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
791 ;;; Here is a checkin hook that may prove useful to sites using the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
792 ;;; ChangeLog facility supported by Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
793 (defun vc-comment-to-change-log (&optional whoami file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
794 "Enter last VC comment into change log file for current buffer's file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
795 Optional arg (interactive prefix) non-nil means prompt for user name and site.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
796 Second arg is file name of change log. \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
797 If nil, uses `change-log-default-name'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
798 (interactive (if current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
799 (list current-prefix-arg
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
800 (prompt-for-change-log-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
801 ;; Make sure the defvar for add-log-current-defun-function has been executed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
802 ;; before binding it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
803 (require 'add-log)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
804 (let ( ; Extract the comment first so we get any error before doing anything.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
805 (comment (ring-ref vc-comment-ring 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
806 ;; Don't let add-change-log-entry insert a defun name.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
807 (add-log-current-defun-function 'ignore)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
808 end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
809 ;; Call add-log to do half the work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
810 (add-change-log-entry whoami file-name t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
811 ;; Insert the VC comment, leaving point before it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
812 (setq end (save-excursion (insert comment) (point-marker)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
813 (if (looking-at "\\s *\\s(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
814 ;; It starts with an open-paren, as in "(foo): Frobbed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
815 ;; So remove the ": " add-log inserted.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
816 (delete-char -2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
817 ;; Canonicalize the white space between the file name and comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
818 (just-one-space)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
819 ;; Indent rest of the text the same way add-log indented the first line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
820 (let ((indentation (current-indentation)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
821 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
822 (while (< (point) end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
823 (forward-line 1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
824 (indent-to indentation))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
825 (setq end (point))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
826 ;; Fill the inserted text, preserving open-parens at bol.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
827 (let ((paragraph-separate (concat paragraph-separate "\\|^\\s *\\s("))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
828 (paragraph-start (concat paragraph-start "\\|^\\s *\\s(")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
829 (beginning-of-line)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
830 (fill-region (point) end))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
831 ;; Canonicalize the white space at the end of the entry so it is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
832 ;; separated from the next entry by a single blank line.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
833 (skip-syntax-forward " " end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
834 (delete-char (- (skip-syntax-backward " ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
835 (or (eobp) (looking-at "\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
836 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
837
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
838
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
839 (defun vc-finish-logentry (&optional nocomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
840 "Complete the operation implied by the current log entry."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
841 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
842 ;; Check and record the comment, if any.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
843 (if (not nocomment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
844 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
845 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
846 (if (not (bolp))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
847 (newline))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
848 ;; Comment too long?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
849 (vc-backend-logentry-check vc-log-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
850 ;; Record the comment in the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
851 (if (null vc-comment-ring)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
852 (setq vc-comment-ring (make-ring vc-maximum-comment-ring-size)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
853 (ring-insert vc-comment-ring (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
854 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
855 ;; Sync parent buffer in case the user modified it while editing the comment.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
856 ;; But not if it is a vc-dired buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
857 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
858 (set-buffer vc-parent-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
859 (or vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
860 (vc-buffer-sync)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
861 ;; OK, do it to it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
862 (if vc-log-operation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
863 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
864 (funcall vc-log-operation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
865 vc-log-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
866 vc-log-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
867 (buffer-string)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
868 (error "No log operation is pending"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
869 ;; save the vc-log-after-operation-hook of log buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
870 (let ((after-hook vc-log-after-operation-hook))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
871 ;; Return to "parent" buffer of this checkin and remove checkin window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
872 (pop-to-buffer vc-parent-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
873 (let ((logbuf (get-buffer "*VC-log*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
874 (delete-windows-on logbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
875 (kill-buffer logbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
876 ;; Now make sure we see the expanded headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
877 (if buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
878 (vc-resynch-window buffer-file-name vc-keep-workfiles t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
879 (run-hooks after-hook)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
880
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
881 ;; Code for access to the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
882
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
883 (defun vc-previous-comment (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
884 "Cycle backwards through comment history."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
885 (interactive "*p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
886 (let ((len (ring-length vc-comment-ring)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
887 (cond ((or (not len) (<= len 0)) ; XEmacs change from Barry Warsaw
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
888 (message "Empty comment ring")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
889 (ding))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
890 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
891 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
892 ;; Initialize the index on the first use of this command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
893 ;; so that the first M-p gets index 0, and the first M-n gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
894 ;; index -1.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
895 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
896 (setq vc-comment-ring-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
897 (if (> arg 0) -1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
898 (if (< arg 0) 1 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
899 (setq vc-comment-ring-index
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
900 (mod (+ vc-comment-ring-index arg) len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
901 (message "%d" (1+ vc-comment-ring-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
902 (insert (ring-ref vc-comment-ring vc-comment-ring-index))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
903
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
904 (defun vc-next-comment (arg)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
905 "Cycle forwards through comment history."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
906 (interactive "*p")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
907 (vc-previous-comment (- arg)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
908
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
909 (defun vc-comment-search-reverse (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
910 "Searches backwards through comment history for substring match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
911 (interactive "sComment substring: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
912 (if (string= str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
913 (setq str vc-last-comment-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
914 (setq vc-last-comment-match str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
915 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
916 (setq vc-comment-ring-index -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
917 (let ((str (regexp-quote str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
918 (len (ring-length vc-comment-ring))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
919 (n (1+ vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
920 (while (and (< n len) (not (string-match str (ring-ref vc-comment-ring n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
921 (setq n (+ n 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
922 (cond ((< n len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
923 (vc-previous-comment (- n vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
924 (t (error "Not found")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
925
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
926 (defun vc-comment-search-forward (str)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
927 "Searches forwards through comment history for substring match."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
928 (interactive "sComment substring: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
929 (if (string= str "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
930 (setq str vc-last-comment-match)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
931 (setq vc-last-comment-match str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
932 (if (null vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
933 (setq vc-comment-ring-index 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
934 (let ((str (regexp-quote str))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
935 (n vc-comment-ring-index))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
936 (while (and (>= n 0) (not (string-match str (ring-ref vc-comment-ring n))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
937 (setq n (- n 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
938 (cond ((>= n 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
939 (vc-next-comment (- n vc-comment-ring-index)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
940 (t (error "Not found")))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
941
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
942 ;; Additional entry points for examining version histories
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
943
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
944 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
945 (defun vc-diff (historic &optional not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
946 "Display diffs between file versions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
947 Normally this compares the current file and buffer with the most recent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
948 checked in version of that file. This uses no arguments.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
949 With a prefix argument, it reads the file name to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
950 and two version designators specifying which versions to compare."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
951 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
952 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
953 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
954 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
955 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
956 (if historic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
957 (call-interactively 'vc-version-diff)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
958 (if (or (null buffer-file-name) (null (vc-name buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
959 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
960 "There is no version-control master associated with this buffer"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
961 (let ((file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
962 unchanged)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
963 (or (and file (vc-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
964 (vc-registration-error file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
965 (vc-buffer-sync not-urgent)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
966 (setq unchanged (vc-workfile-unchanged-p buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
967 (if unchanged
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
968 (message "No changes to %s since latest version." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
969 (vc-backend-diff file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
970 ;; Ideally, we'd like at this point to parse the diff so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
971 ;; the buffer effectively goes into compilation mode and we
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
972 ;; can visit the old and new change locations via next-error.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
973 ;; Unfortunately, this is just too painful to do. The basic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
974 ;; problem is that the `old' file doesn't exist to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
975 ;; visited. This plays hell with numerous assumptions in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
976 ;; the diff.el and compile.el machinery.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
977 (pop-to-buffer "*vc*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
978 (setq default-directory (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
979 (if (= 0 (buffer-size))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
980 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
981 (setq unchanged t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
982 (message "No changes to %s since latest version." file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
983 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
984 (shrink-window-if-larger-than-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
985 (not unchanged))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
986
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
987 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
988 (defun vc-version-diff (file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
989 "For FILE, report diffs between two stored versions REL1 and REL2 of it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
990 If FILE is a directory, generate diffs between versions for all registered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
991 files in or below it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
992 ;; XEmacs - better prompt
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
993 (interactive "FFile or directory to diff: \nsOlder version (default is repository): \nsNewer version (default is workfile): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
994 (if (string-equal rel1 "") (setq rel1 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
995 (if (string-equal rel2 "") (setq rel2 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
996 (if (file-directory-p file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
997 (let ((camefrom (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
998 (set-buffer (get-buffer-create "*vc-status*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
999 (set (make-local-variable 'vc-parent-buffer) camefrom)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1000 (set (make-local-variable 'vc-parent-buffer-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1001 (concat " from " (buffer-name camefrom)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1002 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1003 (insert "Diffs between "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1004 (or rel1 "last version checked in")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1005 " and "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1006 (or rel2 "current workfile(s)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1007 ":\n\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1008 (set-buffer (get-buffer-create "*vc*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1009 (cd file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1010 (vc-file-tree-walk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1011 (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1012 (message "Looking at %s" f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1013 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1014 (not (file-directory-p f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1015 (vc-registered f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1016 (vc-backend-diff f rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1017 (append-to-buffer "*vc-status*" (point-min) (point-max)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1018 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1019 (pop-to-buffer "*vc-status*")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1020 (insert "\nEnd of diffs.\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1021 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1022 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1023 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1024 (if (zerop (vc-backend-diff file rel1 rel2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1025 (message "No changes to %s between %s and %s." file rel1 rel2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1026 (pop-to-buffer "*vc*"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1028 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1029 (defun vc-version-other-window (rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1030 "Visit version REV of the current buffer in another window.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1031 If the current buffer is named `F', the version is named `F.~REV~'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1032 If `F.~REV~' already exists, it is used instead of being re-created."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1033 (interactive "sVersion to visit (default is latest version): ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1034 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1035 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1036 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1037 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1038 (if (and buffer-file-name (vc-name buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1039 (let* ((version (if (string-equal rev "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1040 (vc-latest-version buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1041 rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1042 (filename (concat buffer-file-name ".~" version "~")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1043 (or (file-exists-p filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1044 (vc-backend-checkout buffer-file-name nil version filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1045 (find-file-other-window filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1046 (vc-registration-error buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1048 ;; Header-insertion code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1049
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1050 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1051 (defun vc-insert-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1052 "Insert headers in a file for use with your version-control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1053 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
1054 the variable `vc-header-alist'."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1055 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1056 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1057 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1058 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1059 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1060 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1061 (save-restriction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1062 (widen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1063 (if (or (not (vc-check-headers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1064 (y-or-n-p "Version headers already exist. Insert another set? "))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1065 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1066 (let* ((delims (cdr (assq major-mode vc-comment-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1067 (comment-start-vc (or (car delims) comment-start "#"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1068 (comment-end-vc (or (car (cdr delims)) comment-end ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1069 (hdstrings (cdr (assoc (vc-backend-deduce buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1070 vc-header-alist))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1071 (mapcar #'(lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1072 (insert comment-start-vc "\t" s "\t"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1073 comment-end-vc "\n"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1074 hdstrings)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1075 (if vc-static-header-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1076 (mapcar #'(lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1077 (if (and buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1078 (string-match (car f) buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1079 (insert (format (cdr f) (car hdstrings)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1080 vc-static-header-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1081 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1082 )))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1083
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1084 ;; The VC directory submode. Coopt Dired for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1085 ;; All VC commands get mapped into logical equivalents.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1086
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1087 ;; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1088 (defvar vc-dired-prefix-map (let ((map (make-sparse-keymap)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1089 (set-keymap-name map 'vc-dired-prefix-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1090 (define-key map "\C-xv" vc-prefix-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1091 map))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1092
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1093 (or (not (boundp 'minor-mode-map-alist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1094 (assq 'vc-dired-mode minor-mode-map-alist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1095 (setq minor-mode-map-alist
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1096 (cons (cons 'vc-dired-mode vc-dired-prefix-map)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1097 minor-mode-map-alist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1098
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1099 (defun vc-dired-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1100 "The augmented Dired minor mode used in VC directory buffers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1101 All Dired commands operate normally. Users currently locking listed files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1102 are listed in place of the file's owner and group.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1103 Keystrokes bound to VC commands will execute as though they had been called
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1104 on a buffer attached to the file named in the current Dired buffer line."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1105 (setq vc-dired-mode t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1106 (setq vc-mode " under VC"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1107
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1108 (defun vc-dired-reformat-line (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1109 ;; Hack a directory-listing line, plugging in locking-user info in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1110 ;; place of the user and group info. Should have the beneficial
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1111 ;; side-effect of shortening the listing line. Each call starts with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1112 ;; point immediately following the dired mark area on the line to be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1113 ;; hacked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1114 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1115 ;; Simplest possible one:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1116 ;; (insert (concat x "\t")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1117 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1118 ;; This code, like dired, assumes UNIX -l format.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1119 (forward-word 1) ; skip over any extra field due to -ibs options
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1120 (cond ((numberp x) ; This hack is used by the CVS code. See vc-locking-user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1121 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1122 ((re-search-forward "\\([0-9]+ \\)\\([^ ]+\\)\\( .*\\)" nil 0)
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 (goto-char (match-beginning 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1125 (insert "(")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1126 (goto-char (1+ (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1127 (insert ")")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1128 (delete-char (- 17 (- (match-end 2) (match-beginning 2))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1129 (insert (substring " " 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1130 (- 7 (- (match-end 2) (match-beginning 2)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1131 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1132 (if x (setq x (concat "(" x ")")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1133 (if (re-search-forward "\\([0-9]+ \\).................\\( .*\\)" nil 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1134 (let ((rep (substring (concat x " ") 0 9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1135 (replace-match (concat "\\1" rep "\\2") t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1136 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1138 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1139 (defun vc-directory (dir verbose &optional nested)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1140 "Show version-control status of all files in the directory DIR.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1141 If the second argument VERBOSE is non-nil, show all files;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1142 otherwise show only files that current locked in the version control system.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1143 Interactively, supply a prefix arg to make VERBOSE non-nil.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1144
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1145 If the optional third argument NESTED is non-nil,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1146 scan the entire tree of subdirectories of the current directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1147 (interactive "DVC status of directory: \nP")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1148 (let* (nonempty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1149 (dl (length dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1150 (filelist nil) (userlist nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1151 dired-buf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1152 (subfunction
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1153 (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1154 (if (vc-registered f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1155 (let ((user (vc-locking-user f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1156 (and (or verbose user)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1157 (setq filelist (cons (substring f dl) filelist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1158 (setq userlist (cons user userlist)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1159 (let ((default-directory dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1160 (if nested
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1161 (vc-file-tree-walk subfunction)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1162 (vc-dir-all-files subfunction)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1163 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1164 (dired (make-string-stringlist (cons dir (nreverse filelist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1165 dired-listing-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1166 (rename-buffer (generate-new-buffer-name "VC-DIRED"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1167 (setq dired-buf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1168 (setq nonempty (not (zerop (buffer-size)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1169 (if nonempty
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1170 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1171 (pop-to-buffer dired-buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1172 (vc-dired-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1173 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1174 (setq buffer-read-only nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1175 (forward-line 1) ; Skip header line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1176 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1177 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1178 (lambda (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1179 (forward-char 2) ; skip dired's mark area
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1180 (vc-dired-reformat-line x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1181 (forward-line 1))) ; go to next line
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1182 (nreverse userlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1183 (setq buffer-read-only t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1184 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1185 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1186 (message "No files are currently %s under %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1187 (if verbose "registered" "locked") default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1188 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1189
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1190 (defun make-string-stringlist (stringlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1191 "Turn a list of strings into a string of space-delimited elements."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1192 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1193 (let ((tlist stringlist)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1194 (buf (generate-new-buffer "*stringlist*")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1195 (set-buffer buf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1196 (insert (car tlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1197 (setq tlist (cdr tlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1198 (while (not (null tlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1199 (setq s (car tlist))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1200 (insert s " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1201 (setq tlist (cdr tlist)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1202 (setq string (buffer-string))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1203 (kill-this-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1204 string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1205 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1207 ;; Named-configuration support for SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1208
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1209 (defun vc-add-triple (name file rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1210 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1211 (find-file (concat (vc-backend-subdirectory-name file) "/" vc-name-assoc-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1212 (goto-char (point-max))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1213 (insert name "\t:\t" file "\t" rev "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1214 (basic-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1215 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1216 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1217
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1218 (defun vc-record-rename (file newname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1219 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1220 (find-file (concat (vc-backend-subdirectory-name file) "/" vc-name-assoc-file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1221 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1222 ;; (replace-regexp (concat ":" (regexp-quote file) "$") (concat ":" newname))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1223 (while (re-search-forward (concat ":" (regexp-quote file) "$") nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1224 (replace-match (concat ":" newname) nil nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1225 (basic-save-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1226 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1227 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1228
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1229 (defun vc-lookup-triple (file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1230 ;; Return the numeric version corresponding to a named snapshot of file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1231 ;; If name is nil or a version number string it's just passed through
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1232 (cond ((null name) name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1233 ((let ((firstchar (aref name 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1234 (and (>= firstchar ?0) (<= firstchar ?9)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1235 name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1236 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1237 (car (vc-master-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1238 (concat (vc-backend-subdirectory-name file) "/" vc-name-assoc-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1239 (list (concat name "\t:\t" file "\t\\(.+\\)"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1240 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1241
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1242 ;; Named-configuration entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1243
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1244 (defun vc-locked-example ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1245 ;; Return an example of why the current directory is not ready to be snapshot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1246 ;; or nil if no such example exists.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1247 (catch 'vc-locked-example
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1248 (vc-file-tree-walk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1249 (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1250 (if (and (vc-registered f) (vc-locking-user f))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1251 (throw 'vc-locked-example f)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1252 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1253
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1254 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1255 (defun vc-create-snapshot (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1256 "Make a snapshot called NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1257 The snapshot is made from all registered files at or below the current
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1258 directory. For each file, the version level of its latest
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1259 version becomes part of the named configuration."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1260 (interactive "sNew snapshot name: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1261 (let ((locked (vc-locked-example)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1262 (if locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1263 (error "File %s is locked" locked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1264 (vc-file-tree-walk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1265 (function (lambda (f) (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1266 (vc-name f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1267 (vc-backend-assign-name f name)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1268 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1269
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1270 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1271 (defun vc-retrieve-snapshot (name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1272 "Retrieve the snapshot called NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1273 This function fails if any files are locked at or below the current directory
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1274 Otherwise, all registered files are checked out (unlocked) at their version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1275 levels in the snapshot."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1276 (interactive "sSnapshot name to retrieve: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1277 (let ((locked (vc-locked-example)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1278 (if locked
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1279 (error "File %s is locked" locked)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1280 (vc-file-tree-walk
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1281 (function (lambda (f) (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1282 (vc-name f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1283 (vc-error-occurred
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1284 (vc-backend-checkout f nil name))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1285 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1286
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1287 ;; Miscellaneous other entry points
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1288
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1289 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1290 (defun vc-print-log ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1291 "List the change log of the current buffer in a window."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1292 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1293 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1294 (set-buffer (find-file-noselect (dired-get-filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1295 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1296 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1297 (if (and buffer-file-name (vc-name buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1298 (let ((file buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1299 (vc-backend-print-log file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1300 (pop-to-buffer (get-buffer-create "*vc*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1301 (setq default-directory (file-name-directory file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1302 (while (looking-at "=*\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1303 (delete-char (- (match-end 0) (match-beginning 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1304 (forward-line -1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1305 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1306 (if (looking-at "[\b\t\n\v\f\r ]+")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1307 (delete-char (- (match-end 0) (match-beginning 0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1308 (shrink-window-if-larger-than-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1309 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1310 (vc-registration-error buffer-file-name)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1311
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1312 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1313 (defun vc-revert-buffer ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1314 "Revert the current buffer's file back to the latest checked-in version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1315 This asks for confirmation if the buffer contents are not identical
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1316 to that version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1317 If the back-end is CVS, this will give you the most recent revision of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1318 the file on the branch you are editing."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1319 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1320 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1321 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1322 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1323 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1324 (let ((file buffer-file-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1325 (obuf (current-buffer)) (changed (vc-diff nil t)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1326 (if (and changed (or vc-suppress-confirm
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1327 (not (yes-or-no-p "Discard changes? "))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1328 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1329 (delete-window)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1330 (error "Revert cancelled"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1331 (set-buffer obuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1332 (if changed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1333 (delete-window))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1334 (vc-backend-revert file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1335 (vc-resynch-window file t t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1336 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1338 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1339 (defun vc-cancel-version (norevert)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1340 "Get rid of most recently checked in version of this file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1341 A prefix argument means do not revert the buffer afterwards."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1342 (interactive "P")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1343 (if vc-dired-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1344 (find-file-other-window (dired-get-filename)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1345 (while vc-parent-buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1346 (pop-to-buffer vc-parent-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1347 (let* ((target (concat (vc-latest-version (buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1348 (yours (concat (vc-your-latest-version (buffer-file-name))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1349 (prompt (if (string-equal yours target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1350 "Remove your version %s from master? "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1351 "Version %s was not your change. Remove it anyway? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1352 (if (null (yes-or-no-p (format prompt target)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1353 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1354 (vc-backend-uncheck (buffer-file-name) target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1355 (if (or norevert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1356 (not (yes-or-no-p "Revert buffer to most recent remaining version? ")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1357 (vc-mode-line (buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1358 (vc-checkout (buffer-file-name) nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1359 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1361 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1362 (defun vc-rename-file (old new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1363 "Rename file OLD to NEW, and rename its master file likewise."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1364 (interactive "fVC rename file: \nFRename to: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1365 ;; There are several ways of renaming files under CVS 1.3, but they all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1366 ;; have serious disadvantages. See the FAQ (available from think.com in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1367 ;; pub/cvs/). I'd rather send the user an error, than do something he might
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1368 ;; consider to be wrong. When the famous, long-awaited rename database is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1369 ;; implemented things might change for the better. This is unlikely to occur
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1370 ;; until CVS 2.0 is released. --ceder 1994-01-23 21:27:51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1371 (if (eq (vc-backend-deduce old) 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1372 (error "Renaming files under CVS is dangerous and not supported in VC."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1373 (if (eq (vc-backend-deduce old) 'CC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1374 (error "VC's ClearCase support cannot rename files."))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1375 (let ((oldbuf (get-file-buffer old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1376 (if (and oldbuf (buffer-modified-p oldbuf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1377 (error "Please save files before moving them"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1378 (if (get-file-buffer new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1379 (error "Already editing new file name"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1380 (if (file-exists-p new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1381 (error "New file already exists"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1382 (let ((oldmaster (vc-name old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1383 (if oldmaster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1384 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1385 (if (vc-locking-user old)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1386 (error "Please check in files before moving them"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1387 (if (or (file-symlink-p oldmaster)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1388 ;; This had FILE, I changed it to OLD. -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1389 (file-symlink-p (vc-backend-subdirectory-name old)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1390 (error "This is not a safe thing to do in the presence of symbolic links"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1391 (rename-file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1392 oldmaster
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1393 (let ((backend (vc-backend-deduce old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1394 (newdir (or (file-name-directory new) ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1395 (newbase (file-name-nondirectory new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1396 (catch 'found
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1397 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1398 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1399 (lambda (s)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1400 (if (eq backend (cdr s))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1401 (let* ((newmaster (format (car s) newdir newbase))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1402 (newmasterdir (file-name-directory newmaster)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1403 (if (or (not newmasterdir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1404 (file-directory-p newmasterdir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1405 (throw 'found newmaster))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1406 vc-master-templates)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1407 (error "New file lacks a version control directory"))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1408 (if (or (not oldmaster) (file-exists-p old))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1409 (rename-file old new)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1410 ;; ?? Renaming a file might change its contents due to keyword expansion.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1411 ;; We should really check out a new copy if the old copy was precisely equal
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1412 ;; to some checked in version. However, testing for this is tricky....
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1413 (if oldbuf
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1414 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1415 (set-buffer oldbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1416 (set-visited-file-name new)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1417 (set-buffer-modified-p nil))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1418 ;; This had FILE, I changed it to OLD. -- rms.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1419 (vc-backend-dispatch old
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1420 (vc-record-rename old new) ;SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1421 ;; #### - This CAN kinda be done for both rcs and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1422 ;; cvs. It needs to be implemented. -- Stig
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1423 nil ;RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1424 nil ;CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1425 nil ;CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1426 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1427 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1428
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1429 ;;;###autoload
6
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1430 (defun vc-rename-this-file (new)
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1431 (interactive "FVC rename file to: ")
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1432 (vc-rename-file buffer-file-name new))
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1433
27bc7f280385 Import from CVS: tag r19-15b4
cvs
parents: 2
diff changeset
1434 ;;;###autoload
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1435 (defun vc-update-change-log (&rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1436 "Find change log file and add entries from recent RCS logs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1437 The mark is left at the end of the text prepended to the change log.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1438 With prefix arg of C-u, only find log entries for the current buffer's file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1439 With any numeric prefix arg, find log entries for all files currently visited.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1440 Otherwise, find log entries for all registered files in the default directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1441 From a program, any arguments are passed to the `rcs2log' script."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1442 (interactive
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1443 (cond ((consp current-prefix-arg) ;C-u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1444 (list buffer-file-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1445 (current-prefix-arg ;Numeric argument.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1446 (let ((files nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1447 (buffers (buffer-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1448 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1449 (while buffers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1450 (setq file (buffer-file-name (car buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1451 (and file (vc-backend-deduce file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1452 (setq files (cons file files)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1453 (setq buffers (cdr buffers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1454 files))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1455 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1456 (let ((RCS (concat default-directory "RCS")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1457 (and (file-directory-p RCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1458 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1459 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1460 (if (string-match "\\(.*\\),v$" f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1461 (substring f 0 (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1462 f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1463 (directory-files RCS nil "...\\|^[^.]\\|^.[^.]")))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1464 (let ((odefault default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1465 (find-file-other-window (find-change-log))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1466 (barf-if-buffer-read-only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1467 (vc-buffer-sync)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1468 (undo-boundary)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1469 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1470 (push-mark)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1471 (message "Computing change log entries...")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1472 (message "Computing change log entries... %s"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1473 (if (or (null args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1474 (eq 0 (apply 'call-process "rcs2log" nil t nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1475 "-n"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1476 (user-login-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1477 (user-full-name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1478 user-mail-address
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1479 (mapcar (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1480 (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1481 (file-relative-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1482 (if (file-name-absolute-p f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1483 f
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1484 (concat odefault f)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1485 args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1486 "done" "failed"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1487
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1488 ;; Functions for querying the master and lock files.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1489
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1490 ;; XEmacs - use match-string instead...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1491 ;; (defun vc-match-substring (bn)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1492 ;; (buffer-substring (match-beginning bn) (match-end bn)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1493
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1494 (defun vc-parse-buffer (patterns &optional file properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1495 ;; Each pattern is of the form:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1496 ;; regex ; subex is 1, and date-subex is 2 (or nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1497 ;; (regex subex date-subex)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1498 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1499 ;; Use PATTERNS to parse information out of the current buffer by matching
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1500 ;; each REGEX in the list and the returning the string matched by SUBEX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1501 ;; If a DATE-SUBEX is present, then the SUBEX from the match with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1502 ;; highest value for DATE-SUBEX (string comparison is used) will be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1503 ;; returned.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1504 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1505 ;; If FILE and PROPERTIES are given, the latter must be a list of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1506 ;; properties of the same length as PATTERNS; each property is assigned
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1507 ;; the corresponding value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1508 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1509 (let (pattern regex subex date-subex latest-date val values date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1510 (while (setq pattern (car patterns))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1511 (if (stringp pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1512 (setq regex pattern
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1513 subex 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1514 date-subex (and (string-match "\\\\(.*\\\\(" regex) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1515 (setq regex (car pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1516 subex (nth 1 pattern)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1517 date-subex (nth 2 pattern)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1518 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1519 (if date-subex
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1520 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1521 (setq latest-date "" val nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1522 (while (re-search-forward regex nil t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1523 (setq date (match-string date-subex))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1524 (if (string< latest-date date)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1525 (setq latest-date date
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1526 val (match-string subex))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1527 val)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1528 ;; no date subex, so just take the first match...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1529 (setq val (and (re-search-forward regex nil t) (match-string subex))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1530 (if file (vc-file-setprop file (car properties) val))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1531 (setq values (cons val values)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1532 patterns (cdr patterns)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1533 properties (cdr properties)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1534 values
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1535 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1536
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1537 (defun vc-master-info (file fields &optional rfile properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1538 ;; Search for information in a master file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1539 (if (and file (file-exists-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1540 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1541 (let ((buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1542 (setq buf (create-file-buffer file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1543 (set-buffer buf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1544 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1545 (insert-file-contents file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1546 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1547 (auto-save-mode nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1548 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1549 (vc-parse-buffer fields rfile properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1550 (kill-buffer (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1551 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1552 (if rfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1553 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1554 (function (lambda (p) (vc-file-setprop rfile p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1555 properties))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1556 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1557 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1558
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1559 (defun vc-log-info (command file last flags patterns &optional properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1560 ;; Search for information in log program output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1561 (if (and file (file-exists-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1562 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1563 (set-buffer (get-buffer-create "*vc*"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1564 (apply 'vc-do-command 0 command file last flags)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1565 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1566 (prog1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1567 (vc-parse-buffer patterns file properties)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1568 (kill-buffer (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1569 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1570 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1571 (if file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1572 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1573 (function (lambda (p) (vc-file-setprop file p nil)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1574 properties))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1575 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1576 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1577
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1578 (defun vc-locking-user (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1579 "Return the name of the person currently holding a lock on FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1580 Return nil if there is no such person.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1581 Under CVS, a file is considered locked if it has been modified since it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1582 was checked out...even though it may well be writable by you."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1583 (setq file (expand-file-name file)) ; use full pathname
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1584 (cond ((eq (vc-backend-deduce file) 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1585 (if (vc-workfile-unchanged-p file t)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1586 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1587 ;; XEmacs - ahead of the pack...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1588 (user-login-name (nth 2 (file-attributes file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1589 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1590 ;; #### - this can probably be cleaned up as a result of the changes to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1591 ;; user-login-name...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1592 (if (or (not vc-keep-workfiles)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1593 (eq vc-mistrust-permissions 't)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1594 (and vc-mistrust-permissions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1595 (funcall vc-mistrust-permissions (vc-backend-subdirectory-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1596 file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1597 (vc-true-locking-user file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1598 ;; This implementation assumes that any file which is under version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1599 ;; control and has -rw-r--r-- is locked by its owner. This is true
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1600 ;; for both RCS and SCCS, which keep unlocked files at -r--r--r--.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1601 ;; We have to be careful not to exclude files with execute bits on;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1602 ;; scripts can be under version control too. Also, we must ignore
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1603 ;; the group-read and other-read bits, since paranoid users turn them off.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1604 ;; This hack wins because calls to the very expensive vc-fetch-properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1605 ;; function only have to be made if (a) the file is locked by someone
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1606 ;; other than the current user, or (b) some untoward manipulation
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1607 ;; behind vc's back has changed the owner or the `group' or `other'
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1608 ;; write bits.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1609 (let ((attributes (file-attributes file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1610 (cond ((string-match ".r-..-..-." (nth 8 attributes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1611 nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1612 ((and (= (nth 2 attributes) (user-uid))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1613 (string-match ".rw..-..-." (nth 8 attributes)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1614 (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1615 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1616 (vc-true-locking-user file)))) ; #### - this looks recursive!!!
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1617 ))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1618
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1619 (defun vc-true-locking-user (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1620 ;; The slow but reliable version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1621 (vc-fetch-properties file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1622 (vc-file-getprop file 'vc-locking-user))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1623
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1624 (defun vc-latest-version (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1625 ;; Return version level of the latest version of FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1626 (vc-fetch-properties file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1627 (vc-file-getprop file 'vc-latest-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1628
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1629 (defun vc-your-latest-version (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1630 ;; Return version level of the latest version of FILE checked in by you
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1631 (vc-fetch-properties file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1632 (vc-file-getprop file 'vc-your-latest-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1633
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1634 ;; Collect back-end-dependent stuff here
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1635 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1636 ;; Everything eventually funnels through these functions. To implement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1637 ;; support for a new version-control system, add another branch to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1638 ;; vc-backend-dispatch macro and fill it in in each call. The variable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1639 ;; vc-master-templates in vc-hooks.el will also have to change.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1640
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1641 (put 'vc-backend-dispatch 'lisp-indent-function 'defun)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1642
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1643 (defmacro vc-backend-dispatch (f s r c a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1644 "Execute FORM1, FORM2 or FORM3 depending whether we're using SCCS, RCS, CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1645 or ClearCase.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1646 If FORM3 is RCS, use FORM2 even if we are using CVS. (CVS shares some code
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1647 with RCS)."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1648 (list 'let (list (list 'type (list 'vc-backend-deduce f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1649 (list 'cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1650 (list (list 'eq 'type (quote 'SCCS)) s) ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1651 (list (list 'eq 'type (quote 'RCS)) r) ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1652 (list (list 'eq 'type (quote 'CVS)) ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1653 (if (eq c 'RCS) r c))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1654 (list (list 'eq 'type (quote 'CC)) a) ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1655 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1656
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1657 (defun vc-lock-file (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1658 ;; Generate lock file name corresponding to FILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1659 (let ((master (vc-name file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1660 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1661 master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1662 (string-match "\\(.*/\\)s\\.\\(.*\\)" master)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1663 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1664 (substring master (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1665 "p."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1666 (substring master (match-beginning 2) (match-end 2))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1667
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1668
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1669 (defun vc-fetch-properties (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1670 ;; Re-fetch all properties associated with the given file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1671 ;; Currently these properties are:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1672 ;; vc-locking-user
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1673 ;; vc-locked-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1674 ;; vc-latest-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1675 ;; vc-your-latest-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1676 ;; vc-cvs-status (cvs only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1677 ;; vc-cc-predecessor (ClearCase only)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1678 (vc-backend-dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1679 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1680 ;; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1681 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1682 (vc-master-info (vc-lock-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1683 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1684 "^[^ ]+ [^ ]+ \\([^ ]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1685 "^\\([^ ]+\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1686 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1687 '(vc-locking-user vc-locked-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1688 (vc-master-info (vc-name file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1689 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1690 "^\001d D \\([^ ]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1691 (concat "^\001d D \\([^ ]+\\) .* "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1692 (regexp-quote (user-login-name)) " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1693 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1694 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1695 '(vc-latest-version vc-your-latest-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1696 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1697 ;; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1698 (vc-log-info "rlog" file 'MASTER nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1699 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1700 "^locks: strict\n\t\\([^:]+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1701 "^locks: strict\n\t[^:]+: \\(.+\\)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1702 "^revision[\t ]+\\([0-9.]+\\).*\ndate: \\([ /0-9:]+\\);"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1703 (concat
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1704 "^revision[\t ]+\\([0-9.]+\\)\n.*author: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1705 (regexp-quote (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1706 ";"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1707 '(vc-locking-user vc-locked-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1708 vc-latest-version vc-your-latest-version))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1709 ;; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1710 ;; Don't fetch vc-locking-user and vc-locked-version here, since they
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1711 ;; should always be nil anyhow. Don't fetch vc-your-latest-version, since
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1712 ;; that is done in vc-find-cvs-master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1713 (vc-log-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1714 "cvs" file 'WORKFILE '("status")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1715 ;; CVS 1.3 says "RCS Version:", other releases "RCS Revision:",
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1716 ;; and CVS 1.4a1 says "Repository revision:". The regexp below
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1717 ;; matches much more, but because of the way vc-log-info is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1718 ;; implemented it is impossible to use additional groups.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1719 '(("\\(RCS Version\\|RCS Revision\\|Repository revision\\):[\t ]+\\([0-9.]+\\)" 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1720 "Status: \\(.*\\)")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1721 '(vc-latest-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1722 vc-cvs-status))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1723 ;; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1724 (vc-log-info "cleartool" file 'WORKFILE '("describe")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1725 (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1726 "checked out .* by .* (\\([^ .]+\\)..*@.*)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1727 "from \\([^ ]+\\) (reserved)"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1728 "version [^\"]*\".*@@\\([^ ]+\\)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1729 "version [^\"]*\".*@@\\([^ ]+\\)\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1730 "predecessor version: \\([^ ]+\\)\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1731 '(vc-locking-user vc-locked-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1732 vc-latest-version vc-your-latest-version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1733 vc-cc-predecessor))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1734 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1735
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1736 (defun vc-backend-subdirectory-name (&optional file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1737 ;; Where the master and lock files for the current directory are kept
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1738 (let ((backend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1739 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1740 (and file (vc-backend-deduce file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1741 vc-default-back-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1742 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1743 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1744 ((eq backend 'SCCS) "SCCS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1745 ((eq backend 'RCS) "RCS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1746 ((eq backend 'CVS) "CVS")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1747 ((eq backend 'CC) "@@"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1748 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1749
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1750 (defun vc-backend-admin (file &optional rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1751 ;; Register a file into the version-control system
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1752 ;; Automatically retrieves a read-only version of the file with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1753 ;; keywords expanded if vc-keep-workfiles is non-nil, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1754 ;; it deletes the workfile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1755 (vc-file-clearprops file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1756 (or vc-default-back-end
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1757 (setq vc-default-back-end (if (vc-find-binary "rcs") 'RCS 'SCCS)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1758 (message "Registering %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1759 (let ((backend
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1760 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1761 ((file-exists-p (vc-backend-subdirectory-name)) vc-default-back-end)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1762 ((file-exists-p "RCS") 'RCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1763 ((file-exists-p "SCCS") 'SCCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1764 ((file-exists-p "CVS") 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1765 ((file-exists-p "@@") 'CC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1766 (t vc-default-back-end))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1767 (cond ((eq backend 'SCCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1768 (vc-do-command 0 "admin" file 'MASTER ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1769 (and rev (concat "-r" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1770 "-fb"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1771 (concat "-i" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1772 (and comment (concat "-y" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1773 (format
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1774 (car (rassq 'SCCS vc-master-templates))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1775 (or (file-name-directory file) "")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1776 (file-name-nondirectory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1777 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1778 (if vc-keep-workfiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1779 (vc-do-command 0 "get" file 'MASTER)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1780 ((eq backend 'RCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1781 (vc-do-command 0 "ci" file 'MASTER ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1782 (concat (if vc-keep-workfiles "-u" "-r") rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1783 (and comment (concat "-t-" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1784 file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1785 ((eq backend 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1786 ;; #### - should maybe check to see if the master file is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1787 ;; already in the repository...in which case we need to add the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1788 ;; appropriate branch tag and do an update.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1789 ;; #### - note that adding a file is a 2 step process in CVS...
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1790 (vc-do-command 0 "cvs" file 'WORKFILE "add")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1791 (vc-do-command 0 "cvs" file 'WORKFILE "commit"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1792 (and comment (not (string= comment ""))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1793 (concat "-m" comment)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1794 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1795 ((eq backend 'CC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1796 (vc-do-command 0 "cleartool" file 'WORKFILE ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1797 "mkelem"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1798 (if (string-equal "" comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1799 "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1800 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1801 "-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1802 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1803 comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1804 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1805 (vc-do-command 0 "cleartool" file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1806 "checkin" "-identical" "-nc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1807 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1808 )))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1809 (message "Registering %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1810 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1811
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1812 (defun vc-backend-checkout (file &optional writable rev workfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1813 ;; Retrieve a copy of a saved version into a workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1814 (let ((filename (or workfile file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1815 (message "Checking out %s..." filename)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1816 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1817 ;; Change buffers to get local value of vc-checkin-switches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1818 (set-buffer (or (get-file-buffer file) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1819 (vc-backend-dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1820 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1821 ;; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1822 (if workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1823 ;; Some SCCS implementations allow checking out directly to a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1824 ;; file using the -G option, but then some don't so use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1825 ;; least common denominator approach and use the -p option
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1826 ;; ala RCS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1827 (let ((vc-modes (logior (file-modes (vc-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1828 (if writable 128 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1829 (failed t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1830 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1831 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1832 (apply 'vc-do-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1833 0 "/bin/sh" file 'MASTER "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1834 ;; Some shells make the "" dummy argument into $0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1835 ;; while others use the shell's name as $0 and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1836 ;; use the "" as $1. The if-statement
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1837 ;; converts the latter case to the former.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1838 (format "if [ x\"$1\" = x ]; then shift; fi; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1839 umask %o; exec >\"$1\" || exit; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1840 shift; umask %o; exec get \"$@\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1841 (logand 511 (lognot vc-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1842 (logand 511 (lognot (default-file-modes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1843 "" ; dummy argument for shell's $0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1844 filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1845 (if writable "-e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1846 "-p" (and rev
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1847 (concat "-r" (vc-lookup-triple file rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1848 vc-checkout-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1849 (setq failed nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1850 (and failed (file-exists-p filename) (delete-file filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1851 (apply 'vc-do-command 0 "get" file 'MASTER ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1852 (if writable "-e")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1853 (and rev (concat "-r" (vc-lookup-triple file rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1854 vc-checkout-switches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1855 ;; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1856 (if workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1857 ;; RCS doesn't let us check out into arbitrary file names directly.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1858 ;; Use `co -p' and make stdout point to the correct file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1859 (let ((vc-modes (logior (file-modes (vc-name file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1860 (if writable 128 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1861 (failed t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1862 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1863 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1864 (apply 'vc-do-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1865 0 "/bin/sh" file 'MASTER "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1866 ;; See the SCCS case, above, regarding the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1867 ;; if-statement.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1868 (format "if [ x\"$1\" = x ]; then shift; fi; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1869 umask %o; exec >\"$1\" || exit; \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1870 shift; umask %o; exec co \"$@\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1871 (logand 511 (lognot vc-modes))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1872 (logand 511 (lognot (default-file-modes))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1873 "" ; dummy argument for shell's $0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1874 filename
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1875 (if writable "-l")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1876 (concat "-p" rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1877 vc-checkout-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1878 (setq failed nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1879 (and failed (file-exists-p filename) (delete-file filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1880 (apply 'vc-do-command 0 "co" file 'MASTER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1881 (if writable "-l")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1882 (and rev (concat "-r" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1883 vc-checkout-switches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1884 ;; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1885 (if workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1886 ;; CVS is much like RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1887 (let ((failed t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1888 (unwind-protect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1889 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1890 (apply 'vc-do-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1891 0 "/bin/sh" file 'WORKFILE "-c"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1892 "exec >\"$1\" || exit; shift; exec cvs update \"$@\""
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1893 "" ; dummy argument for shell's $0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1894 workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1895 (concat "-r" rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1896 "-p"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1897 vc-checkout-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1898 (setq failed nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1899 (and failed (file-exists-p filename) (delete-file filename))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1900 (apply 'vc-do-command 0 "cvs" file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1901 "update"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1902 (and rev (concat "-r" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1903 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1904 vc-checkout-switches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1905 ;; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1906 (if (or rev workfile)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1907 (error "VC's ClearCase support currently checks out /main/LATEST.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1908 (apply 'vc-do-command 0 "cleartool" file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1909 "checkout" "-nc"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1910 vc-checkout-switches))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1911 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1912 (or workfile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1913 (vc-file-setprop file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1914 'vc-checkout-time (nth 5 (file-attributes file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1915 (message "Checking out %s...done" filename))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1916 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1917
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1918 (defun vc-backend-logentry-check (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1919 (vc-backend-dispatch file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1920 (if (>= (buffer-size) 512) ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1921 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1922 (goto-char 512)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1923 (error
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1924 "Log must be less than 512 characters; point is now at pos 512")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1925 nil ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1926 nil ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1927 nil) ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1928 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1929
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1930 (defun vc-backend-checkin (file rev comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1931 ;; Register changes to FILE as level REV with explanatory COMMENT.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1932 ;; Automatically retrieves a read-only version of the file with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1933 ;; keywords expanded if vc-keep-workfiles is non-nil, otherwise
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1934 ;; it deletes the workfile.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1935 (message "Checking in %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1936 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1937 ;; Change buffers to get local value of vc-checkin-switches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1938 (set-buffer (or (get-file-buffer file) (current-buffer)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1939 (vc-backend-dispatch file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1940 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1941 (apply 'vc-do-command 0 "delta" file 'MASTER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1942 (if rev (concat "-r" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1943 (concat "-y" comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1944 vc-checkin-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1945 (if vc-keep-workfiles
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1946 (vc-do-command 0 "get" file 'MASTER))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1947 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1948 (apply 'vc-do-command 0 "ci" file 'MASTER
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1949 (concat (if vc-keep-workfiles "-u" "-r") rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1950 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1951 (concat "-m" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1952 vc-checkin-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1953 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1954 (apply 'vc-do-command 0 "cvs" file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1955 "ci"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1956 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1957 (concat "-m" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1958 vc-checkin-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1959 (vc-file-setprop file 'vc-checkout-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1960 (nth 5 (file-attributes file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1961 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1962 (apply 'vc-do-command 0 "cleartool" file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1963 "checkin" "-identical"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1964 (if (string-equal "" comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1965 "-nc")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1966 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1967 "-c")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1968 (if (not (string-equal "" comment))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1969 comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1970 vc-checkin-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1971 (vc-file-setprop file 'vc-checkout-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1972 (nth 5 (file-attributes file))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1973 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1974 (vc-file-setprop file 'vc-locking-user nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1975 (message "Checking in %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1976 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1977
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1978 (defun vc-backend-revert (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1979 ;; Revert file to latest checked-in version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1980 (message "Reverting %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1981 (vc-backend-dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1982 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1983 (progn ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1984 (vc-do-command 0 "unget" file 'MASTER nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1985 (vc-do-command 0 "get" file 'MASTER nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1986 (vc-do-command 0 "co" file 'MASTER ; RCS. This deletes the work file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1987 "-f" "-u")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1988 (progn ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1989 (delete-file file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1990 (vc-do-command 0 "cvs" file 'WORKFILE "update"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1991 (vc-do-command 0 "cleartool" file 'WORKFILE ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1992 "unco" "-rm")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1993 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1994 (vc-file-setprop file 'vc-locking-user nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1995 (message "Reverting %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1996 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1997
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1998 (defun vc-backend-steal (file &optional rev)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1999 ;; Steal the lock on the current workfile. Needs RCS 5.6.2 or later for -M.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2000 (message "Stealing lock on %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2001 (vc-backend-dispatch file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2002 (progn ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2003 (vc-do-command 0 "unget" file 'MASTER "-n" (if rev (concat "-r" rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2004 (vc-do-command 0 "get" file 'MASTER "-g" (if rev (concat "-r" rev)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2005 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2006 (vc-do-command 0 "rcs" file 'MASTER ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2007 "-M" (concat "-u" rev) (concat "-l" rev))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2008 (error "You cannot steal a CVS lock; there are no CVS locks to steal.") ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2009 (error "VC's ClearCase support cannot steal locks.") ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2010 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2011 (vc-file-setprop file 'vc-locking-user (user-login-name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2012 (message "Stealing lock on %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2013 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2014
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2015 (defun vc-backend-uncheck (file target)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2016 ;; Undo the latest checkin. Note: this code will have to get a lot
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2017 ;; smarter when we support multiple branches.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2018 (message "Removing last change from %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2019 (vc-backend-dispatch file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2020 (vc-do-command 0 "rmdel" file 'MASTER (concat "-r" target))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2021 (vc-do-command 0 "rcs" file 'MASTER (concat "-o" target))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2022 (error "Unchecking files under CVS is dangerous and not supported in VC.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2023 (error "VC's ClearCase support cannot cancel checkins.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2024 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2025 (message "Removing last change from %s...done" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2026 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2027
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2028 (defun vc-backend-print-log (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2029 ;; Print change log associated with FILE to buffer *vc*.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2030 (vc-backend-dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2031 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2032 (vc-do-command 0 "prs" file 'MASTER)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2033 (vc-do-command 0 "rlog" file 'MASTER)
24
4103f0995bd7 Import from CVS: tag r19-15b95
cvs
parents: 16
diff changeset
2034 (vc-do-command 0 "cvs" file 'WORKFILE "log")
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2035 (vc-do-command 0 "cleartool" file 'WORKFILE "lshistory")))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2036
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2037 (defun vc-backend-assign-name (file name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2038 ;; Assign to a FILE's latest version a given NAME.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2039 (vc-backend-dispatch file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2040 (vc-add-triple name file (vc-latest-version file)) ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2041 (vc-do-command 0 "rcs" file 'MASTER (concat "-n" name ":")) ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2042 (vc-do-command 0 "cvs" file 'WORKFILE "tag" name) ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2043 (vc-do-command 0 "cleartool" file 'WORKFILE ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2044 "mklabel" "-replace" "-nc" name)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2045 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2046 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2047
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2048 (defun vc-backend-diff (file &optional oldvers newvers cmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2049 ;; Get a difference report between two versions of FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2050 ;; Get only a brief comparison report if CMP, a difference report otherwise.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2051 (let ((backend (vc-backend-deduce file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2052 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2053 ((eq backend 'SCCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2054 (setq oldvers (vc-lookup-triple file oldvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2055 (setq newvers (vc-lookup-triple file newvers))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2056 (cond
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2057 ;; SCCS and RCS shares a lot of code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2058 ((or (eq backend 'SCCS) (eq backend 'RCS))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2059 (let* ((command (if (eq backend 'SCCS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2060 "vcdiff"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2061 "rcsdiff"))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2062 (mode (if (eq backend 'RCS) 'WORKFILE 'MASTER))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2063 (options (append (list (and cmp "--brief")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2064 "-q"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2065 (and oldvers (concat "-r" oldvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2066 (and newvers (concat "-r" newvers)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2067 (and (not cmp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2068 (if (listp diff-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2069 diff-switches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2070 (list diff-switches)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2071 (status (apply 'vc-do-command 2 command file mode options)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2072 ;; Some RCS versions don't understand "--brief"; work around this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2073 (if (eq status 2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2074 (apply 'vc-do-command 1 command file 'WORKFILE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2075 (if cmp (cdr options) options))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2076 status)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2077 ;; CVS is different.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2078 ;; cmp is not yet implemented -- we always do a full diff.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2079 ((eq backend 'CVS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2080 (if (string= (vc-file-getprop file 'vc-your-latest-version) "0") ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2081 ;; This file is added but not yet committed; there is no master file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2082 ;; diff it against /dev/null.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2083 (if (or oldvers newvers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2084 (error "No revisions of %s exists" file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2085 (apply 'vc-do-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2086 1 "diff" file 'WORKFILE "/dev/null"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2087 (if (listp diff-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2088 diff-switches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2089 (list diff-switches))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2090 (apply 'vc-do-command
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2091 1 "cvs" file 'WORKFILE "diff"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2092 (and oldvers (concat "-r" oldvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2093 (and newvers (concat "-r" newvers))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2094 (if (listp diff-switches)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2095 diff-switches
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2096 (list diff-switches)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2097 ;; ClearCase is completely different.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2098 ((eq backend 'CC)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2099 (apply 'vc-do-command 2 "cleardiff" file nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2100 (if cmp "-status_only")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2101 (concat file "@@"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2102 (or oldvers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2103 (vc-file-getprop file 'vc-cc-predecessor)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2104 (if newvers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2105 (concat file "@@" newvers)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2106 file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2107 nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2108 (t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2109 (vc-registration-error file)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2111 (defun vc-backend-merge-news (file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2112 ;; Merge in any new changes made to FILE.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2113 (vc-backend-dispatch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2114 file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2115 (error "vc-backend-merge-news not meaningful for SCCS files") ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2116 (error "vc-backend-merge-news not meaningful for RCS files") ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2117 (vc-do-command 1 "cvs" file 'WORKFILE "update") ; CVS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2118 (error "vc-backend-merge-news not meaningful for ClearCase files") ; CC
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2119 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2120
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2121 (defun vc-check-headers ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2122 "Check if the current file has any headers in it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2123 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2124 (save-excursion
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2125 (goto-char (point-min))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2126 (vc-backend-dispatch buffer-file-name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2127 (re-search-forward "%[MIRLBSDHTEGUYFPQCZWA]%" nil t) ; SCCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2128 (re-search-forward "\\$[A-Za-z\300-\326\330-\366\370-\377]+\\(: [\t -#%-\176\240-\377]*\\)?\\$" nil t) ; RCS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2129 'RCS ; CVS works like RCS in this regard.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2130 nil ; ClearCase does not recognise headers.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2131 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2132 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2134 ;; Back-end-dependent stuff ends here.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2135
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2136 ;; Set up key bindings for use while editing log messages
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2137
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2138 (defun vc-log-mode ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2139 "Minor mode for driving version-control tools.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2140 These bindings are added to the global keymap when you enter this mode:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2141 \\[vc-next-action] perform next logical version-control operation on current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2142 \\[vc-register] register current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2143 \\[vc-toggle-read-only] like next-action, but won't register files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2144 \\[vc-insert-headers] insert version-control headers in current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2145 \\[vc-print-log] display change history of current file
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2146 \\[vc-revert-buffer] revert buffer to latest version
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2147 \\[vc-cancel-version] undo latest checkin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2148 \\[vc-diff] show diffs between file versions
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2149 \\[vc-version-other-window] visit old version in another window
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2150 \\[vc-directory] show all files locked by any user in or below .
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2151 \\[vc-update-change-log] add change log entry from recent checkins
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2152
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2153 While you are entering a change log message for a version, the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2154 additional bindings will be in effect.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2155
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2156 \\[vc-finish-logentry] proceed with check in, ending log message entry
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2157
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2158 Whenever you do a checkin, your log comment is added to a ring of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2159 saved comments. These can be recalled as follows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2160
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2161 \\[vc-next-comment] replace region with next message in comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2162 \\[vc-previous-comment] replace region with previous message in comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2163 \\[vc-comment-search-reverse] search backward for regexp in the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2164 \\[vc-comment-search-forward] search backward for regexp in the comment ring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2165
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2166 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
2167 the value of vc-log-mode-hook.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2168
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2169 Global user options:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2170 vc-initial-comment If non-nil, require user to enter a change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2171 comment upon first checkin of the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2172
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2173 vc-keep-workfiles Non-nil value prevents workfiles from being
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2174 deleted when changes are checked in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2175
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2176 vc-suppress-confirm Suppresses some confirmation prompts,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2177 notably for reversions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2179 vc-header-alist Which keywords to insert when adding headers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2180 with \\[vc-insert-headers]. Defaults to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2181 '(\"\%\W\%\") under SCCS, '(\"\$Id\$\") under
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2182 RCS and CVS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2183
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2184 vc-static-header-alist By default, version headers inserted in C files
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2185 get stuffed in a static string area so that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2186 ident(RCS/CVS) or what(SCCS) can see them in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2187 the compiled object code. You can override
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2188 this by setting this variable to nil, or change
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2189 the header template by changing it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2190
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2191 vc-command-messages if non-nil, display run messages from the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2192 actual version-control utilities (this is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2193 intended primarily for people hacking vc
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2194 itself).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2195 "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2196 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2197 (set-syntax-table text-mode-syntax-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2198 (use-local-map vc-log-entry-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2199 (setq local-abbrev-table text-mode-abbrev-table)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2200 (setq major-mode 'vc-log-mode)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2201 (setq mode-name "VC-Log")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2202 (make-local-variable 'vc-log-file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2203 (make-local-variable 'vc-log-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2204 (make-local-variable 'vc-comment-ring-index)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2205 (set-buffer-modified-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2206 (setq buffer-file-name nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2207 (run-hooks 'text-mode-hook 'vc-log-mode-hook)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2208 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2210 ;; Initialization code, to be done just once at load-time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2211 (if vc-log-entry-mode
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2212 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2213 (setq vc-log-entry-mode (make-sparse-keymap))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2214 (set-keymap-name vc-log-entry-mode 'vc-log-entry-mode) ; XEmacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2215 (define-key vc-log-entry-mode "\M-n" 'vc-next-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2216 (define-key vc-log-entry-mode "\M-p" 'vc-previous-comment)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2217 (define-key vc-log-entry-mode "\M-r" 'vc-comment-search-reverse)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2218 (define-key vc-log-entry-mode "\M-s" 'vc-comment-search-forward)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2219 (define-key vc-log-entry-mode "\C-c\C-c" 'vc-finish-logentry)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2220 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2221
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2222 ;;; These things should probably be generally available
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2223
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2224 (defun vc-file-tree-walk (func &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2225 "Walk recursively through default directory.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2226 Invoke FUNC f ARGS on each non-directory file f underneath it."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2227 (vc-file-tree-walk-internal default-directory func args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2228 (message "Traversing directory %s...done" default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2229
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2230 (defun vc-file-tree-walk-internal (file func args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2231 (if (not (file-directory-p file))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2232 (apply func file args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2233 (message "Traversing directory %s..." file)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2234 (let ((dir (file-name-as-directory file)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2235 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2236 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2237 (lambda (f) (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2238 (string-equal f ".")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2239 (string-equal f "..")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2240 (member f vc-directory-exclusion-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2241 (let ((dirf (concat dir f)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2242 (or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2243 (file-symlink-p dirf) ; Avoid possible loops
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2244 (vc-file-tree-walk-internal dirf func args))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2245 (directory-files dir)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2247 (defun vc-dir-all-files (func &rest args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2248 "Invoke FUNC f ARGS on each regular file f in default directory."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2249 (let ((dir default-directory))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2250 (message "Scanning directory %s..." dir)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2251 (mapcar (function (lambda (f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2252 (let ((dirf (expand-file-name f dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2253 (if (not (file-directory-p dirf))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2254 (apply func dirf args)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2255 (directory-files dir))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2256 (message "Scanning directory %s...done" dir)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2257
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2258 (provide 'vc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2259
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2260 ;;; DEVELOPER'S NOTES ON CONCURRENCY PROBLEMS IN THIS CODE
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2261 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2262 ;;; These may be useful to anyone who has to debug or extend the package.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2263 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2264 ;;; A fundamental problem in VC is that there are time windows between
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2265 ;;; vc-next-action's computations of the file's version-control state and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2266 ;;; the actions that change it. This is a window open to lossage in a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2267 ;;; multi-user environment; someone else could nip in and change the state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2268 ;;; of the master during it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2269 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2270 ;;; The performance problem is that rlog/prs calls are very expensive; we want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2271 ;;; to avoid them as much as possible.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2272 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2273 ;;; ANALYSIS:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2274 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2275 ;;; The performance problem, it turns out, simplifies in practice to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2276 ;;; problem of making vc-locking-user fast. The two other functions that call
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2277 ;;; prs/rlog will not be so commonly used that the slowdown is a problem; one
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2278 ;;; makes snapshots, the other deletes the calling user's last change in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2279 ;;; master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2280 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2281 ;;; The race condition implies that we have to either (a) lock the master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2282 ;;; during the entire execution of vc-next-action, or (b) detect and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2283 ;;; recover from errors resulting from dispatch on an out-of-date state.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2284 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2285 ;;; Alternative (a) appears to be unfeasible. The problem is that we can't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2286 ;;; guarantee that the lock will ever be removed. Suppose a user starts a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2287 ;;; checkin, the change message buffer pops up, and the user, having wandered
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2288 ;;; off to do something else, simply forgets about it?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2289 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2290 ;;; Alternative (b), on the other hand, works well with a cheap way to speed up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2291 ;;; vc-locking-user. Usually, if a file is registered, we can read its locked/
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2292 ;;; unlocked state and its current owner from its permissions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2293 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2294 ;;; This shortcut will fail if someone has manually changed the workfile's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2295 ;;; permissions; also if developers are munging the workfile in several
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2296 ;;; directories, with symlinks to a master (in this latter case, the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2297 ;;; permissions shortcut will fail to detect a lock asserted from another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2298 ;;; directory).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2299 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2300 ;;; Note that these cases correspond exactly to the errors which could happen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2301 ;;; because of a competing checkin/checkout race in between two instances of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2302 ;;; vc-next-action.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2303 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2304 ;;; For VC's purposes, a workfile/master pair may have the following states:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2305 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2306 ;;; A. Unregistered. There is a workfile, there is no master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2307 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2308 ;;; B. Registered and not locked by anyone.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2309 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2310 ;;; C. Locked by calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2311 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2312 ;;; D. Locked by the calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2313 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2314 ;;; E. Locked by someone other than the calling user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2315 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2316 ;;; This makes for 25 states and 20 error conditions. Here's the matrix:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2317 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2318 ;;; VC's idea of state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2319 ;;; |
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2320 ;;; V Actual state RCS action SCCS action Effect
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2321 ;;; A B C D E
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2322 ;;; A . 1 2 3 4 ci -u -t- admin -fb -i<file> initial admin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2323 ;;; B 5 . 6 7 8 co -l get -e checkout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2324 ;;; C 9 10 . 11 12 co -u unget; get revert
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2325 ;;; D 13 14 15 . 16 ci -u -m<comment> delta -y<comment>; get checkin
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2326 ;;; E 17 18 19 20 . rcs -u -M ; rcs -l unget -n ; get -g steal lock
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2327 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2328 ;;; All commands take the master file name as a last argument (not shown).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2329 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2330 ;;; In the discussion below, a "self-race" is a pathological situation in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2331 ;;; which VC operations are being attempted simultaneously by two or more
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2332 ;;; Emacsen running under the same username.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2333 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2334 ;;; The vc-next-action code has the following windows:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2335 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2336 ;;; Window P:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2337 ;;; Between the check for existence of a master file and the call to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2338 ;;; admin/checkin in vc-buffer-admin (apparent state A). This window may
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2339 ;;; never close if the initial-comment feature is on.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2340 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2341 ;;; Window Q:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2342 ;;; Between the call to vc-workfile-unchanged-p in and the immediately
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2343 ;;; following revert (apparent state C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2344 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2345 ;;; Window R:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2346 ;;; Between the call to vc-workfile-unchanged-p in and the following
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2347 ;;; checkin (apparent state D). This window may never close.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2348 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2349 ;;; Window S:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2350 ;;; Between the unlock and the immediately following checkout during a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2351 ;;; revert operation (apparent state C). Included in window Q.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2352 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2353 ;;; Window T:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2354 ;;; Between vc-locking-user and the following checkout (apparent state B).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2355 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2356 ;;; Window U:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2357 ;;; Between vc-locking-user and the following revert (apparent state C).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2358 ;;; Includes windows Q and S.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2359 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2360 ;;; Window V:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2361 ;;; Between vc-locking-user and the following checkin (apparent state
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2362 ;;; D). This window may never be closed if the user fails to complete the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2363 ;;; checkin message. Includes window R.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2364 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2365 ;;; Window W:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2366 ;;; Between vc-locking-user and the following steal-lock (apparent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2367 ;;; state E). This window may never close if the user fails to complete
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2368 ;;; the steal-lock message. Includes window X.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2369 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2370 ;;; Window X:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2371 ;;; Between the unlock and the immediately following re-lock during a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2372 ;;; steal-lock operation (apparent state E). This window may never cloce
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2373 ;;; if the user fails to complete the steal-lock message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2374 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2375 ;;; Errors:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2376 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2377 ;;; Apparent state A ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2378 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2379 ;;; 1. File looked unregistered but is actually registered and not locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2380 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2381 ;;; Potential cause: someone else's admin during window P, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2382 ;;; caller's admin happening before their checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2383 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2384 ;;; RCS: ci will fail with a "no lock set by <user>" message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2385 ;;; SCCS: admin will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2386 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2387 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2388 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2389 ;;; 2. File looked unregistered but is actually locked by caller, unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2390 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2391 ;;; Potential cause: self-race during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2392 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2393 ;;; RCS: will revert the file to the last saved version and unlock it.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2394 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2395 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2396 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2397 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2398 ;;; 3. File looked unregistered but is actually locked by caller, changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2399 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2400 ;;; Potential cause: self-race during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2401 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2402 ;;; RCS: will register the caller's workfile as a delta with a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2403 ;;; null change comment (the -t- switch will be ignored).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2404 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2405 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2406 ;;; 4. File looked unregistered but is locked by someone else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2407 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2408 ;;; Potential cause: someone else's admin during window P, with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2409 ;;; caller's admin happening *after* their checkout.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2410 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2411 ;;; RCS: will fail with a "no lock set by <user>" message.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2412 ;;; SCCS: will fail with error (ad19).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2413 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2414 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2415 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2416 ;;; Apparent state B ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2417 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2418 ;;; 5. File looked registered and not locked, but is actually unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2419 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2420 ;;; Potential cause: master file got nuked during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2421 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2422 ;;; RCS: will fail with "RCS/<file>: No such file or directory"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2423 ;;; SCCS: will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2424 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2425 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2426 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2427 ;;; 6. File looked registered and not locked, but is actually locked by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2428 ;;; calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2429 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2430 ;;; Potential cause: self-race during window T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2431 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2432 ;;; RCS: in the same directory as the previous workfile, co -l will fail
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2433 ;;; with "co error: writable foo exists; checkout aborted". In any other
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2434 ;;; directory, checkout will succeed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2435 ;;; SCCS: will fail with ge17.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2436 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2437 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2438 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2439 ;;; 7. File looked registered and not locked, but is actually locked by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2440 ;;; calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2441 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2442 ;;; As case 6.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2443 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2444 ;;; 8. File looked registered and not locked, but is actually locked by another
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2445 ;;; user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2446 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2447 ;;; Potential cause: someone else checks it out during window T.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2448 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2449 ;;; RCS: co error: revision 1.3 already locked by <user>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2450 ;;; SCCS: fails with ge4 (in directory) or ut7 (outside it).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2451 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2452 ;;; We can let these errors be passed up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2453 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2454 ;;; Apparent state C ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2455 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2456 ;;; 9. File looks locked by calling user and unchanged, but is unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2457 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2458 ;;; As case 5.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2459 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2460 ;;; 10. File looks locked by calling user and unchanged, but is actually not
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2461 ;;; locked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2462 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2463 ;;; Potential cause: a self-race in window U, or by the revert's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2464 ;;; landing during window X of some other user's steal-lock or window S
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2465 ;;; of another user's revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2466 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2467 ;;; RCS: succeeds, refreshing the file from the identical version in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2468 ;;; the master.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2469 ;;; SCCS: fails with error ut4 (p file nonexistent).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2470 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2471 ;;; Either of these consequences is acceptable.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2472 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2473 ;;; 11. File is locked by calling user. It looks unchanged, but is actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2474 ;;; changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2475 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2476 ;;; Potential cause: the file would have to be touched by a self-race
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2477 ;;; during window Q.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2478 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2479 ;;; The revert will succeed, removing whatever changes came with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2480 ;;; the touch. It is theoretically possible that work could be lost.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2481 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2482 ;;; 12. File looks like it's locked by the calling user and unchanged, but
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2483 ;;; it's actually locked by someone else.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2484 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2485 ;;; Potential cause: a steal-lock in window V.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2486 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2487 ;;; RCS: co error: revision <rev> locked by <user>; use co -r or rcs -u
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2488 ;;; SCCS: fails with error un2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2489 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2490 ;;; We can pass these errors up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2491 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2492 ;;; Apparent state D ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2493 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2494 ;;; 13. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2495 ;;; actually unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2496 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2497 ;;; Potential cause: master file got nuked during window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2498 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2499 ;;; RCS: Checks in the user's version as an initial delta.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2500 ;;; SCCS: will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2501 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2502 ;;; This case is kind of nasty. It means VC may fail to detect the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2503 ;;; loss of previous version information.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2504 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2505 ;;; 14. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2506 ;;; actually unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2507 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2508 ;;; Potential cause: self-race in window V, or the checkin happening
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2509 ;;; during the window X of someone else's steal-lock or window S of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2510 ;;; someone else's revert.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2511 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2512 ;;; RCS: ci will fail with "no lock set by <user>".
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2513 ;;; SCCS: delta will fail with error ut4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2514 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2515 ;;; 15. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2516 ;;; actually locked by the calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2517 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2518 ;;; Potential cause: another self-race --- a whole checkin/checkout
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2519 ;;; sequence by the calling user would have to land in window R.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2520 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2521 ;;; SCCS: checks in a redundant delta and leaves the file unlocked as usual.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2522 ;;; RCS: reverts to the file state as of the second user's checkin, leaving
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2523 ;;; the file unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2524 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2525 ;;; It is theoretically possible that work could be lost under RCS.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2526 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2527 ;;; 16. File looks like it's locked by the calling user and changed, but it's
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2528 ;;; actually locked by a different user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2529 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2530 ;;; RCS: ci error: no lock set by <user>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2531 ;;; SCCS: unget will fail with error un2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2532 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2533 ;;; We can pass these errors up to the user.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2534 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2535 ;;; Apparent state E ---
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2536 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2537 ;;; 17. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2538 ;;; unregistered.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2539 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2540 ;;; As case 13.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2541 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2542 ;;; 18. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2543 ;;; unlocked.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2544 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2545 ;;; Potential cause: someone released a lock during window W.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2546 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2547 ;;; RCS: The calling user will get the lock on the file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2548 ;;; SCCS: unget -n will fail with cm4.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2549 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2550 ;;; Either of these consequences will be OK.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2551 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2552 ;;; 19. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2553 ;;; locked by the calling user and unchanged.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2554 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2555 ;;; Potential cause: the other user relinquishing a lock followed by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2556 ;;; a self-race, both in window W.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2557 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2558 ;;; Under both RCS and SCCS, both unlock and lock will succeed, making
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2559 ;;; the sequence a no-op.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2560 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2561 ;;; 20. File looks like it's locked by some other user, but it's actually
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2562 ;;; locked by the calling user and changed.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2563 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2564 ;;; As case 19.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2565 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2566 ;;; PROBLEM CASES:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2567 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2568 ;;; In order of decreasing severity:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2569 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2570 ;;; Cases 11 and 15 under RCS are the only one that potentially lose work.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2571 ;;; They would require a self-race for this to happen.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2572 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2573 ;;; Case 13 in RCS loses information about previous deltas, retaining
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2574 ;;; only the information in the current workfile. This can only happen
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2575 ;;; if the master file gets nuked in window P.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2576 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2577 ;;; Case 3 in RCS and case 15 under SCCS insert a redundant delta with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2578 ;;; no change comment in the master. This would require a self-race in
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2579 ;;; window P or R respectively.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2580 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2581 ;;; Cases 2, 10, 19 and 20 do extra work, but make no changes.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2582 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2583 ;;; Unfortunately, it appears to me that no recovery is possible in these
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2584 ;;; cases. They don't yield error messages, so there's no way to tell that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2585 ;;; a race condition has occurred.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2586 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2587 ;;; All other cases don't change either the workfile or the master, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2588 ;;; trigger command errors which the user will see.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2589 ;;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2590 ;;; Thus, there is no explicit recovery code.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2591
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2592 ;;; vc.el ends here