Mercurial > emacs
annotate lisp/vc-arch.el @ 83080:d4d5e54871ff
Trivial cleanups to get rid of GCC warnings.
src/fontset.c (Fset_fontset_font): Removed unused variables.
src/fringe.c (Ffringe_bitmaps_at_pos): Ditto.
src/xdisp.c (Flookup_image_map, note_mode_line_or_margin_highlight): Ditto.
src/xterm.c (x_detect_focus_change, x_calc_absolute_position): Ditto.
src/intervals.h (compare_string_intervals): New declaration.
src/intervals.h (NULL_INTERVAL_P): Shut up GCC warnings by casting the
left side of the comma expression to void.
src/lisp.h (CHECK): Ditto.
src/keyboard.c (modify_event_symbol): Shut up GCC warning about format
template type mismatch.
git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-120
author | Karoly Lorentey <lorentey@elte.hu> |
---|---|
date | Fri, 19 Mar 2004 23:19:04 +0000 |
parents | 504aef04e493 |
children | 2ae29225b85c |
rev | line source |
---|---|
54396 | 1 ;;; vc-arch.el --- VC backend for the Arch version-control system |
2 | |
3 ;; Copyright (C) 1995,98,99,2000,01,02,03,2004 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: FSF (see vc.el for full credits) | |
6 ;; Maintainer: Stefan Monnier <monnier@gnu.org> | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
12 ;; the Free Software Foundation; either version 2, or (at your option) | |
13 ;; any later version. | |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; You should have received a copy of the GNU General Public License | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
23 ;; Boston, MA 02111-1307, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; The home page of the Arch version control system is at | |
28 ;; | |
29 ;; http://www.gnuarch.org/ | |
30 ;; | |
31 ;; This is derived from vc-mcvs.el as follows: | |
32 ;; - cp vc-mcvs.el vc-arch.el and then M-% mcvs RET arch RET | |
33 ;; | |
34 ;; Then of course started the hacking. | |
35 ;; | |
36 ;; What has been partly tested: | |
37 ;; - Open a file | |
38 ;; - C-x v = without any prefix arg | |
39 ;; - C-x v v to commit a change to a single file | |
40 | |
41 ;; Bugs: | |
42 | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
43 ;; - Opening a new file prompts "blabla was lost; check out? (yes or no)". |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
44 ;; - *VC-log*'s initial content lacks the `Summary:' lines. |
54396 | 45 ;; - All files under the tree are considered as "under Arch's control" |
46 ;; without regards to =tagging-method and such. | |
47 ;; - Files are always considered as `edited'. | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
48 ;; - C-x v l does not work. |
54396 | 49 ;; - C-x v i does not work. |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
50 ;; - C-x v ~ does not work. |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
51 ;; - C-x v u does not work. |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
52 ;; - C-x v s does not work. |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
53 ;; - C-x v r does not work. |
54396 | 54 ;; - VC-dired does not work. |
55 ;; - And more... | |
56 | |
57 ;;; Code: | |
58 | |
59 (eval-when-compile (require 'vc)) | |
60 | |
61 ;;; | |
62 ;;; Customization options | |
63 ;;; | |
64 | |
65 (defvar vc-arch-command | |
66 (let ((candidates '("tla"))) | |
67 (while (and candidates (not (executable-find (car candidates)))) | |
68 (setq candidates (cdr candidates))) | |
69 (or (car candidates) "tla"))) | |
70 | |
71 ;; Clear up the cache to force vc-call to check again and discover | |
72 ;; new functions when we reload this file. | |
73 (put 'Arch 'vc-functions nil) | |
74 | |
75 ;;;###autoload (defun vc-arch-registered (file) | |
76 ;;;###autoload (let ((dir file)) | |
77 ;;;###autoload (while (and (stringp dir) | |
78 ;;;###autoload (not (equal | |
79 ;;;###autoload dir (setq dir (file-name-directory dir)))) | |
80 ;;;###autoload dir) | |
81 ;;;###autoload (setq dir (if (file-directory-p | |
82 ;;;###autoload (expand-file-name "{arch}" dir)) | |
83 ;;;###autoload t (directory-file-name dir)))) | |
84 ;;;###autoload (if (eq dir t) | |
85 ;;;###autoload (progn | |
86 ;;;###autoload (load "vc-arch") | |
87 ;;;###autoload (vc-arch-registered file))))) | |
88 | |
89 (defun vc-arch-add-tag () | |
90 "Add an `arch-tag' to the end of the current file." | |
91 (interactive) | |
92 (goto-char (point-max)) | |
93 (forward-comment -1) | |
94 (unless (bolp) (insert "\n")) | |
95 (let ((beg (point))) | |
96 (insert "arch-tag: ") | |
97 (call-process "uuidgen" nil t) ;Also inserts a terminal newline. | |
98 (comment-region beg (point)))) | |
99 | |
100 (defun vc-arch-root (file) | |
101 "Return the root directory of a Arch project, if any." | |
102 (or (vc-file-getprop file 'arch-root) | |
103 (vc-file-setprop | |
104 file 'arch-root | |
105 (let ((root nil)) | |
106 (while (not (or root | |
107 (equal file (setq file (file-name-directory file))) | |
108 (null file))) | |
109 (if (file-directory-p (expand-file-name "{arch}" file)) | |
110 (setq root file) | |
111 (setq file (directory-file-name file)))) | |
112 root)))) | |
113 | |
114 (defun vc-arch-registered (file) | |
115 ;; Don't check whether it's source or not. Checking would require | |
116 ;; running TLA, so it's better to not do it, so it also works if TLA is | |
117 ;; not installed. | |
118 (vc-arch-root file)) | |
119 | |
120 (defun vc-arch-default-version (file) | |
121 (or (vc-file-getprop (vc-arch-root file) 'arch-default-version) | |
122 (let* ((root (vc-arch-root file)) | |
123 (f (expand-file-name "{arch}/++default-version" root))) | |
124 (if (file-readable-p f) | |
125 (vc-file-setprop | |
126 root 'arch-default-version | |
127 (with-temp-buffer | |
128 (insert-file-contents f) | |
129 ;; Strip the terminating newline. | |
130 (buffer-substring (point-min) (1- (point-max))))))))) | |
131 | |
54409
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
132 (defun vc-arch-workfile-unchanged-p (file) |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
133 "Check if FILE is unchanged by diffing against the master version. |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
134 Return non-nil if FILE is unchanged." |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
135 nil) |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
136 |
54396 | 137 (defun vc-arch-state (file) |
138 ;; There's no checkout operation and merging is not done from VC | |
139 ;; so the only operation that's state dependent that VC supports is commit | |
140 ;; which is only activated if the file is `edited'. | |
141 'edited) | |
142 | |
143 (defun vc-arch-workfile-version (file) | |
144 (let* ((root (expand-file-name "{arch}" (vc-arch-root file))) | |
145 (defbranch (vc-arch-default-version file))) | |
146 (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*\\)--.*\\)--.*\\)\\'" defbranch)) | |
147 (let* ((archive (match-string 1 defbranch)) | |
148 (category (match-string 4 defbranch)) | |
149 (branch (match-string 3 defbranch)) | |
150 (version (match-string 2 defbranch)) | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
151 (sealed nil) (rev-nb 0) |
54396 | 152 (rev nil) |
153 logdir tmp) | |
154 (setq logdir (expand-file-name category root)) | |
155 (setq logdir (expand-file-name branch logdir)) | |
156 (setq logdir (expand-file-name version logdir)) | |
157 (setq logdir (expand-file-name archive logdir)) | |
158 (setq logdir (expand-file-name "patch-log" logdir)) | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
159 ;; Revision names go: base-0, patch-N, version-0, versionfix-N. |
54396 | 160 (dolist (file (directory-files logdir)) |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
161 (when (and (eq (aref file 0) ?v) (not sealed)) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
162 (setq sealed t rev-nb 0)) |
54396 | 163 (if (and (string-match "-\\([0-9]+\\)\\'" file) |
164 (setq tmp (string-to-number (match-string 1 file))) | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
165 (or (not sealed) (eq (aref file 0) ?v)) |
54396 | 166 (>= tmp rev-nb)) |
167 (setq rev-nb tmp rev file))) | |
168 (concat defbranch "--" rev))))) | |
169 | |
170 | |
171 (defcustom vc-arch-mode-line-rewrite | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
172 '(("\\`.*--\\(.*--.*\\)--\\(v?\\).*-\\([0-9]+\\)\\'" . "\\2\\3[\\1]")) |
54396 | 173 "Rewrite rules to shorten Arch's revision names on the mode-line." |
174 :type '(repeat (cons regexp string))) | |
175 | |
176 (defun vc-arch-mode-line-string (file) | |
177 "Return string for placement in modeline by `vc-mode-line' for FILE." | |
178 (let ((rev (vc-workfile-version file))) | |
179 (dolist (rule vc-arch-mode-line-rewrite) | |
180 (if (string-match (car rule) rev) | |
181 (setq rev (replace-match (cdr rule) t nil rev)))) | |
182 (format "Arch%c%s" | |
183 (if (memq (vc-state file) '(up-to-date needs-patch)) ?- ?:) | |
184 rev))) | |
185 | |
186 (defun vc-arch-diff3-rej-p (rej) | |
187 (and (eq (nth 7 (file-attributes rej)) 56) | |
188 (with-temp-buffer | |
189 (insert-file-contents rej) | |
190 (goto-char (point-min)) | |
191 (looking-at "Conflicts occured, diff3 conflict markers left in file\\.$")))) | |
192 | |
193 (defun vc-arch-delete-rej-if-obsolete () | |
194 "For use in `write-file-functions'." | |
195 (let ((rej (concat buffer-file-name ".rej"))) | |
196 (when (and buffer-file-name (vc-arch-diff3-rej-p rej)) | |
197 (if (not (re-search-forward "^>>>>>>> " nil t)) | |
198 ;; The .rej file is obsolete. | |
199 (condition-case nil (delete-file rej) (error nil))))) | |
200 ;; This did not save the buffer. | |
201 nil) | |
202 | |
203 (defun vc-arch-find-file-hook () | |
204 (let ((rej (concat buffer-file-name ".rej"))) | |
205 (when (and buffer-file-name (file-exists-p rej)) | |
206 (if (vc-arch-diff3-rej-p rej) | |
207 (save-excursion | |
208 (goto-char (point-min)) | |
209 (if (not (re-search-forward "^>>>>>>> " nil t)) | |
210 ;; The .rej file is obsolete. | |
211 (condition-case nil (delete-file rej) (error nil)) | |
212 (smerge-mode 1) | |
213 (add-hook 'write-file-functions | |
214 'vc-arch-delete-rej-if-obsolete nil t) | |
215 (message "There are unresolved conflicts in this file"))) | |
216 (message "There are unresolved conflicts in %s" | |
217 (file-name-nondirectory rej)))))) | |
218 | |
219 (defun vc-arch-checkout-model (file) 'implicit) | |
220 | |
221 (defun vc-arch-checkin (file rev comment) | |
222 (if rev (error "Committing to a specific revision is unsupported.")) | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
223 (let ((summary (file-relative-name file (vc-arch-root file)))) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
224 ;; Extract a summary from the comment. |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
225 (when (or (string-match "\\`Summary:[ \t]*\\(.*[^ \t\n]\\)\\([ \t]*\n\\)*" comment) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
226 (string-match "\\`[ \t]*\\(.*[^ \t\n]\\)[ \t]*\\(\n?\\'\\|\n\\([ \t]*\n\\)+\\)" comment)) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
227 (setq summary (match-string 1 comment)) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
228 (setq comment (substring comment (match-end 0)))) |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
229 (vc-arch-command nil 0 file "commit" "-s" summary "-L" comment "--" |
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
230 (vc-switches 'Arch 'checkin)))) |
54396 | 231 |
232 (defun vc-arch-diff (file &optional oldvers newvers) | |
233 "Get a difference report using Arch between two versions of FILE." | |
234 (if newvers | |
235 (error "Diffing specific revisions not implemented.") | |
236 (let* ((async (fboundp 'start-process)) | |
237 ;; Run the command from the root dir. | |
238 (default-directory (vc-arch-root file)) | |
239 (status | |
240 (vc-arch-command | |
241 "*vc-diff*" | |
242 (if async 'async 1) | |
243 nil "file-diffs" | |
244 ;; Arch does not support the typical flags. | |
245 ;; (vc-switches 'Arch 'diff) | |
246 (file-relative-name file) | |
247 (if (equal oldvers (vc-workfile-version file)) | |
248 nil | |
249 oldvers)))) | |
250 (if async 1 status)))) ; async diff, pessimistic assumption. | |
251 | |
252 (defun vc-arch-delete-file (file) | |
253 (vc-arch-command nil 0 file "rm")) | |
254 | |
255 (defun vc-arch-rename-file (old new) | |
256 (vc-arch-command nil 0 new "mv" (file-relative-name old))) | |
257 | |
258 (defun vc-arch-command (buffer okstatus file &rest flags) | |
259 "A wrapper around `vc-do-command' for use in vc-arch.el." | |
260 (apply 'vc-do-command buffer okstatus vc-arch-command file flags)) | |
261 | |
262 (provide 'vc-arch) | |
263 | |
264 ;;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704 | |
265 ;;; vc-arch.el ends here |