Mercurial > emacs
annotate lisp/vc-arch.el @ 105903:28d5dd02302d
* xmenu.c (Fx_popup_menu): Hide any tooltip before opening a menu.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Sun, 08 Nov 2009 00:14:30 +0000 |
parents | 1c682f1cb8e6 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
54396 | 1 ;;; vc-arch.el --- VC backend for the Arch version-control system |
2 | |
100908 | 3 ;; Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009 |
100177
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
54396 | 5 |
6 ;; Author: FSF (see vc.el for full credits) | |
7 ;; Maintainer: Stefan Monnier <monnier@gnu.org> | |
8 | |
9 ;; This file is part of GNU Emacs. | |
10 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
54396 | 12 ;; it under the terms of the GNU General Public License as published by |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
14 ;; (at your option) any later version. |
54396 | 15 |
16 ;; GNU Emacs is distributed in the hope that it will be useful, | |
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
54396 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; 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
|
27 ;; |
54396 | 28 ;; 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
|
29 ;; |
54396 | 30 ;; This is derived from vc-mcvs.el as follows: |
31 ;; - cp vc-mcvs.el vc-arch.el and then M-% mcvs RET arch RET | |
32 ;; | |
33 ;; Then of course started the hacking. | |
34 ;; | |
35 ;; 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
|
36 ;; - 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
|
37 ;; - 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
|
38 ;; - C-x v v to commit a change to a single file. |
54396 | 39 |
40 ;; Bugs: | |
41 | |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
42 ;; - *VC-log*'s initial content lacks the `Summary:' lines. |
54396 | 43 ;; - All files under the tree are considered as "under Arch's control" |
44 ;; without regards to =tagging-method and such. | |
45 ;; - 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
|
46 ;; - C-x v l does not work. |
54396 | 47 ;; - 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
|
48 ;; - 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
|
49 ;; - 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
|
50 ;; - 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
|
51 ;; - C-x v r does not work. |
94542
16651da1e3ed
Fix some comments to remove references to vc-dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94521
diff
changeset
|
52 ;; - VC directory listings do not work. |
54396 | 53 ;; - And more... |
54 | |
55 ;;; Code: | |
56 | |
54532
87ca639a4eca
Require CL for `case'.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54531
diff
changeset
|
57 (eval-when-compile (require 'vc) (require 'cl)) |
54396 | 58 |
94563
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
59 ;;; Properties of the backend |
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
60 |
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
61 (defun vc-arch-revision-granularity () 'repository) |
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
62 (defun vc-arch-checkout-model (files) 'implicit) |
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
63 |
54396 | 64 ;;; |
65 ;;; Customization options | |
66 ;;; | |
67 | |
100177
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
68 ;; It seems Arch diff does not accept many options, so this is not |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
69 ;; very useful. It exists mainly so that the VC backends are all |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
70 ;; consistent with regards to their treatment of diff switches. |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
71 (defcustom vc-arch-diff-switches t |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
72 "String or list of strings specifying switches for Arch diff under VC. |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
73 If nil, use the value of `vc-diff-switches'. If t, use no switches." |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
74 :type '(choice (const :tag "Unspecified" nil) |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
75 (const :tag "None" t) |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
76 (string :tag "Argument String") |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
77 (repeat :tag "Argument List" :value ("") string)) |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
78 :version "23.1" |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
79 :group 'vc) |
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
80 |
99784
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
81 (define-obsolete-variable-alias 'vc-arch-command 'vc-arch-program "23.1") |
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
82 |
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
83 (defcustom vc-arch-program |
81379
fa58a242b75e
(vc-arch-command): Remove bzr. It's a different program.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81326
diff
changeset
|
84 (let ((candidates '("tla" "baz"))) |
54396 | 85 (while (and candidates (not (executable-find (car candidates)))) |
86 (setq candidates (cdr candidates))) | |
99784
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
87 (or (car candidates) "tla")) |
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
88 "Name of the Arch executable." |
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
89 :type 'string |
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
90 :group 'vc) |
54396 | 91 |
92 ;; Clear up the cache to force vc-call to check again and discover | |
93 ;; new functions when we reload this file. | |
94 (put 'Arch 'vc-functions nil) | |
95 | |
96 ;;;###autoload (defun vc-arch-registered (file) | |
57094
7883de80034e
(vc-arch-root, vc-arch-registered): Use vc-find-root.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57026
diff
changeset
|
97 ;;;###autoload (if (vc-find-root file "{arch}/=tagging-method") |
7883de80034e
(vc-arch-root, vc-arch-registered): Use vc-find-root.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57026
diff
changeset
|
98 ;;;###autoload (progn |
7883de80034e
(vc-arch-root, vc-arch-registered): Use vc-find-root.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57026
diff
changeset
|
99 ;;;###autoload (load "vc-arch") |
7883de80034e
(vc-arch-root, vc-arch-registered): Use vc-find-root.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
57026
diff
changeset
|
100 ;;;###autoload (vc-arch-registered file)))) |
54396 | 101 |
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
|
102 (defun vc-arch-add-tagline () |
54396 | 103 "Add an `arch-tag' to the end of the current file." |
104 (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
|
105 (comment-normalize-vars) |
54396 | 106 (goto-char (point-max)) |
107 (forward-comment -1) | |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
108 (skip-chars-forward " \t\n") |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
109 (cond |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
110 ((not (bolp)) (insert "\n\n")) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
111 ((not (eq ?\n (char-before (1- (point))))) (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
|
112 (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
|
113 (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
|
114 (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
|
115 (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
|
116 (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
|
117 ".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
|
118 (file-name-directory buffer-file-name))))) |
54396 | 119 (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
|
120 (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
|
121 ;; 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
|
122 (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
|
123 (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
|
124 (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
|
125 (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
|
126 (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
|
127 (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
|
128 (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
|
129 (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
|
130 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
|
131 (+ (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
|
132 (buffer-size))))))) |
54396 | 133 (comment-region beg (point)))) |
134 | |
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
|
135 (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
|
136 |
76769
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
137 (defmacro vc-with-current-file-buffer (file &rest body) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
138 (declare (indent 2) (debug t)) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
139 `(let ((-kill-buf- nil) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
140 (-file- ,file)) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
141 (with-current-buffer (or (find-buffer-visiting -file-) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
142 (setq -kill-buf- (generate-new-buffer " temp"))) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
143 ;; Avoid find-file-literally since it can do many undesirable extra |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
144 ;; things (among which, call us back into an infinite loop). |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
145 (if -kill-buf- (insert-file-contents -file-)) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
146 (unwind-protect |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
147 (progn ,@body) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
148 (if (buffer-live-p -kill-buf-) (kill-buffer -kill-buf-)))))) |
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
149 |
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
|
150 (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
|
151 "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
|
152 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
|
153 ;; 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
|
154 (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
|
155 (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
|
156 (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
|
157 (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
|
158 ;; 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
|
159 (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
|
160 (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
|
161 (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
|
162 ;; Check the presence of a tagline. |
76769
3693d2ee35b8
(vc-with-current-file-buffer): New macro.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
75469
diff
changeset
|
163 (vc-with-current-file-buffer 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
|
164 (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
|
165 (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
|
166 (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
|
167 (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
|
168 (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
|
169 (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
|
170 ;; 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
|
171 ;; 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
|
172 (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
|
173 (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
|
174 (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
|
175 (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
|
176 (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
|
177 (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
|
178 (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
|
179 (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
|
180 (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
|
181 (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
|
182 (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
|
183 |
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 (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
|
185 ;; 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
|
186 (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
|
187 (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
|
188 (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
|
189 (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
|
190 (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
|
191 (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
|
192 (looking-at ".*[^ \n\t]") |
75469
d2adef0ec2f0
(vc-arch-file-id): Move with-current-buffer inside the if.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
193 (match-string 0)) |
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
|
194 (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
|
195 (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
|
196 (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
|
197 (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
|
198 (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
|
199 (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
|
200 (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
|
201 (match-string 1) |
75469
d2adef0ec2f0
(vc-arch-file-id): Move with-current-buffer inside the if.
Richard M. Stallman <rms@gnu.org>
parents:
75347
diff
changeset
|
202 (concat "./" (file-relative-name file (vc-arch-root 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
|
203 |
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 (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
|
205 (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
|
206 (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
|
207 (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
|
208 (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
|
209 (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
|
210 (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
|
211 "^[ \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
|
212 (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
|
213 '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
|
214 |
54396 | 215 (defun vc-arch-root (file) |
216 "Return the root directory of a Arch project, if any." | |
217 (or (vc-file-getprop file 'arch-root) | |
87574
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
218 ;; Check the =tagging-method, in case someone naively manually |
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
219 ;; creates a {arch} directory somewhere. |
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
220 (let ((root (vc-find-root file "{arch}/=tagging-method"))) |
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
221 (when root |
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
222 (vc-file-setprop |
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
86002
diff
changeset
|
223 file 'arch-root root))))) |
54396 | 224 |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
225 (defun vc-arch-register (files &optional rev comment) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
226 (if rev (error "Explicit initial revision not supported for Arch")) |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
227 (dolist (file files) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
228 (let ((tagmet (vc-arch-tagging-method file))) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
229 (if (and (memq tagmet '(tagline implicit)) comment-start) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
230 (with-current-buffer (find-file-noselect file) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
231 (if (buffer-modified-p) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
232 (error "Save %s first" (buffer-name))) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
233 (vc-arch-add-tagline) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
234 (save-buffer))))) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
235 (vc-arch-command nil 0 files "add")) |
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
|
236 |
54396 | 237 (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
|
238 ;; 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
|
239 ;; 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
|
240 ;; 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
|
241 (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
|
242 (vc-arch-file-source-p file))) |
54396 | 243 |
244 (defun vc-arch-default-version (file) | |
245 (or (vc-file-getprop (vc-arch-root file) 'arch-default-version) | |
246 (let* ((root (vc-arch-root file)) | |
247 (f (expand-file-name "{arch}/++default-version" root))) | |
248 (if (file-readable-p f) | |
249 (vc-file-setprop | |
250 root 'arch-default-version | |
251 (with-temp-buffer | |
252 (insert-file-contents f) | |
253 ;; Strip the terminating newline. | |
254 (buffer-substring (point-min) (1- (point-max))))))))) | |
255 | |
54409
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
256 (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
|
257 "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
|
258 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
|
259 nil) |
a9f1e9611612
(vc-arch-workfile-unchanged-p): Define to avoid dup-diff.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54396
diff
changeset
|
260 |
54396 | 261 (defun vc-arch-state (file) |
262 ;; There's no checkout operation and merging is not done from VC | |
263 ;; so the only operation that's state dependent that VC supports is commit | |
264 ;; 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
|
265 (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
|
266 (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
|
267 (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
|
268 (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
|
269 (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
|
270 (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
|
271 (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
|
272 (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
|
273 (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
|
274 (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
|
275 '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
|
276 (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
|
277 (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
|
278 (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
|
279 (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
|
280 (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
|
281 (save-excursion |
992d9837a265
(vc-arch-state): Fix parsing for `names' method.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56954
diff
changeset
|
282 (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
|
283 ;; 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
|
284 ;; 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
|
285 (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
|
286 ;; 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
|
287 (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
|
288 (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
|
289 ;; 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
|
290 (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
|
291 (subst-char-in-string |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
292 ?/ ?% (vc-arch-working-revision 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
|
293 '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
|
294 ;; 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
|
295 ;; 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
|
296 '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
|
297 ;; 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
|
298 (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
|
299 "\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
|
300 (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
|
301 ;; 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
|
302 '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
|
303 (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
|
304 (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
|
305 (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
|
306 (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
|
307 '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
|
308 'edited))))))))) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
309 |
98776
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
310 (defun vc-arch-dir-status (dir callback) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
311 "Run 'tla inventory' for DIR and pass results to CALLBACK. |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
312 CALLBACK expects (ENTRIES &optional MORE-TO-COME); see |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
313 `vc-dir-refresh'." |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
314 (let ((default-directory dir)) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
315 (vc-arch-command t 'async nil "changes")) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
316 ;; The updating could be done asynchronously. |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
317 (vc-exec-after |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
318 `(vc-arch-after-dir-status ',callback))) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
319 |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
320 (defun vc-arch-after-dir-status (callback) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
321 (let* ((state-map '(("M " . edited) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
322 ("Mb" . edited) ;binary |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
323 ("D " . removed) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
324 ("D/" . removed) ;directory |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
325 ("A " . added) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
326 ("A/" . added) ;directory |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
327 ("=>" . renamed) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
328 ("/>" . renamed) ;directory |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
329 ("lf" . symlink-to-file) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
330 ("fl" . file-to-symlink) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
331 ("--" . permissions-changed) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
332 ("-/" . permissions-changed) ;directory |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
333 )) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
334 (state-map-regexp (regexp-opt (mapcar 'car state-map) t)) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
335 (entry-regexp (concat "^" state-map-regexp " \\(.*\\)$")) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
336 result) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
337 (goto-char (point-min)) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
338 ;;(message "Got %s" (buffer-string)) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
339 (while (re-search-forward entry-regexp nil t) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
340 (let* ((state-string (match-string 1)) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
341 (state (cdr (assoc state-string state-map))) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
342 (filename (match-string 2))) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
343 (push (list filename state) result))) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
344 |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
345 (funcall callback result nil))) |
58d0fa1979cb
* vc-arch.el (vc-arch-dir-status): New function.
Magnus Henoch <mange@freemail.hu>
parents:
96899
diff
changeset
|
346 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
347 (defun vc-arch-working-revision (file) |
54396 | 348 (let* ((root (expand-file-name "{arch}" (vc-arch-root file))) |
349 (defbranch (vc-arch-default-version file))) | |
59313
ad91f130fbdf
(vc-arch-workfile-version): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
59312
diff
changeset
|
350 (when (and defbranch (string-match "\\`\\(.+@[^/\n]+\\)/\\(\\(\\(.*?\\)\\(?:--.*\\)?\\)--.*\\)\\'" defbranch)) |
54396 | 351 (let* ((archive (match-string 1 defbranch)) |
352 (category (match-string 4 defbranch)) | |
353 (branch (match-string 3 defbranch)) | |
354 (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
|
355 (sealed nil) (rev-nb 0) |
54396 | 356 (rev nil) |
357 logdir tmp) | |
358 (setq logdir (expand-file-name category root)) | |
359 (setq logdir (expand-file-name branch logdir)) | |
360 (setq logdir (expand-file-name version logdir)) | |
361 (setq logdir (expand-file-name archive logdir)) | |
362 (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>
parents:
57094
diff
changeset
|
363 (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>
parents:
57094
diff
changeset
|
364 ;; Revision names go: base-0, patch-N, version-0, versionfix-M. |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
365 (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
|
366 (setq sealed t rev-nb 0)) |
54396 | 367 (if (and (string-match "-\\([0-9]+\\)\\'" file) |
368 (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
|
369 (or (not sealed) (eq (aref file 0) ?v)) |
54396 | 370 (>= tmp rev-nb)) |
371 (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
|
372 ;; 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
|
373 ;; 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
|
374 (concat defbranch "--" (or rev "none-000")))))) |
54396 | 375 |
376 | |
377 (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
|
378 '(("\\`.*--\\(.*--.*\\)--\\(v?\\).*-\\([0-9]+\\)\\'" . "\\2\\3[\\1]")) |
54396 | 379 "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
|
380 :type '(repeat (cons regexp string)) |
9d529d2aac14
(vc-arch-mode-line-rewrite): Add :group 'vc.
Kim F. Storm <storm@cua.dk>
parents:
55873
diff
changeset
|
381 :group 'vc) |
54396 | 382 |
383 (defun vc-arch-mode-line-string (file) | |
384 "Return string for placement in modeline by `vc-mode-line' for FILE." | |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
385 (let ((rev (vc-working-revision file))) |
54396 | 386 (dolist (rule vc-arch-mode-line-rewrite) |
387 (if (string-match (car rule) rev) | |
388 (setq rev (replace-match (cdr rule) t nil rev)))) | |
389 (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
|
390 (case (vc-state file) |
94521
2a61c5f918a5
Change 'needs-patch to 'needs-update.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
87903
diff
changeset
|
391 ((up-to-date needs-update) ?-) |
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
|
392 (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
|
393 (t ?:)) |
54396 | 394 rev))) |
395 | |
396 (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
|
397 (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
|
398 (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
|
399 (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
|
400 (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
|
401 (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
|
402 (looking-at "Conflicts occured, diff3 conflict markers left in file\\."))))) |
54396 | 403 |
404 (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
|
405 "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
|
406 (save-excursion |
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
407 (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
|
408 (when (and buffer-file-name (vc-arch-diff3-rej-p rej)) |
79848
316ed7573095
* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
409 (unless (re-search-forward "^<<<<<<< " nil t) |
316ed7573095
* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
410 ;; The .rej file is obsolete. |
316ed7573095
* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
411 (condition-case nil (delete-file rej) (error nil)) |
316ed7573095
* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
412 ;; Remove the hook so that it is not called multiple times. |
316ed7573095
* vc-arch.el (vc-arch-delete-rej-if-obsolete): Remove the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
413 (remove-hook 'after-save-hook 'vc-arch-delete-rej-if-obsolete t)))))) |
54396 | 414 |
415 (defun vc-arch-find-file-hook () | |
416 (let ((rej (concat buffer-file-name ".rej"))) | |
417 (when (and buffer-file-name (file-exists-p rej)) | |
418 (if (vc-arch-diff3-rej-p rej) | |
419 (save-excursion | |
420 (goto-char (point-min)) | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
421 (if (not (re-search-forward "^<<<<<<< " nil t)) |
54396 | 422 ;; The .rej file is obsolete. |
423 (condition-case nil (delete-file rej) (error nil)) | |
424 (smerge-mode 1) | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
425 (add-hook 'after-save-hook |
54396 | 426 'vc-arch-delete-rej-if-obsolete nil t) |
427 (message "There are unresolved conflicts in this file"))) | |
428 (message "There are unresolved conflicts in %s" | |
429 (file-name-nondirectory rej)))))) | |
430 | |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
431 (defun vc-arch-checkin (files rev comment) |
63423
8269aa11cce4
(vc-arch-checkin, vc-arch-diff): Follow error conventions.
Juanma Barranquero <lekktu@gmail.com>
parents:
59444
diff
changeset
|
432 (if rev (error "Committing to a specific revision is unsupported")) |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
433 ;; FIXME: This implementation probably only works for singleton filesets |
84374
1224dec49333
(vc-arch-checkin): Fix typo.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82502
diff
changeset
|
434 (let ((summary (file-relative-name (car files) (vc-arch-root (car files))))) |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
435 ;; 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
|
436 (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
|
437 (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
|
438 (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
|
439 (setq comment (substring comment (match-end 0)))) |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
440 (vc-arch-command nil 0 files "commit" "-s" summary "-L" comment "--" |
54415
504aef04e493
(vc-arch-workfile-version, vc-arch-mode-line-rewrite):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54409
diff
changeset
|
441 (vc-switches 'Arch 'checkin)))) |
54396 | 442 |
81960
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
443 (defun vc-arch-diff (files &optional oldvers newvers buffer) |
5a8f965c55ba
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81804
diff
changeset
|
444 "Get a difference report using Arch between two versions of FILES." |
82000
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
445 ;; FIXME: This implementation only works for singleton filesets. To make |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
446 ;; it work for more cases, we have to either call `file-diffs' manually on |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
447 ;; each and every `file' in the fileset, or use `changes --diffs' (and |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
448 ;; variants) and maybe filter the output with `filterdiff' to only include |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
449 ;; the files in which we're interested. |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
450 (let ((file (car files))) |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
451 (if (and newvers |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
452 (vc-up-to-date-p file) |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
453 (equal newvers (vc-working-revision file))) |
82000
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
454 ;; Newvers is the base revision and the current file is unchanged, |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
455 ;; so we can diff with the current file. |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
456 (setq newvers nil)) |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
457 (if newvers |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
458 (error "Diffing specific revisions not implemented") |
104594
1c682f1cb8e6
* vc-arch.el (vc-arch-diff): Let-bind `process-file-side-effects' with nil.
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
459 (let* (process-file-side-effects |
1c682f1cb8e6
* vc-arch.el (vc-arch-diff): Let-bind `process-file-side-effects' with nil.
Michael Albinus <michael.albinus@gmx.de>
parents:
100908
diff
changeset
|
460 (async (not vc-disable-async-diff)) |
82000
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
461 ;; Run the command from the root dir. |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
462 (default-directory (vc-arch-root file)) |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
463 (status |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
464 (vc-arch-command |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
465 (or buffer "*vc-diff*") |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
466 (if async 'async 1) |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
467 nil "file-diffs" |
100177
5a223111838e
(vc-arch-diff-switches): New option, for consistency with other backends.
Glenn Morris <rgm@gnu.org>
parents:
99784
diff
changeset
|
468 (vc-switches 'Arch 'diff) |
82000
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
469 (file-relative-name file) |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
470 (if (equal oldvers (vc-working-revision file)) |
82000
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
471 nil |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
472 oldvers)))) |
066eaef90bfb
(vc-arch-diff): Fix last change.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81960
diff
changeset
|
473 (if async 1 status))))) ; async diff, pessimistic assumption. |
54396 | 474 |
475 (defun vc-arch-delete-file (file) | |
476 (vc-arch-command nil 0 file "rm")) | |
477 | |
478 (defun vc-arch-rename-file (old new) | |
479 (vc-arch-command nil 0 new "mv" (file-relative-name old))) | |
480 | |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
481 (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
|
482 |
54396 | 483 (defun vc-arch-command (buffer okstatus file &rest flags) |
484 "A wrapper around `vc-do-command' for use in vc-arch.el." | |
99784
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
485 (apply 'vc-do-command (or buffer "*vc*") okstatus vc-arch-program file flags)) |
54396 | 486 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
487 (defun vc-arch-init-revision () nil) |
54806
e16241d08bbc
(vc-arch-root): Be a bit more careful.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
54532
diff
changeset
|
488 |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
489 ;;; Completion of versions and revisions. |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
490 |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
491 (defun vc-arch--version-completion-table (root string) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
492 (delq nil |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
493 (mapcar |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
494 (lambda (d) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
495 (when (string-match "/\\([^/]+\\)/\\([^/]+\\)\\'" d) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
496 (concat (match-string 2 d) "/" (match-string 1 d)))) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
497 (let ((default-directory root)) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
498 (file-expand-wildcards |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
499 (concat "*/*/" |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
500 (if (string-match "/" string) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
501 (concat (substring string (match-end 0)) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
502 "*/" (substring string 0 (match-beginning 0))) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
503 (concat "*/" string)) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
504 "*")))))) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
505 |
85457
e58eb1e72d23
(vc-arch-revision-completion-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85139
diff
changeset
|
506 (defun vc-arch-revision-completion-table (files) |
e58eb1e72d23
(vc-arch-revision-completion-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85139
diff
changeset
|
507 (lexical-let ((files files)) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
508 (lambda (string pred action) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
509 ;; FIXME: complete revision patches as well. |
85457
e58eb1e72d23
(vc-arch-revision-completion-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85139
diff
changeset
|
510 (let* ((root (expand-file-name "{arch}" (vc-arch-root (car files)))) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
511 (table (vc-arch--version-completion-table root string))) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
512 (complete-with-action action table string pred))))) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
513 |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
514 ;;; Trimming revision libraries. |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
515 |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
516 ;; This code is not directly related to VC and there are many variants of |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
517 ;; this functionality available as scripts, but I like this version better, |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
518 ;; so maybe others will like it too. |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
519 |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
520 (defun vc-arch-trim-find-least-useful-rev (revs) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
521 (let* ((first (pop revs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
522 (second (pop revs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
523 (third (pop revs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
524 ;; We try to give more importance to recent revisions. The idea is |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
525 ;; that it's OK if checking out a revision 1000-patch-old is ten |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
526 ;; times slower than checking out a revision 100-patch-old. But at |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
527 ;; the same time a 2-patch-old rev isn't really ten times more |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
528 ;; important than a 20-patch-old, so we use an arbitrary constant |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
529 ;; "100" to reduce this effect for recent revisions. Making this |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
530 ;; constant a float has the side effect of causing the subsequent |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
531 ;; computations to be done as floats as well. |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
532 (max (+ 100.0 (car (or (car (last revs)) third)))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
533 (cost (lambda () (/ (- (car third) (car first)) (- max (car second))))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
534 (minrev second) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
535 (mincost (funcall cost))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
536 (while revs |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
537 (setq first second) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
538 (setq second third) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
539 (setq third (pop revs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
540 (when (< (funcall cost) mincost) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
541 (setq minrev second) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
542 (setq mincost (funcall cost)))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
543 minrev)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
544 |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
545 (defun vc-arch-trim-make-sentinel (revs) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
546 (if (null revs) (lambda (proc msg) (message "VC-Arch trimming ... done")) |
96899
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
547 (lexical-let ((revs revs)) |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
548 (lambda (proc msg) |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
549 (message "VC-Arch trimming %s..." (file-name-nondirectory (car revs))) |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
550 (rename-file (car revs) (concat (car revs) "*rm*")) |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
551 (setq proc (start-process "vc-arch-trim" nil |
96899
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
552 "rm" "-rf" (concat (car revs) "*rm*"))) |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
553 (set-process-sentinel proc (vc-arch-trim-make-sentinel (cdr revs))))))) |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
554 |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
555 (defun vc-arch-trim-one-revlib (dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
556 "Delete half of the revisions in the revision library." |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
557 (interactive "Ddirectory: ") |
96899
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
558 (let ((garbage (directory-files dir 'full "\\`,," 'nosort))) |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
559 (when garbage |
7df3d9a17631
(vc-arch-trim-make-sentinel): Use a closure.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
94847
diff
changeset
|
560 (funcall (vc-arch-trim-make-sentinel garbage) nil nil))) |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
561 (let ((revs |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
562 (sort (delq nil |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
563 (mapcar |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
564 (lambda (f) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
565 (when (string-match "-\\([0-9]+\\)\\'" f) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
566 (cons (string-to-number (match-string 1 f)) f))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
567 (directory-files dir nil nil 'nosort))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
568 'car-less-than-car)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
569 (subdirs nil)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
570 (when (cddr revs) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
571 (dotimes (i (/ (length revs) 2)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
572 (let ((minrev (vc-arch-trim-find-least-useful-rev revs))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
573 (setq revs (delq minrev revs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
574 (push minrev subdirs))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
575 (funcall (vc-arch-trim-make-sentinel |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
576 (mapcar (lambda (x) (expand-file-name (cdr x) dir)) subdirs)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
577 nil nil)))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
578 |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
579 (defun vc-arch-trim-revlib () |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
580 "Delete half of the revisions in the revision library." |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
581 (interactive) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
582 (let ((rl-dir (with-output-to-string |
99784
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
583 (call-process vc-arch-program nil standard-output nil |
81620
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
584 "my-revision-library")))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
585 (while (string-match "\\(.*\\)\n" rl-dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
586 (let ((dir (match-string 1 rl-dir))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
587 (setq rl-dir |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
588 (if (and (file-directory-p dir) (file-writable-p dir)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
589 dir |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
590 (substring rl-dir (match-end 0)))))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
591 (unless (file-writable-p rl-dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
592 (error "No writable revlib directory found")) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
593 (message "Revlib at %s" rl-dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
594 (let* ((archives (directory-files rl-dir 'full "[^.]\\|...")) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
595 (categories |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
596 (apply 'append |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
597 (mapcar (lambda (dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
598 (when (file-directory-p dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
599 (directory-files dir 'full "[^.]\\|..."))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
600 archives))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
601 (branches |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
602 (apply 'append |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
603 (mapcar (lambda (dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
604 (when (file-directory-p dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
605 (directory-files dir 'full "[^.]\\|..."))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
606 categories))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
607 (versions |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
608 (apply 'append |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
609 (mapcar (lambda (dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
610 (when (file-directory-p dir) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
611 (directory-files dir 'full "--.*--"))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
612 branches)))) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
613 (mapc 'vc-arch-trim-one-revlib versions)) |
205f0e2270e9
(vc-arch-add-tagline): Do a slightly cleaner job.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81379
diff
changeset
|
614 )) |
82502
2a2056106d16
(vc-arch-extra-menu-map): New var and fun.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
82140
diff
changeset
|
615 |
78822
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
616 (defvar vc-arch-extra-menu-map |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
617 (let ((map (make-sparse-keymap))) |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
618 (define-key map [add-tagline] |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
619 '(menu-item "Add tagline" vc-arch-add-tagline)) |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
620 map)) |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
621 |
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
622 (defun vc-arch-extra-menu () vc-arch-extra-menu-map) |
99784
248f432fca05
(vc-arch-program): Rename from vc-arch-command, for
Glenn Morris <rgm@gnu.org>
parents:
98776
diff
changeset
|
623 |
78822
1926a08e8926
* vc-arch.el (vc-arch-extra-menu-map): New var and fun.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
624 |
74940
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
625 ;;; Less obvious implementations. |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
626 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
84374
diff
changeset
|
627 (defun vc-arch-find-revision (file rev buffer) |
74940
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
628 (let ((out (make-temp-file "vc-out"))) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
629 (unwind-protect |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
630 (progn |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
631 (with-temp-buffer |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
632 (vc-arch-command (current-buffer) 1 nil "file-diffs" file rev) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
633 (call-process-region (point-min) (point-max) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
634 "patch" nil nil nil "-R" "-o" out file)) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
635 (with-current-buffer buffer |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
636 (insert-file-contents out))) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
637 (delete-file out)))) |
f0d812b53a76
(vc-arch-find-version): New function.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
68651
diff
changeset
|
638 |
54396 | 639 (provide 'vc-arch) |
640 | |
56954
242cddb00aef
(vc-arch-workfile-version): Handle the special case before the first commit.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
56283
diff
changeset
|
641 ;; arch-tag: a35c7c1c-5237-429d-88ef-3d718fd2e704 |
54396 | 642 ;;; vc-arch.el ends here |