78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
1 ;;; vc-mtn.el --- VC backend for Monotone
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
2
|
79721
|
3 ;; Copyright (C) 2007, 2008 Free Software Foundation, Inc.
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
4
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
6 ;; Keywords:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
7
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
8 ;; This file is free software; you can redistribute it and/or modify
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
9 ;; it under the terms of the GNU General Public License as published by
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
10 ;; the Free Software Foundation; either version 3, or (at your option)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
11 ;; any later version.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
12
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
13 ;; This file is distributed in the hope that it will be useful,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
16 ;; GNU General Public License for more details.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
17
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
18 ;; You should have received a copy of the GNU General Public License
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
21 ;; Boston, MA 02110-1301, USA.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
22
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
23 ;;; Commentary:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
24
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
25 ;;
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
26
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
27 ;;; Code:
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
28
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
29 (eval-when-compile (require 'cl) (require 'vc))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
30
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
31 ;; Clear up the cache to force vc-call to check again and discover
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
32 ;; new functions when we reload this file.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
33 (put 'Mtn 'vc-functions nil)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
34
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
35 (defvar vc-mtn-command "mtn")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
36 (unless (executable-find vc-mtn-command)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
37 ;; vc-mtn.el is 100% non-functional without the `mtn' executable.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
38 (setq vc-handled-backends (delq 'Mtn vc-handled-backends)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
39
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
40 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
41 (defconst vc-mtn-admin-dir "_MTN")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
42 ;;;###autoload
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
43 (defconst vc-mtn-admin-format (concat vc-mtn-admin-dir "/format"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
44
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
45 ;;;###autoload (defun vc-mtn-registered (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
46 ;;;###autoload (if (vc-find-root file vc-mtn-admin-format)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
47 ;;;###autoload (progn
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
48 ;;;###autoload (load "vc-mtn")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
49 ;;;###autoload (vc-mtn-registered file))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
50
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
51 (defun vc-mtn-revision-granularity () 'repository)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
52 (defun vc-mtn-checkout-model (file) 'implicit)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
53
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
54 (defun vc-mtn-root (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
55 (setq file (if (file-directory-p file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
56 (file-name-as-directory file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
57 (file-name-directory file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
58 (or (vc-file-getprop file 'vc-mtn-root)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
59 (vc-file-setprop file 'vc-mtn-root
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
60 (vc-find-root file vc-mtn-admin-format))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
61
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
62
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
63 (defun vc-mtn-registered (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
64 (let ((root (vc-mtn-root file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
65 (when root
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
66 (vc-mtn-state file))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
67
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
68 (defun vc-mtn-command (buffer okstatus files &rest flags)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
69 "A wrapper around `vc-do-command' for use in vc-mtn.el."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
70 (apply 'vc-do-command buffer okstatus vc-mtn-command files flags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
71
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
72 (defun vc-mtn-state (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
73 ;; If `mtn' fails or returns status>0, or if the search files, just
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
74 ;; return nil.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
75 (ignore-errors
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
76 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
77 (vc-mtn-command t 0 file "status")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
78 (goto-char (point-min))
|
93144
|
79 (re-search-forward
|
|
80 "^ \\(?:\\(patched\\)\\|\\(added\\) \\(?:.*\\)\\)\\|no changes$")
|
|
81 (cond ((match-end 1) 'edited)
|
|
82 ((match-end 2) 'added)
|
|
83 (t 'up-to-date)))))
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
84
|
85139
|
85 (defun vc-mtn-working-revision (file)
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
86 ;; If `mtn' fails or returns status>0, or if the search fails, just
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
87 ;; return nil.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
88 (ignore-errors
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
89 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
90 (vc-mtn-command t 0 file "status")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
91 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
92 (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
93 (match-string 2))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
94
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
95 (defun vc-mtn-workfile-branch (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
96 ;; If `mtn' fails or returns status>0, or if the search files, just
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
97 ;; return nil.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
98 (ignore-errors
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
99 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
100 (vc-mtn-command t 0 file "status")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
101 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
102 (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
103 (match-string 1))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
104
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
105 (defun vc-mtn-workfile-unchanged-p (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
106 (not (eq (vc-mtn-state file) 'edited)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
107
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
108 ;; Mode-line rewrite code copied from vc-arch.el.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
109
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
110 (defcustom vc-mtn-mode-line-rewrite
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
111 '(("\\`[^:/#]*[:/#]" . "")) ;Drop the host part.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
112 "Rewrite rules to shorten Mtn's revision names on the mode-line."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
113 :type '(repeat (cons regexp string))
|
80261
4af0bb174714
* textmodes/css-mode.el (css-indent-offset, css-electric-keys):
Dan Nicolaescu <dann@ics.uci.edu>
diff
changeset
|
114 :version "22.2"
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
115 :group 'vc)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
116
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
117 (defun vc-mtn-mode-line-string (file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
118 "Return string for placement in modeline by `vc-mode-line' for FILE."
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
119 (let ((branch (vc-mtn-workfile-branch file)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
120 (dolist (rule vc-mtn-mode-line-rewrite)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
121 (if (string-match (car rule) branch)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
122 (setq branch (replace-match (cdr rule) t nil branch))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
123 (format "Mtn%c%s"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
124 (case (vc-state file)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
125 ((up-to-date needs-patch) ?-)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
126 (added ?@)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
127 (t ?:))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
128 branch)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
129
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
130 (defun vc-mtn-register (files &optional rest)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
131 (vc-mtn-command nil 0 files "add"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
132
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
133 (defun vc-mtn-responsible-p (file) (vc-mtn-root file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
134 (defun vc-mtn-could-register (file) (vc-mtn-root file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
135
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
136 (defun vc-mtn-checkin (files rev comment)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
137 (vc-mtn-command nil 0 files "commit" "-m" comment))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
138
|
85139
|
139 (defun vc-mtn-find-revision (file rev buffer)
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
140 (vc-mtn-command buffer 0 file "cat" "-r" rev))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
141
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
142 ;; (defun vc-mtn-checkout (file &optional editable rev)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
143 ;; )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
144
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
145 (defun vc-mtn-revert (file &optional contents-done)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
146 (unless contents-done
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
147 (vc-mtn-command nil 0 file "revert")))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
148
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
149 ;; (defun vc-mtn-roolback (files)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
150 ;; )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
151
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
152 (defun vc-mtn-print-log (files &optional buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
153 (vc-mtn-command buffer 0 files "log"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
154
|
85478
|
155 (defvar log-view-message-re)
|
|
156 (defvar log-view-file-re)
|
|
157 (defvar log-view-font-lock-keywords)
|
|
158
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
159 (define-derived-mode vc-mtn-log-view-mode log-view-mode "Mtn-Log-View"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
160 ;; TODO: Not sure what to do about file markers for now.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
161 (set (make-local-variable 'log-view-file-re) "\\'\\`")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
162 ;; TODO: Use a more precise regexp than "[ |/]+" to avoid false positives
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
163 ;; in the ChangeLog text.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
164 (set (make-local-variable 'log-view-message-re)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
165 "^[ |/]+Revision: \\([0-9a-f]+\\)")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
166 (require 'add-log) ;For change-log faces.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
167 (set (make-local-variable 'log-view-font-lock-keywords)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
168 (append log-view-font-lock-keywords
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
169 '(("^[ |]+Author: \\(.*\\)" (1 'change-log-email))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
170 ("^[ |]+Date: \\(.*\\)" (1 'change-log-date-face))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
171
|
85141
b16f7408cd3f
Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
diff
changeset
|
172 ;; (defun vc-mtn-show-log-entry (revision)
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
173 ;; )
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
174
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
175 (defun vc-mtn-wash-log (file))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
176
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
177 (defun vc-mtn-diff (files &optional rev1 rev2 buffer)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
178 (apply 'vc-mtn-command (or buffer "*vc-diff*") 1 files "diff"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
179 (append (if rev1 (list "-r" rev1)) (if rev2 (list "-r" rev2)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
180
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
181 (defun vc-mtn-annotate-command (file buf &optional rev)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
182 (apply 'vc-mtn-command buf 0 file "annotate"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
183 (if rev (list "-r" rev))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
184
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
185 (defconst vc-mtn-annotate-full-re
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
186 "^ *\\([0-9a-f]+\\)\\.* by [^ ]+ \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\): ")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
187 (defconst vc-mtn-annotate-any-re
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
188 (concat "^\\(?: +: \\|" vc-mtn-annotate-full-re "\\)"))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
189
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
190 (defun vc-mtn-annotate-time ()
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
191 (when (looking-at vc-mtn-annotate-any-re)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
192 (goto-char (match-end 0))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
193 (let ((year (match-string 2)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
194 (if (not year)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
195 ;; Look for the date on a previous line.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
196 (save-excursion
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
197 (get-text-property (1- (previous-single-property-change
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
198 (point) 'vc-mtn-time nil (point-min)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
199 'vc-mtn-time))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
200 (let ((time (vc-annotate-convert-time
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
201 (encode-time 0 0 0
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
202 (string-to-number (match-string 4))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
203 (string-to-number (match-string 3))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
204 (string-to-number year)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
205 t))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
206 (let ((inhibit-read-only t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
207 (inhibit-modification-hooks t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
208 (put-text-property (match-beginning 0) (match-end 0)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
209 'vc-mtn-time time))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
210 time)))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
211
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
212 (defun vc-mtn-annotate-extract-revision-at-line ()
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
213 (save-excursion
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
214 (when (or (looking-at vc-mtn-annotate-full-re)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
215 (re-search-backward vc-mtn-annotate-full-re nil t))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
216 (match-string 1))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
217
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
218 ;;; Revision completion.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
219
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
220 (defun vc-mtn-list-tags ()
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
221 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
222 (vc-mtn-command t 0 nil "list" "tags")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
223 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
224 (let ((tags ()))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
225 (while (re-search-forward "^[^ ]+" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
226 (push (match-string 0) tags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
227 tags)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
228
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
229 (defun vc-mtn-list-branches ()
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
230 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
231 (vc-mtn-command t 0 nil "list" "branches")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
232 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
233 (let ((branches ()))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
234 (while (re-search-forward "^.+" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
235 (push (match-string 0) branches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
236 branches)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
237
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
238 (defun vc-mtn-list-revision-ids (prefix)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
239 (with-temp-buffer
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
240 (vc-mtn-command t 0 nil "complete" "revision" prefix)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
241 (goto-char (point-min))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
242 (let ((ids ()))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
243 (while (re-search-forward "^.+" nil t)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
244 (push (match-string 0) ids))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
245 ids)))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
246
|
85461
abd6fdb45765
(vc-mtn-revision-completion-table):Make it work when the arg is a list of files.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
247 (defun vc-mtn-revision-completion-table (files)
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
248 ;; TODO: Implement completion for for selectors
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
249 ;; TODO: Implement completion for composite selectors.
|
85461
abd6fdb45765
(vc-mtn-revision-completion-table):Make it work when the arg is a list of files.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
250 (lexical-let ((files files))
|
abd6fdb45765
(vc-mtn-revision-completion-table):Make it work when the arg is a list of files.
Stefan Monnier <monnier@iro.umontreal.ca>
diff
changeset
|
251 ;; What about using `files'?!? --Stef
|
78791
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
252 (lambda (string pred action)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
253 (cond
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
254 ;; "Tag" selectors.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
255 ((string-match "\\`t:" string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
256 (complete-with-action action
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
257 (mapcar (lambda (tag) (concat "t:" tag))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
258 (vc-mtn-list-tags))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
259 string pred))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
260 ;; "Branch" selectors.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
261 ((string-match "\\`b:" string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
262 (complete-with-action action
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
263 (mapcar (lambda (tag) (concat "b:" tag))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
264 (vc-mtn-list-branches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
265 string pred))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
266 ;; "Head" selectors. Not sure how they differ from "branch" selectors.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
267 ((string-match "\\`h:" string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
268 (complete-with-action action
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
269 (mapcar (lambda (tag) (concat "h:" tag))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
270 (vc-mtn-list-branches))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
271 string pred))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
272 ;; "ID" selectors.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
273 ((string-match "\\`i:" string)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
274 (complete-with-action action
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
275 (mapcar (lambda (tag) (concat "i:" tag))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
276 (vc-mtn-list-revision-ids
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
277 (substring string (match-end 0))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
278 string pred))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
279 (t
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
280 (complete-with-action action
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
281 '("t:" "b:" "h:" "i:"
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
282 ;; Completion not implemented for these.
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
283 "a:" "c:" "d:" "e:" "l:")
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
284 string pred))))))
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
285
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
286
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
287
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
288 (provide 'vc-mtn)
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
289
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
290 ;; arch-tag: 2b89ffbc-cbb8-405a-9080-2eafd4becb70
|
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
diff
changeset
|
291 ;;; vc-mtn.el ends here
|