50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; vc-mcvs.el --- VC backend for the Meta-CVS version-control system
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
3 ;; Copyright (C) 1995,98,99,2000,01,02,2003 Free Software Foundation, Inc.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: FSF (see vc.el for full credits)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Maintainer: Stefan Monnier <monnier@gnu.org>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 ;; This file is part of GNU Emacs.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12 ;; the Free Software Foundation; either version 2, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 ;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;; Boston, MA 02111-1307, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 ;;; Commentary:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26
|
50779
|
27 ;; The home page of the Meta-CVS version control system is at
|
|
28 ;;
|
|
29 ;; http://users.footprints.net/~kaz/mcvs.html
|
|
30 ;;
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;; This is derived from vc-cvs.el as follows:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; - cp vc-cvs.el vc-mcvs.el
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 ;; - Replace CVS/ with MCVS/CVS/
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34 ;; - Replace 'CVS with 'MCVS
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 ;; - Replace -cvs- with -mcvs-
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 ;; - Replace most of the rest of CVS to Meta-CVS
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 ;; Then of course started the hacking. Only a small part of the code
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39 ;; has been touched and not much more than that was tested, so if
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;; you bump into a bug, don't be surprised: just report it to me.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 ;; What has been partly tested:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 ;; - C-x v v to start editing a file that was checked out with CVSREAD on.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44 ;; - C-x v v to commit a file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 ;; - C-x v =
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 ;; - C-x v l
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47 ;; - C-x v i
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 ;; - C-x v g
|
50808
|
49 ;; - M-x vc-rename-file RET
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 ;;; Bugs:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53 ;; - VC-dired doesn't work.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 ;;; Code:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 (eval-when-compile (require 'vc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 (require 'vc-cvs)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61 ;;; Customization options
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (defcustom vc-mcvs-global-switches nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 "*Global switches to pass to any Meta-CVS command."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 :type '(choice (const :tag "None" nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67 (string :tag "Argument String")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (repeat :tag "Argument List"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 :value ("")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 (defcustom vc-mcvs-register-switches nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 "*Extra switches for registering a file into Meta-CVS.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 A string or list of strings passed to the checkin program by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 \\[vc-register]."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 :type '(choice (const :tag "None" nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
79 (string :tag "Argument String")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
80 (repeat :tag "Argument List"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
81 :value ("")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
82 string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
83 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
85
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 (defcustom vc-mcvs-diff-switches nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 "*A string or list of strings specifying extra switches for cvs diff under VC."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 :type '(choice (const :tag "None" nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 (string :tag "Argument String")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 (repeat :tag "Argument List"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 :value ("")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 string))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 (defcustom vc-mcvs-header (or (cdr (assoc 'MCVS vc-header-alist))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 vc-cvs-header)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 "*Header keywords to be inserted by `vc-insert-headers'."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 :type '(repeat string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 (defcustom vc-mcvs-use-edit vc-cvs-use-edit
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104 "*Non-nil means to use `cvs edit' to \"check out\" a file.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 This is only meaningful if you don't use the implicit checkout model
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 \(i.e. if you have $CVSREAD set)."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107 :type 'boolean
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 (defcustom vc-mcvs-stay-local vc-cvs-stay-local
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 "*Non-nil means use local operations when possible for remote repositories.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 This avoids slow queries over the network and instead uses heuristics
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
114 and past information to determine the current status of a file.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 The value can also be a regular expression to match against the host name
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116 of a repository; then VC only stays local for hosts that match it."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 :type '(choice (const :tag "Always stay local" t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 (string :tag "Host regexp")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (const :tag "Don't stay local" nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 :version "21.4"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 ;;; State-querying functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 ;;;###autoload (defun vc-mcvs-registered (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 ;;;###autoload (let ((dir file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129 ;;;###autoload (while (and (stringp dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 ;;;###autoload (not (equal dir (setq dir (file-name-directory dir)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 ;;;###autoload (setq dir (if (file-directory-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132 ;;;###autoload (expand-file-name "MCVS/CVS" dir))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 ;;;###autoload t (directory-file-name dir))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 ;;;###autoload (if (eq dir t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135 ;;;###autoload (progn
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 ;;;###autoload (load "vc-mcvs")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 ;;;###autoload (vc-mcvs-registered file)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
139 (defun vc-mcvs-root (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 "Return the root directory of a Meta-CVS project, if any."
|
50667
|
141 (or (vc-file-getprop file 'mcvs-root)
|
|
142 (vc-file-setprop
|
|
143 file 'mcvs-root
|
|
144 (let ((root nil))
|
|
145 (while (not (or root
|
|
146 (equal file (setq file (file-name-directory file)))))
|
|
147 (if (file-directory-p (expand-file-name "MCVS/CVS" file))
|
|
148 (setq root file)
|
|
149 (setq file (directory-file-name file))))
|
|
150 root))))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (defun vc-mcvs-read (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154 (insert-file-contents file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
155 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
156 (read (current-buffer))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
157
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
158 (defun vc-mcvs-map-file (dir file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 (let ((map (vc-mcvs-read (expand-file-name "MCVS/MAP" dir)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 inode)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 (dolist (x map inode)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 (if (equal (nth 2 x) file) (setq inode (nth 1 x))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 (defun vc-mcvs-registered (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 (let (root inode cvsfile)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 (when (and (setq root (vc-mcvs-root file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 (setq inode (vc-mcvs-map-file
|
50667
|
168 root (file-relative-name file root))))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 (vc-file-setprop file 'mcvs-inode inode)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 ;; Avoid calling `mcvs diff' in vc-workfile-unchanged-p.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171 (vc-file-setprop file 'vc-checkout-time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
172 (if (vc-cvs-registered
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 (setq cvsfile (expand-file-name inode root)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174 (vc-file-getprop cvsfile 'vc-checkout-time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 ;; The file might not be registered yet because
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176 ;; of lazy-adding.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 t)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
179
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180 (defmacro vc-mcvs-cvs (op file &rest args)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 (declare (debug t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 `(,(intern (concat "vc-cvs-" (symbol-name op)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
183 (expand-file-name (vc-file-getprop ,file 'mcvs-inode)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184 (vc-file-getprop ,file 'mcvs-root))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 ,@args))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 (defun vc-mcvs-state (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
188 ;; This would assume the Meta-CVS sandbox is synchronized.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189 ;; (vc-mcvs-cvs state file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 "Meta-CVS-specific version of `vc-state'."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
191 (if (vc-mcvs-stay-local-p file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 (let ((state (vc-file-getprop file 'vc-state)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
193 ;; If we should stay local, use the heuristic but only if
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 ;; we don't have a more precise state already available.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 (if (memq state '(up-to-date edited))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
196 (vc-mcvs-state-heuristic file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197 state))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 (cd (file-name-directory file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 (vc-mcvs-command t 0 file "status")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (vc-cvs-parse-status t))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 (defalias 'vc-mcvs-state-heuristic 'vc-cvs-state-heuristic)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
205
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 (defun vc-mcvs-dir-state (dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 "Find the Meta-CVS state of all files in DIR."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 ;; if DIR is not under Meta-CVS control, don't do anything.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 (when (file-readable-p (expand-file-name "MCVS/CVS/Entries" dir))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 (if (vc-mcvs-stay-local-p dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211 (vc-mcvs-dir-state-heuristic dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (let ((default-directory dir))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 ;; Don't specify DIR in this command, the default-directory is
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
214 ;; enough. Otherwise it might fail with remote repositories.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (vc-mcvs-command t 0 nil "status" "-l")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 (while (re-search-forward "^=+\n\\([^=\n].*\n\\|\n\\)+" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219 (narrow-to-region (match-beginning 0) (match-end 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 (vc-cvs-parse-status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
221 (goto-char (point-max))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 (widen)))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (defun vc-mcvs-workfile-version (file) (vc-mcvs-cvs workfile-version file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 (defalias 'vc-mcvs-checkout-model 'vc-cvs-checkout-model)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227
|
50808
|
228 (defun vc-mcvs-mode-line-string (file)
|
|
229 (let ((s (vc-mcvs-cvs mode-line-string file)))
|
|
230 (if s (concat "M" s))))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 ;;; State-changing functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 (defun vc-mcvs-register (file &optional rev comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237 "Register FILE into the Meta-CVS version-control system.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 COMMENT can be used to provide an initial description of FILE.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 `vc-register-switches' and `vc-mcvs-register-switches' are passed to
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 the Meta-CVS command (in that order)."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (let* ((filename (file-name-nondirectory file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 (extpos (string-match "\\." filename))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 (ext (if extpos (substring filename (1+ extpos))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 (root (vc-mcvs-root file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246 (types-file (expand-file-name "MCVS/TYPES" root))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
247 (map-file (expand-file-name "MCVS/MAP" root))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 (types (vc-mcvs-read types-file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 ;; Make sure meta files like MCVS/MAP are not read-only (happens with
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
250 ;; CVSREAD) since Meta-CVS doesn't pay attention to it at all and goes
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
251 ;; belly-up.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 (unless (file-writable-p map-file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (vc-checkout map-file t))
|
50667
|
254 (unless (or (file-writable-p types-file) (not (file-exists-p types-file)))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 (vc-checkout types-file t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 ;; Make sure the `mcvs add' will not fire up the CVSEDITOR
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 ;; to add a rule for the given file's extension.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (when (and ext (not (assoc ext types)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 (let ((type (completing-read "Type to use [default]: "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 '("default" "name-only" "keep-old"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 "binary" "value-only")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 nil t nil nil "default")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 (push (list ext (make-symbol (upcase (concat ":" type)))) types)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264 (setq types (sort types (lambda (x y) (string< (car x) (car y)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 (with-current-buffer (find-file-noselect types-file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 (erase-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 (pp types (current-buffer))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 (save-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 (unless (get-buffer-window (current-buffer) t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (kill-buffer (current-buffer)))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 ;; Now do the ADD.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 (let ((switches (append
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 (if (stringp vc-register-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 (list vc-register-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 vc-register-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 (if (stringp vc-mcvs-register-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 (list vc-mcvs-register-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 vc-mcvs-register-switches))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (prog1 (apply 'vc-mcvs-command nil 0 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280 "add"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 (and comment (string-match "[^\t\n ]" comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 (concat "-m" comment))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 ;; I'm not sure exactly why, but if we don't setup the inode and root
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285 ;; prop of the file, things break later on in vc-mode-line that
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286 ;; ends up calling vc-mcvs-workfile-version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287 ;; We also need to set vc-checkout-time so that vc-workfile-unchanged-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 ;; doesn't try to call `mcvs diff' on the file.
|
50667
|
289 (vc-mcvs-registered file))))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 (defalias 'vc-mcvs-responsible-p 'vc-mcvs-root
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
292 "Return non-nil if CVS thinks it is responsible for FILE.")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
293
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
294 (defalias 'vc-cvs-could-register 'vc-cvs-responsible-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
295 "Return non-nil if FILE could be registered in Meta-CVS.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
296 This is only possible if Meta-CVS is responsible for FILE's directory.")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
297
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
298 (defun vc-mcvs-checkin (file rev comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
299 "Meta-CVS-specific version of `vc-backend-checkin'."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
300 (let ((switches (if (stringp vc-checkin-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
301 (list vc-checkin-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
302 vc-checkin-switches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
303 status)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
304 (if (or (not rev) (vc-mcvs-valid-version-number-p rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
305 (setq status (apply 'vc-mcvs-command nil 1 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
306 "ci" (if rev (concat "-r" rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
307 "-m" comment
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
308 switches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
309 (if (not (vc-mcvs-valid-symbolic-tag-name-p rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
310 (error "%s is not a valid symbolic tag name" rev)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
311 ;; If the input revison is a valid symbolic tag name, we create it
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
312 ;; as a branch, commit and switch to it.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
313 (apply 'vc-mcvs-command nil 0 file "tag" "-b" (list rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
314 (apply 'vc-mcvs-command nil 0 file "update" "-r" (list rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
315 (setq status (apply 'vc-mcvs-command nil 1 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
316 "ci"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
317 "-m" comment
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
318 switches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
319 (vc-file-setprop file 'vc-mcvs-sticky-tag rev)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
320 (set-buffer "*vc*")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
321 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
322 (when (not (zerop status))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
323 ;; Check checkin problem.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
324 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
325 ((re-search-forward "Up-to-date check failed" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
326 (vc-file-setprop file 'vc-state 'needs-merge)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
327 (error (substitute-command-keys
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
328 (concat "Up-to-date check failed: "
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
329 "type \\[vc-next-action] to merge in changes"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
330 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
331 (pop-to-buffer (current-buffer))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
332 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
333 (shrink-window-if-larger-than-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
334 (error "Check-in failed"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
335 ;; Update file properties
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
336 (vc-file-setprop
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
337 file 'vc-workfile-version
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
338 (vc-parse-buffer "^\\(new\\|initial\\) revision: \\([0-9.]+\\)" 2))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
339 ;; Forget the checkout model of the file, because we might have
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
340 ;; guessed wrong when we found the file. After commit, we can
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
341 ;; tell it from the permissions of the file (see
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
342 ;; vc-mcvs-checkout-model).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
343 (vc-file-setprop file 'vc-checkout-model nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
344
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
345 ;; if this was an explicit check-in (does not include creation of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
346 ;; a branch), remove the sticky tag.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
347 (if (and rev (not (vc-mcvs-valid-symbolic-tag-name-p rev)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
348 (vc-mcvs-command nil 0 file "update" "-A"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
349
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
350 (defun vc-mcvs-find-version (file rev buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
351 (apply 'vc-mcvs-command
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
352 buffer 0 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
353 "-Q" ; suppress diagnostic output
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
354 "update"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
355 (and rev (not (string= rev ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
356 (concat "-r" rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
357 "-p"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
358 (if (stringp vc-checkout-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
359 (list vc-checkout-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
360 vc-checkout-switches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
361
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
362 (defun vc-mcvs-checkout (file &optional editable rev)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
363 (message "Checking out %s..." file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
364 (with-current-buffer (or (get-file-buffer file) (current-buffer))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
365 (let ((switches (if (stringp vc-checkout-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
366 (list vc-checkout-switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
367 vc-checkout-switches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
368 (vc-call update file editable rev switches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
369 (vc-mode-line file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
370 (message "Checking out %s...done" file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
371
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
372 (defun vc-mcvs-update (file editable rev switches)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
373 (if (and (file-exists-p file) (not rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
374 ;; If no revision was specified, just make the file writable
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
375 ;; if necessary (using `cvs-edit' if requested).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
376 (and editable (not (eq (vc-mcvs-checkout-model file) 'implicit))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
377 (if vc-mcvs-use-edit
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
378 (vc-mcvs-command nil 0 file "edit")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
379 (set-file-modes file (logior (file-modes file) 128))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
380 (if (equal file buffer-file-name) (toggle-read-only -1))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
381 ;; Check out a particular version (or recreate the file).
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
382 (vc-file-setprop file 'vc-workfile-version nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
383 (apply 'vc-mcvs-command nil 0 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
384 (if editable "-w")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
385 "update"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
386 ;; default for verbose checkout: clear the sticky tag so
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
387 ;; that the actual update will get the head of the trunk
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
388 (if (or (not rev) (string= rev ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
389 "-A"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
390 (concat "-r" rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
391 switches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
392
|
50808
|
393 (defun vc-mcvs-rename-file (old new)
|
|
394 (vc-mcvs-command nil 0 new "move" (file-relative-name old)))
|
|
395
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
396 (defun vc-mcvs-revert (file &optional contents-done)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
397 "Revert FILE to the version it was based on."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
398 (vc-default-revert file contents-done)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
399 (unless (eq (vc-checkout-model file) 'implicit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
400 (if vc-mcvs-use-edit
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
401 (vc-mcvs-command nil 0 file "unedit")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
402 ;; Make the file read-only by switching off all w-bits
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
403 (set-file-modes file (logand (file-modes file) 3950)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
404
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
405 (defun vc-mcvs-merge (file first-version &optional second-version)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
406 "Merge changes into current working copy of FILE.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
407 The changes are between FIRST-VERSION and SECOND-VERSION."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
408 (vc-mcvs-command nil 0 file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
409 "update" "-kk"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
410 (concat "-j" first-version)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
411 (concat "-j" second-version))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
412 (vc-file-setprop file 'vc-state 'edited)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
413 (with-current-buffer (get-buffer "*vc*")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
414 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
415 (if (re-search-forward "conflicts during merge" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
416 1 ; signal error
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
417 0))) ; signal success
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
418
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
419 (defun vc-mcvs-merge-news (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
420 "Merge in any new changes made to FILE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
421 (message "Merging changes into %s..." file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
422 ;; (vc-file-setprop file 'vc-workfile-version nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
423 (vc-file-setprop file 'vc-checkout-time 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
424 (vc-mcvs-command nil 0 file "update")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
425 ;; Analyze the merge result reported by Meta-CVS, and set
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
426 ;; file properties accordingly.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
427 (with-current-buffer (get-buffer "*vc*")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
428 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
429 ;; get new workfile version
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
430 (if (re-search-forward
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
431 "^Merging differences between [0-9.]* and \\([0-9.]*\\) into" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
432 (vc-file-setprop file 'vc-workfile-version (match-string 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
433 (vc-file-setprop file 'vc-workfile-version nil))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
434 ;; get file status
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
435 (prog1
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
436 (if (eq (buffer-size) 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
437 0 ;; there were no news; indicate success
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
438 (if (re-search-forward
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
439 (concat "^\\([CMUP] \\)?"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
440 ".*"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
441 "\\( already contains the differences between \\)?")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
442 nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
443 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
444 ;; Merge successful, we are in sync with repository now
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
445 ((or (match-string 2)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
446 (string= (match-string 1) "U ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
447 (string= (match-string 1) "P "))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
448 (vc-file-setprop file 'vc-state 'up-to-date)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
449 (vc-file-setprop file 'vc-checkout-time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
450 (nth 5 (file-attributes file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
451 0);; indicate success to the caller
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
452 ;; Merge successful, but our own changes are still in the file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
453 ((string= (match-string 1) "M ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
454 (vc-file-setprop file 'vc-state 'edited)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
455 0);; indicate success to the caller
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
456 ;; Conflicts detected!
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
457 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
458 (vc-file-setprop file 'vc-state 'edited)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
459 1);; signal the error to the caller
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
460 )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
461 (pop-to-buffer "*vc*")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
462 (error "Couldn't analyze mcvs update result")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
463 (message "Merging changes into %s...done" file))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
464
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
465 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
466 ;;; History functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
467 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
468
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
469 (defun vc-mcvs-print-log (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
470 "Get change log associated with FILE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
471 (vc-mcvs-command
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
472 nil
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
473 (if (and (vc-mcvs-stay-local-p file) (fboundp 'start-process)) 'async 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
474 file "log"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
475
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
476 (defun vc-mcvs-diff (file &optional oldvers newvers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
477 "Get a difference report using Meta-CVS between two versions of FILE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
478 (let (status (diff-switches-list (vc-diff-switches-list 'MCVS)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
479 (if (string= (vc-workfile-version file) "0")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
480 ;; This file is added but not yet committed; there is no master file.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
481 (if (or oldvers newvers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
482 (error "No revisions of %s exist" file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
483 ;; We regard this as "changed".
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
484 ;; Diff it against /dev/null.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
485 ;; Note: this is NOT a "mcvs diff".
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
486 (apply 'vc-do-command "*vc-diff*"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
487 1 "diff" file
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
488 (append diff-switches-list '("/dev/null"))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
489 (setq status
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
490 (apply 'vc-mcvs-command "*vc-diff*"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
491 (if (and (vc-mcvs-stay-local-p file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
492 (fboundp 'start-process))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
493 'async
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
494 1)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
495 file "diff"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
496 (and oldvers (concat "-r" oldvers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
497 (and newvers (concat "-r" newvers))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
498 diff-switches-list))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
499 (if (vc-mcvs-stay-local-p file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
500 1 ;; async diff, pessimistic assumption
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
501 status))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
502
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
503 (defun vc-mcvs-diff-tree (dir &optional rev1 rev2)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
504 "Diff all files at and below DIR."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
505 (with-current-buffer "*vc-diff*"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
506 (setq default-directory dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
507 (if (vc-mcvs-stay-local-p dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
508 ;; local diff: do it filewise, and only for files that are modified
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
509 (vc-file-tree-walk
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
510 dir
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
511 (lambda (f)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
512 (vc-exec-after
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
513 `(let ((coding-system-for-read (vc-coding-system-for-diff ',f)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
514 ;; possible optimization: fetch the state of all files
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
515 ;; in the tree via vc-mcvs-dir-state-heuristic
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
516 (unless (vc-up-to-date-p ',f)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
517 (message "Looking at %s" ',f)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
518 (vc-diff-internal ',f ',rev1 ',rev2))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
519 ;; cvs diff: use a single call for the entire tree
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
520 (let ((coding-system-for-read
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
521 (or coding-system-for-read 'undecided)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
522 (apply 'vc-mcvs-command "*vc-diff*" 1 nil "diff"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
523 (and rev1 (concat "-r" rev1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
524 (and rev2 (concat "-r" rev2))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
525 (vc-diff-switches-list 'MCVS))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
526
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
527 (defun vc-mcvs-annotate-command (file buffer &optional version)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
528 "Execute \"mcvs annotate\" on FILE, inserting the contents in BUFFER.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
529 Optional arg VERSION is a version to annotate from."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
530 (vc-mcvs-command
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
531 buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
532 (if (and (vc-mcvs-stay-local-p file) (fboundp 'start-process)) 'async 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
533 file "annotate" (if version (concat "-r" version))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
534
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
535 (defalias 'vc-mcvs-annotate-current-time 'vc-cvs-annotate-current-time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
536 (defalias 'vc-mcvs-annotate-time 'vc-cvs-annotate-time)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
537
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
538 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
539 ;;; Snapshot system
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
540 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
541
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
542 (defun vc-mcvs-create-snapshot (dir name branchp)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
543 "Assign to DIR's current version a given NAME.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
544 If BRANCHP is non-nil, the name is created as a branch (and the current
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
545 workspace is immediately moved to that new branch)."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
546 (vc-mcvs-command nil 0 dir "tag" "-c" (if branchp "-b") name)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
547 (when branchp (vc-mcvs-command nil 0 dir "update" "-r" name)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
548
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
549 (defun vc-mcvs-retrieve-snapshot (dir name update)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
550 "Retrieve a snapshot at and below DIR.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
551 NAME is the name of the snapshot; if it is empty, do a `cvs update'.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
552 If UPDATE is non-nil, then update (resynch) any affected buffers."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
553 (with-current-buffer (get-buffer-create "*vc*")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
554 (let ((default-directory dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
555 (sticky-tag))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
556 (erase-buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
557 (if (or (not name) (string= name ""))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
558 (vc-mcvs-command t 0 nil "update")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
559 (vc-mcvs-command t 0 nil "update" "-r" name)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
560 (setq sticky-tag name))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
561 (when update
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
562 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
563 (while (not (eobp))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
564 (if (looking-at "\\([CMUP]\\) \\(.*\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
565 (let* ((file (expand-file-name (match-string 2) dir))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
566 (state (match-string 1))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
567 (buffer (find-buffer-visiting file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
568 (when buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
569 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
570 ((or (string= state "U")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
571 (string= state "P"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
572 (vc-file-setprop file 'vc-state 'up-to-date)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
573 (vc-file-setprop file 'vc-workfile-version nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
574 (vc-file-setprop file 'vc-checkout-time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
575 (nth 5 (file-attributes file))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
576 ((or (string= state "M")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
577 (string= state "C"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
578 (vc-file-setprop file 'vc-state 'edited)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
579 (vc-file-setprop file 'vc-workfile-version nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
580 (vc-file-setprop file 'vc-checkout-time 0)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
581 (vc-file-setprop file 'vc-mcvs-sticky-tag sticky-tag)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
582 (vc-resynch-buffer file t t))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
583 (forward-line 1))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
584
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
585
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
586 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
587 ;;; Miscellaneous
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
588 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
589
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
590 (defalias 'vc-mcvs-make-version-backups-p 'vc-mcvs-stay-local-p
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
591 "Return non-nil if version backups should be made for FILE.")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
592 (defalias 'vc-mcvs-check-headers 'vc-cvs-check-headers)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
593
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
594
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
595 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
596 ;;; Internal functions
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
597 ;;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
598
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
599 (defun vc-mcvs-command (buffer okstatus file &rest flags)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
600 "A wrapper around `vc-do-command' for use in vc-mcvs.el.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
601 The difference to vc-do-command is that this function always invokes `mcvs',
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
602 and that it passes `vc-mcvs-global-switches' to it before FLAGS."
|
50667
|
603 (let ((args (append '("--error-continue")
|
|
604 (if (stringp vc-mcvs-global-switches)
|
|
605 (cons vc-mcvs-global-switches flags)
|
|
606 (append vc-mcvs-global-switches
|
|
607 flags)))))
|
|
608 (if (member (car flags) '("diff" "log"))
|
|
609 ;; We need to filter the output.
|
|
610 (vc-do-command buffer okstatus "sh" nil "-c"
|
|
611 (concat "mcvs "
|
|
612 (mapconcat
|
|
613 'shell-quote-argument
|
|
614 (append (remq nil args)
|
|
615 (if file (list (file-relative-name file))))
|
|
616 " ")
|
|
617 " | mcvs filt"))
|
|
618 (apply 'vc-do-command buffer okstatus "mcvs" file args))))
|
50646
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
619
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
620 (defun vc-mcvs-stay-local-p (file) (vc-mcvs-cvs stay-local-p file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
621
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
622 (defun vc-mcvs-dir-state-heuristic (dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
623 "Find the Meta-CVS state of all files in DIR, using only local information."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
624 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
625 (vc-cvs-get-entries dir)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
626 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
627 (while (not (eobp))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
628 ;; Meta-MCVS-removed files are not taken under VC control.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
629 (when (looking-at "/\\([^/]*\\)/[^/-]")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
630 (let ((file (expand-file-name (match-string 1) dir)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
631 (unless (vc-file-getprop file 'vc-state)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
632 (vc-cvs-parse-entry file t))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
633 (forward-line 1))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
634
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
635 (defalias 'vc-mcvs-valid-symbolic-tag-name-p 'vc-cvs-valid-symbolic-tag-name-p)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
636 (defalias 'vc-mcvs-valid-version-number-p 'vc-cvs-valid-version-number-p)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
637
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
638 (provide 'vc-mcvs)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
639 ;;; vc-mcvs.el ends here
|