annotate lisp/vc-arch.el @ 89909:68c22ea6027c

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