annotate lisp/vc-arch.el @ 57079:6f014cde9d81

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