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