Mercurial > emacs
annotate lisp/vc-arch.el @ 56401:1529ab7bab88
(mark_object): Only look at Lisp_Misc_Save_Value if GC_MARK_STACK.
author | Kim F. Storm <storm@cua.dk> |
---|---|
date | Mon, 12 Jul 2004 14:35:53 +0000 |
parents | 9d529d2aac14 |
children | 242cddb00aef 59dcbfe97385 |
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 | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
28 ;; |
54396 | 29 ;; http://www.gnuarch.org/ |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
30 ;; |
54396 | 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: | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
37 ;; - Open a file. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
38 ;; - C-x v = without any prefix arg. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
39 ;; - C-x v v to commit a change to a single file. |
54396 | 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 ;; - *VC-log*'s initial content lacks the `Summary:' lines. |
54396 | 44 ;; - All files under the tree are considered as "under Arch's control" |
45 ;; without regards to =tagging-method and such. | |
46 ;; - 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
|
47 ;; - C-x v l does not work. |
54396 | 48 ;; - 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
|
49 ;; - 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
|
50 ;; - 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
|
51 ;; - 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
|
52 ;; - C-x v r does not work. |
54396 | 53 ;; - VC-dired does not work. |
54 ;; - And more... | |
55 | |
56 ;;; Code: | |
57 | |
54532
87ca639a4eca
Require CL for `case'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54531
diff
changeset
|
58 (eval-when-compile (require 'vc) (require 'cl)) |
54396 | 59 |
60 ;;; | |
61 ;;; Customization options | |
62 ;;; | |
63 | |
64 (defvar vc-arch-command | |
65 (let ((candidates '("tla"))) | |
66 (while (and candidates (not (executable-find (car candidates)))) | |
67 (setq candidates (cdr candidates))) | |
68 (or (car candidates) "tla"))) | |
69 | |
70 ;; Clear up the cache to force vc-call to check again and discover | |
71 ;; new functions when we reload this file. | |
72 (put 'Arch 'vc-functions nil) | |
73 | |
74 ;;;###autoload (defun vc-arch-registered (file) | |
75 ;;;###autoload (let ((dir file)) | |
76 ;;;###autoload (while (and (stringp dir) | |
77 ;;;###autoload (not (equal | |
78 ;;;###autoload dir (setq dir (file-name-directory dir)))) | |
79 ;;;###autoload dir) | |
80 ;;;###autoload (setq dir (if (file-directory-p | |
81 ;;;###autoload (expand-file-name "{arch}" dir)) | |
82 ;;;###autoload t (directory-file-name dir)))) | |
83 ;;;###autoload (if (eq dir t) | |
84 ;;;###autoload (progn | |
85 ;;;###autoload (load "vc-arch") | |
86 ;;;###autoload (vc-arch-registered file))))) | |
87 | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
88 (defun vc-arch-add-tagline () |
54396 | 89 "Add an `arch-tag' to the end of the current file." |
90 (interactive) | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
91 (comment-normalize-vars) |
54396 | 92 (goto-char (point-max)) |
93 (forward-comment -1) | |
94 (unless (bolp) (insert "\n")) | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
95 (let ((beg (point)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
96 (idfile (and buffer-file-name |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
97 (expand-file-name |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
98 (concat ".arch-ids/" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
99 (file-name-nondirectory buffer-file-name) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
100 ".id") |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
101 (file-name-directory buffer-file-name))))) |
54396 | 102 (insert "arch-tag: ") |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
103 (if (and idfile (file-exists-p idfile)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
104 ;; If the file is unreadable, we do want to get an error here. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
105 (progn |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
106 (insert-file-contents idfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
107 (forward-line 1) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
108 (delete-file idfile)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
109 (condition-case nil |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
110 (call-process "uuidgen" nil t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
111 (file-error (insert (format "%s <%s> %s" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
112 (current-time-string) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
113 user-mail-address |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
114 (+ (nth 2 (current-time)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
115 (buffer-size))))))) |
54396 | 116 (comment-region beg (point)))) |
117 | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
118 (defconst vc-arch-tagline-re "^\\W*arch-tag:[ \t]*\\(.*[^ \t\n]\\)") |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
119 |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
120 (defun vc-arch-file-source-p (file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
121 "Can return nil, `maybe' or a non-nil value. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
122 Only the value `maybe' can be trusted :-(." |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
123 ;; FIXME: Check the tag and name of parent dirs. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
124 (unless (string-match "\\`[,+]" (file-name-nondirectory file)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
125 (or (string-match "\\`{arch}/" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
126 (file-relative-name file (vc-arch-root file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
127 (file-exists-p |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
128 ;; Check the presence of an ID file. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
129 (expand-file-name |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
130 (concat ".arch-ids/" (file-name-nondirectory file) ".id") |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
131 (file-name-directory file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
132 ;; Check the presence of a tagline. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
133 (with-current-buffer (find-file-noselect file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
134 (save-excursion |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
135 (goto-char (point-max)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
136 (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
137 (progn |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
138 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
139 (re-search-forward vc-arch-tagline-re (+ (point) 1000) t))))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
140 ;; FIXME: check =tagging-method to see whether untagged files might |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
141 ;; be source or not. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
142 (with-current-buffer |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
143 (find-file-noselect (expand-file-name "{arch}/=tagging-method" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
144 (vc-arch-root file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
145 (let ((untagged-source t)) ;Default is `names'. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
146 (save-excursion |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
147 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
148 (if (re-search-forward "^[ \t]*\\(\\(tagline\\|implicit\\|names\\)\\|explicit\\)" nil t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
149 (setq untagged-source (match-end 2))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
150 (if (re-search-forward "^[ \t]*untagged-source[ \t]+\\(\\(source\\)\\|precious\\|backup\\|junk\\|unrecognized\\)" nil t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
151 (setq untagged-source (match-end 2)))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
152 (if untagged-source 'maybe)))))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
153 |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
154 (defun vc-arch-file-id (file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
155 ;; Don't include the kind of ID this is because it seems to be too messy. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
156 (let ((idfile (expand-file-name |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
157 (concat ".arch-ids/" (file-name-nondirectory file) ".id") |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
158 (file-name-directory file)))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
159 (if (file-exists-p idfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
160 (with-temp-buffer |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
161 (insert-file-contents idfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
162 (looking-at ".*[^ \n\t]") |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
163 (match-string 0))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
164 (with-current-buffer (find-file-noselect file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
165 (save-excursion |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
166 (goto-char (point-max)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
167 (if (or (re-search-backward vc-arch-tagline-re (- (point) 1000) t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
168 (progn |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
169 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
170 (re-search-forward vc-arch-tagline-re (+ (point) 1000) t))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
171 (match-string 1) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
172 (concat "./" (file-relative-name file (vc-arch-root file)))))))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
173 |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
174 (defun vc-arch-tagging-method (file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
175 (with-current-buffer |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
176 (find-file-noselect |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
177 (expand-file-name "{arch}/=tagging-method" (vc-arch-root file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
178 (save-excursion |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
179 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
180 (if (re-search-forward |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
181 "^[ \t]*\\(tagline\\|implicit\\|names\\|explicit\\)" nil t) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
182 (intern (match-string 1)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
183 'names)))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
184 |
54396 | 185 (defun vc-arch-root (file) |
186 "Return the root directory of a Arch project, if any." | |
187 (or (vc-file-getprop file 'arch-root) | |
188 (vc-file-setprop | |
189 file 'arch-root | |
190 (let ((root nil)) | |
191 (while (not (or root | |
192 (equal file (setq file (file-name-directory file))) | |
193 (null file))) | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
194 ;; Check the =tagging-method, in case someone naively manually |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
195 ;; creates a {arch} directory somewhere. |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
196 (if (file-exists-p (expand-file-name "{arch}/=tagging-method" file)) |
54396 | 197 (setq root file) |
198 (setq file (directory-file-name file)))) | |
199 root)))) | |
200 | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
201 (defun vc-arch-register (file &optional rev comment) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
202 (if rev (error "Explicit initial revision not supported for Arch")) |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
203 (let ((tagmet (vc-arch-tagging-method file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
204 (if (and (memq tagmet '(tagline implicit)) comment-start) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
205 (with-current-buffer (find-file-noselect file) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
206 (if (buffer-modified-p) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
207 (error "Save %s first" (buffer-name))) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
208 (vc-arch-add-tagline) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
209 (save-buffer)) |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
210 (vc-arch-command nil 0 file "add")))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
211 |
54396 | 212 (defun vc-arch-registered (file) |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
213 ;; Don't seriously check whether it's source or not. Checking would |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
214 ;; require running TLA, so it's better to not do it, so it also works if |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
215 ;; TLA is not installed. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
216 (and (vc-arch-root file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
217 (vc-arch-file-source-p file))) |
54396 | 218 |
219 (defun vc-arch-default-version (file) | |
220 (or (vc-file-getprop (vc-arch-root file) 'arch-default-version) | |
221 (let* ((root (vc-arch-root file)) | |
222 (f (expand-file-name "{arch}/++default-version" root))) | |
223 (if (file-readable-p f) | |
224 (vc-file-setprop | |
225 root 'arch-default-version | |
226 (with-temp-buffer | |
227 (insert-file-contents f) | |
228 ;; Strip the terminating newline. | |
229 (buffer-substring (point-min) (1- (point-max))))))))) | |
230 | |
54409
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
231 (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
|
232 "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
|
233 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
|
234 nil) |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
235 |
54396 | 236 (defun vc-arch-state (file) |
237 ;; There's no checkout operation and merging is not done from VC | |
238 ;; so the only operation that's state dependent that VC supports is commit | |
239 ;; which is only activated if the file is `edited'. | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
240 (let* ((root (vc-arch-root file)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
241 (ver (vc-arch-default-version file)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
242 (pat (concat "\\`" (subst-char-in-string ?/ ?% ver))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
243 (dir (expand-file-name ",,inode-sigs/" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
244 (expand-file-name "{arch}" root))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
245 (sigfile nil)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
246 (dolist (f (if (file-directory-p dir) (directory-files dir t pat))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
247 (if (or (not sigfile) (file-newer-than-file-p f sigfile)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
248 (setq sigfile f))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
249 (if (not sigfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
250 'edited ;We know nothing. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
251 (let ((id (vc-arch-file-id file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
252 (setq id (replace-regexp-in-string "[ \t]" "_" id)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
253 (with-current-buffer (find-file-noselect sigfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
254 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
255 (while (and (search-forward id nil 'move) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
256 (progn (goto-char (- (match-beginning 0) 2)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
257 ;; Ignore E_ entries used for foo.id files. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
258 (or (not (bolp)) (looking-at "E_"))))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
259 (if (eobp) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
260 ;; ID not found. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
261 (if (equal (file-name-nondirectory sigfile) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
262 (subst-char-in-string |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
263 ?/ ?% (vc-arch-workfile-version file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
264 'added |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
265 ;; Might be `added' or `up-to-date' as well. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
266 ;; FIXME: Check in the patch logs to find out. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
267 'edited) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
268 ;; Found the ID, let's check the inode. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
269 (if (not (re-search-forward |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
270 "\t.*mtime=\\([0-9]+\\):size=\\([0-9]+\\)" |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
271 (line-end-position) t)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
272 ;; Buh? Unexpected format. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
273 'edited |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
274 (let ((ats (file-attributes file))) |
55873
304d478aa594
(vc-arch-state): Don't assume the file exists.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
55814
diff
changeset
|
275 (if (and (eq (nth 7 ats) (string-to-number (match-string 2))) |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
276 (equal (format-time-string "%s" (nth 5 ats)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
277 (match-string 1))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
278 'up-to-date |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
279 'edited))))))))) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
280 |
54396 | 281 (defun vc-arch-workfile-version (file) |
282 (let* ((root (expand-file-name "{arch}" (vc-arch-root file))) | |
283 (defbranch (vc-arch-default-version file))) | |
284 (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*\\)--.*\\)--.*\\)\\'" defbranch)) | |
285 (let* ((archive (match-string 1 defbranch)) | |
286 (category (match-string 4 defbranch)) | |
287 (branch (match-string 3 defbranch)) | |
288 (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
|
289 (sealed nil) (rev-nb 0) |
54396 | 290 (rev nil) |
291 logdir tmp) | |
292 (setq logdir (expand-file-name category root)) | |
293 (setq logdir (expand-file-name branch logdir)) | |
294 (setq logdir (expand-file-name version logdir)) | |
295 (setq logdir (expand-file-name archive logdir)) | |
296 (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
|
297 ;; Revision names go: base-0, patch-N, version-0, versionfix-N. |
54396 | 298 (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
|
299 (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
|
300 (setq sealed t rev-nb 0)) |
54396 | 301 (if (and (string-match "-\\([0-9]+\\)\\'" file) |
302 (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
|
303 (or (not sealed) (eq (aref file 0) ?v)) |
54396 | 304 (>= tmp rev-nb)) |
305 (setq rev-nb tmp rev file))) | |
306 (concat defbranch "--" rev))))) | |
307 | |
308 | |
309 (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
|
310 '(("\\`.*--\\(.*--.*\\)--\\(v?\\).*-\\([0-9]+\\)\\'" . "\\2\\3[\\1]")) |
54396 | 311 "Rewrite rules to shorten Arch's revision names on the mode-line." |
56283
9d529d2aac14
(vc-arch-mode-line-rewrite): Add :group 'vc.
Kim F. Storm <storm@cua.dk>
parents:
55873
diff
changeset
|
312 :type '(repeat (cons regexp string)) |
9d529d2aac14
(vc-arch-mode-line-rewrite): Add :group 'vc.
Kim F. Storm <storm@cua.dk>
parents:
55873
diff
changeset
|
313 :group 'vc) |
54396 | 314 |
315 (defun vc-arch-mode-line-string (file) | |
316 "Return string for placement in modeline by `vc-mode-line' for FILE." | |
317 (let ((rev (vc-workfile-version file))) | |
318 (dolist (rule vc-arch-mode-line-rewrite) | |
319 (if (string-match (car rule) rev) | |
320 (setq rev (replace-match (cdr rule) t nil rev)))) | |
321 (format "Arch%c%s" | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
322 (case (vc-state file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
323 ((up-to-date needs-patch) ?-) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
324 (added ?@) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
325 (t ?:)) |
54396 | 326 rev))) |
327 | |
328 (defun vc-arch-diff3-rej-p (rej) | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
329 (let ((attrs (file-attributes rej))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
330 (and attrs (< (nth 7 attrs) 60) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
331 (with-temp-buffer |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
332 (insert-file-contents rej) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
333 (goto-char (point-min)) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
334 (looking-at "Conflicts occured, diff3 conflict markers left in file\\."))))) |
54396 | 335 |
336 (defun vc-arch-delete-rej-if-obsolete () | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
337 "For use in `after-save-hook'." |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
338 (save-excursion |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
339 (let ((rej (concat buffer-file-name ".rej"))) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
340 (when (and buffer-file-name (vc-arch-diff3-rej-p rej)) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
341 (if (not (re-search-forward "^<<<<<<< " nil t)) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
342 ;; The .rej file is obsolete. |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
343 (condition-case nil (delete-file rej) (error nil))))))) |
54396 | 344 |
345 (defun vc-arch-find-file-hook () | |
346 (let ((rej (concat buffer-file-name ".rej"))) | |
347 (when (and buffer-file-name (file-exists-p rej)) | |
348 (if (vc-arch-diff3-rej-p rej) | |
349 (save-excursion | |
350 (goto-char (point-min)) | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
351 (if (not (re-search-forward "^<<<<<<< " nil t)) |
54396 | 352 ;; The .rej file is obsolete. |
353 (condition-case nil (delete-file rej) (error nil)) | |
354 (smerge-mode 1) | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
355 (add-hook 'after-save-hook |
54396 | 356 'vc-arch-delete-rej-if-obsolete nil t) |
357 (message "There are unresolved conflicts in this file"))) | |
358 (message "There are unresolved conflicts in %s" | |
359 (file-name-nondirectory rej)))))) | |
360 | |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
361 (defun vc-arch-find-file-not-found-hook () |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
362 ;; Do nothing. We are not sure whether the file is `source' or not, |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
363 ;; so we shouldn't ask the user whether she wants to check it out. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
364 ) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
365 |
54396 | 366 (defun vc-arch-checkout-model (file) 'implicit) |
367 | |
368 (defun vc-arch-checkin (file rev comment) | |
369 (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
|
370 (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
|
371 ;; 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
|
372 (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
|
373 (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
|
374 (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
|
375 (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
|
376 (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
|
377 (vc-switches 'Arch 'checkin)))) |
54396 | 378 |
55814
45f2afeb662b
(vc-arch-diff): Add optional `buffer' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54806
diff
changeset
|
379 (defun vc-arch-diff (file &optional oldvers newvers buffer) |
54396 | 380 "Get a difference report using Arch between two versions of FILE." |
54531
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
381 (if (and newvers |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
382 (vc-up-to-date-p file) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
383 (equal newvers (vc-workfile-version file))) |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
384 ;; Newvers is the base revision and the current file is unchanged, |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
385 ;; so we can diff with the current file. |
2ae29225b85c
(vc-arch-diff): Handle the special case where `newvers' is equivalent to nil.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54415
diff
changeset
|
386 (setq newvers nil)) |
54396 | 387 (if newvers |
388 (error "Diffing specific revisions not implemented.") | |
389 (let* ((async (fboundp 'start-process)) | |
390 ;; Run the command from the root dir. | |
391 (default-directory (vc-arch-root file)) | |
392 (status | |
393 (vc-arch-command | |
55814
45f2afeb662b
(vc-arch-diff): Add optional `buffer' arg.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54806
diff
changeset
|
394 (or buffer "*vc-diff*") |
54396 | 395 (if async 'async 1) |
396 nil "file-diffs" | |
397 ;; Arch does not support the typical flags. | |
398 ;; (vc-switches 'Arch 'diff) | |
399 (file-relative-name file) | |
400 (if (equal oldvers (vc-workfile-version file)) | |
401 nil | |
402 oldvers)))) | |
403 (if async 1 status)))) ; async diff, pessimistic assumption. | |
404 | |
405 (defun vc-arch-delete-file (file) | |
406 (vc-arch-command nil 0 file "rm")) | |
407 | |
408 (defun vc-arch-rename-file (old new) | |
409 (vc-arch-command nil 0 new "mv" (file-relative-name old))) | |
410 | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
411 (defalias 'vc-arch-responsible-p 'vc-arch-root) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
412 |
54396 | 413 (defun vc-arch-command (buffer okstatus file &rest flags) |
414 "A wrapper around `vc-do-command' for use in vc-arch.el." | |
415 (apply 'vc-do-command buffer okstatus vc-arch-command file flags)) | |
416 | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
417 (defun vc-arch-init-version () nil) |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
418 |
54396 | 419 (provide 'vc-arch) |
420 | |
421 ;;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704 | |
422 ;;; vc-arch.el ends here |