Mercurial > emacs
annotate lisp/vc-mtn.el @ 108830:0d7ed8742a5f
emulation/cua-base.el: Recognize `right-char', `left-char' as movement commands.
author | Juanma Barranquero <lekktu@gmail.com> |
---|---|
date | Sun, 30 May 2010 06:44:46 +0200 |
parents | 1918e70c8b37 |
children | c05344a913c8 |
rev | line source |
---|---|
78791 | 1 ;;; vc-mtn.el --- VC backend for Monotone |
2 | |
106815 | 3 ;; Copyright (C) 2007, 2008, 2009, 2010 Free Software Foundation, Inc. |
78791 | 4 |
5 ;; Author: Stefan Monnier <monnier@iro.umontreal.ca> | |
6 ;; Keywords: | |
7 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
8 ;; This file is part of GNU Emacs. |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
9 |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
78791 | 11 ;; 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
|
12 ;; 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
|
13 ;; (at your option) any later version. |
78791 | 14 |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
15 ;; GNU Emacs is distributed in the hope that it will be useful, |
78791 | 16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 ;; GNU General Public License for more details. | |
19 | |
20 ;; 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
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
78791 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; | |
26 | |
96125
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
27 ;;; TODO: |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
28 |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
29 ;; - The `previous-version' VC method needs to be supported, 'D' in |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
30 ;; log-view-mode uses it. |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
31 |
78791 | 32 ;;; Code: |
33 | |
34 (eval-when-compile (require 'cl) (require 'vc)) | |
35 | |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
36 (defcustom vc-mtn-diff-switches t |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
37 "String or list of strings specifying switches for monotone diff under VC. |
100182
880b72ca5f06
(vc-mtn-diff-switches): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
100058
diff
changeset
|
38 If nil, use the value of `vc-diff-switches'. If t, use no switches." |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
39 :type '(choice (const :tag "Unspecified" nil) |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
40 (const :tag "None" t) |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
41 (string :tag "Argument String") |
100182
880b72ca5f06
(vc-mtn-diff-switches): Doc fix.
Glenn Morris <rgm@gnu.org>
parents:
100058
diff
changeset
|
42 (repeat :tag "Argument List" :value ("") string)) |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
43 :version "23.1" |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
44 :group 'vc) |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
45 |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
46 (define-obsolete-variable-alias 'vc-mtn-command 'vc-mtn-program "23.1") |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
47 (defcustom vc-mtn-program "mtn" |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
48 "Name of the monotone executable." |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
49 :type 'string |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
50 :group 'vc) |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
51 |
78791 | 52 ;; Clear up the cache to force vc-call to check again and discover |
53 ;; new functions when we reload this file. | |
54 (put 'Mtn 'vc-functions nil) | |
55 | |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
56 (unless (executable-find vc-mtn-program) |
78791 | 57 ;; vc-mtn.el is 100% non-functional without the `mtn' executable. |
58 (setq vc-handled-backends (delq 'Mtn vc-handled-backends))) | |
59 | |
60 ;;;###autoload | |
61 (defconst vc-mtn-admin-dir "_MTN") | |
62 ;;;###autoload | |
63 (defconst vc-mtn-admin-format (concat vc-mtn-admin-dir "/format")) | |
64 | |
65 ;;;###autoload (defun vc-mtn-registered (file) | |
66 ;;;###autoload (if (vc-find-root file vc-mtn-admin-format) | |
67 ;;;###autoload (progn | |
68 ;;;###autoload (load "vc-mtn") | |
69 ;;;###autoload (vc-mtn-registered file)))) | |
70 | |
71 (defun vc-mtn-revision-granularity () 'repository) | |
94563
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94521
diff
changeset
|
72 (defun vc-mtn-checkout-model (files) 'implicit) |
78791 | 73 |
74 (defun vc-mtn-root (file) | |
75 (setq file (if (file-directory-p file) | |
76 (file-name-as-directory file) | |
77 (file-name-directory file))) | |
78 (or (vc-file-getprop file 'vc-mtn-root) | |
79 (vc-file-setprop file 'vc-mtn-root | |
80 (vc-find-root file vc-mtn-admin-format)))) | |
81 | |
82 | |
83 (defun vc-mtn-registered (file) | |
84 (let ((root (vc-mtn-root file))) | |
85 (when root | |
86 (vc-mtn-state file)))) | |
87 | |
88 (defun vc-mtn-command (buffer okstatus files &rest flags) | |
89 "A wrapper around `vc-do-command' for use in vc-mtn.el." | |
93564
eeb1bb8489e4
(vc-mtn-command): Avoid localization of messages.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93144
diff
changeset
|
90 (let ((process-environment |
eeb1bb8489e4
(vc-mtn-command): Avoid localization of messages.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93144
diff
changeset
|
91 ;; Avoid localization of messages so we can parse the output. |
eeb1bb8489e4
(vc-mtn-command): Avoid localization of messages.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93144
diff
changeset
|
92 (cons "LC_MESSAGES=C" process-environment))) |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
93 (apply 'vc-do-command (or buffer "*vc*") okstatus vc-mtn-program |
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
94 files flags))) |
78791 | 95 |
96 (defun vc-mtn-state (file) | |
97 ;; If `mtn' fails or returns status>0, or if the search files, just | |
98 ;; return nil. | |
99 (ignore-errors | |
100 (with-temp-buffer | |
101 (vc-mtn-command t 0 file "status") | |
102 (goto-char (point-min)) | |
93144
33c08cf9fb3a
(vc-mtn-state): Support the added state.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92692
diff
changeset
|
103 (re-search-forward |
33c08cf9fb3a
(vc-mtn-state): Support the added state.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92692
diff
changeset
|
104 "^ \\(?:\\(patched\\)\\|\\(added\\) \\(?:.*\\)\\)\\|no changes$") |
33c08cf9fb3a
(vc-mtn-state): Support the added state.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92692
diff
changeset
|
105 (cond ((match-end 1) 'edited) |
33c08cf9fb3a
(vc-mtn-state): Support the added state.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92692
diff
changeset
|
106 ((match-end 2) 'added) |
33c08cf9fb3a
(vc-mtn-state): Support the added state.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92692
diff
changeset
|
107 (t 'up-to-date))))) |
78791 | 108 |
103542
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
109 (defun vc-mtn-after-dir-status (update-function) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
110 (let (result) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
111 (goto-char (point-min)) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
112 (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)" nil t) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
113 (while (re-search-forward |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
114 "^ \\(?:\\(patched \\)\\|\\(added \\)\\)\\(.*\\)$" nil t) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
115 (cond ((match-end 1) (push (list (match-string 3) 'edited) result)) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
116 ((match-end 2) (push (list (match-string 3) 'added) result)))) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
117 (funcall update-function result))) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
118 |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
119 (defun vc-mtn-dir-status (dir update-function) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
120 (vc-mtn-command (current-buffer) 'async dir "status") |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
121 (vc-exec-after |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
122 `(vc-mtn-after-dir-status (quote ,update-function)))) |
01b5e53f519a
(vc-mtn-after-dir-status, vc-mtn-dir-status): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
102812
diff
changeset
|
123 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
78791
diff
changeset
|
124 (defun vc-mtn-working-revision (file) |
78791 | 125 ;; If `mtn' fails or returns status>0, or if the search fails, just |
126 ;; return nil. | |
127 (ignore-errors | |
128 (with-temp-buffer | |
129 (vc-mtn-command t 0 file "status") | |
130 (goto-char (point-min)) | |
131 (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)") | |
132 (match-string 2)))) | |
133 | |
134 (defun vc-mtn-workfile-branch (file) | |
135 ;; If `mtn' fails or returns status>0, or if the search files, just | |
136 ;; return nil. | |
137 (ignore-errors | |
138 (with-temp-buffer | |
139 (vc-mtn-command t 0 file "status") | |
140 (goto-char (point-min)) | |
141 (re-search-forward "Current branch: \\(.*\\)\nChanges against parent \\(.*\\)") | |
142 (match-string 1)))) | |
143 | |
144 (defun vc-mtn-workfile-unchanged-p (file) | |
145 (not (eq (vc-mtn-state file) 'edited))) | |
146 | |
147 ;; Mode-line rewrite code copied from vc-arch.el. | |
148 | |
149 (defcustom vc-mtn-mode-line-rewrite | |
150 '(("\\`[^:/#]*[:/#]" . "")) ;Drop the host part. | |
151 "Rewrite rules to shorten Mtn's revision names on the mode-line." | |
152 :type '(repeat (cons regexp string)) | |
80261
4af0bb174714
* textmodes/css-mode.el (css-indent-offset, css-electric-keys):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79721
diff
changeset
|
153 :version "22.2" |
78791 | 154 :group 'vc) |
155 | |
156 (defun vc-mtn-mode-line-string (file) | |
157 "Return string for placement in modeline by `vc-mode-line' for FILE." | |
158 (let ((branch (vc-mtn-workfile-branch file))) | |
159 (dolist (rule vc-mtn-mode-line-rewrite) | |
160 (if (string-match (car rule) branch) | |
161 (setq branch (replace-match (cdr rule) t nil branch)))) | |
162 (format "Mtn%c%s" | |
163 (case (vc-state file) | |
94521
2a61c5f918a5
Change 'needs-patch to 'needs-update.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
93564
diff
changeset
|
164 ((up-to-date needs-update) ?-) |
78791 | 165 (added ?@) |
166 (t ?:)) | |
167 branch))) | |
168 | |
102812
62b984273010
(vc-mtn-register): Fix optional arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
100908
diff
changeset
|
169 (defun vc-mtn-register (files &optional rev comment) |
78791 | 170 (vc-mtn-command nil 0 files "add")) |
171 | |
172 (defun vc-mtn-responsible-p (file) (vc-mtn-root file)) | |
173 (defun vc-mtn-could-register (file) (vc-mtn-root file)) | |
174 | |
107430
1918e70c8b37
Add special markup processing for commit logs.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106815
diff
changeset
|
175 (defun vc-mtn-checkin (files rev comment &optional extra-args-ignored) |
78791 | 176 (vc-mtn-command nil 0 files "commit" "-m" comment)) |
177 | |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
78791
diff
changeset
|
178 (defun vc-mtn-find-revision (file rev buffer) |
78791 | 179 (vc-mtn-command buffer 0 file "cat" "-r" rev)) |
180 | |
181 ;; (defun vc-mtn-checkout (file &optional editable rev) | |
182 ;; ) | |
183 | |
184 (defun vc-mtn-revert (file &optional contents-done) | |
185 (unless contents-done | |
186 (vc-mtn-command nil 0 file "revert"))) | |
187 | |
188 ;; (defun vc-mtn-roolback (files) | |
189 ;; ) | |
190 | |
106472
6e0f1038bc44
Support showing a single log entry from vc-annotate.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106033
diff
changeset
|
191 (defun vc-mtn-print-log (files buffer &optional shortlog start-revision limit) |
106033
2bed02fa3041
* vc.el (vc-log-show-limit): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105011
diff
changeset
|
192 (apply 'vc-mtn-command buffer 0 files "log" |
106472
6e0f1038bc44
Support showing a single log entry from vc-annotate.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
106033
diff
changeset
|
193 (append |
106489
d7d82ba7ae74
(vc-mtn-print-log): Fix typo in previous.
Glenn Morris <rgm@gnu.org>
parents:
106472
diff
changeset
|
194 (when start-revision (list "--from" (format "%s" start-revision))) |
d7d82ba7ae74
(vc-mtn-print-log): Fix typo in previous.
Glenn Morris <rgm@gnu.org>
parents:
106472
diff
changeset
|
195 (when limit (list "--last" (format "%s" limit)))))) |
78791 | 196 |
85478
786d3a985758
* term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85462
diff
changeset
|
197 (defvar log-view-message-re) |
786d3a985758
* term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85462
diff
changeset
|
198 (defvar log-view-file-re) |
786d3a985758
* term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85462
diff
changeset
|
199 (defvar log-view-font-lock-keywords) |
96125
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
200 (defvar log-view-per-file-logs) |
85478
786d3a985758
* term/x-win.el (x-gtk-stock-map, icon-map-list)
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85462
diff
changeset
|
201 |
78791 | 202 (define-derived-mode vc-mtn-log-view-mode log-view-mode "Mtn-Log-View" |
96125
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
203 ;; Don't match anything. |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
204 (set (make-local-variable 'log-view-file-re) "\\`a\\`") |
673e286487b1
(vc-mtn-log-view-mode): Set log-view-per-file-logs and
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
205 (set (make-local-variable 'log-view-per-file-logs) nil) |
78791 | 206 ;; TODO: Use a more precise regexp than "[ |/]+" to avoid false positives |
207 ;; in the ChangeLog text. | |
208 (set (make-local-variable 'log-view-message-re) | |
209 "^[ |/]+Revision: \\([0-9a-f]+\\)") | |
210 (require 'add-log) ;For change-log faces. | |
211 (set (make-local-variable 'log-view-font-lock-keywords) | |
212 (append log-view-font-lock-keywords | |
213 '(("^[ |]+Author: \\(.*\\)" (1 'change-log-email)) | |
214 ("^[ |]+Date: \\(.*\\)" (1 'change-log-date-face)))))) | |
215 | |
85141
b16f7408cd3f
Carry through today's big terminology change to a few places where I
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
85139
diff
changeset
|
216 ;; (defun vc-mtn-show-log-entry (revision) |
78791 | 217 ;; ) |
218 | |
219 (defun vc-mtn-diff (files &optional rev1 rev2 buffer) | |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
220 "Get a difference report using monotone between two revisions of FILES." |
78791 | 221 (apply 'vc-mtn-command (or buffer "*vc-diff*") 1 files "diff" |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
222 (append |
100058
fc3d57499127
(vc-mtn-diff): No need to duplicate vc-switches logic.
Glenn Morris <rgm@gnu.org>
parents:
99785
diff
changeset
|
223 (vc-switches 'mtn 'diff) |
99785
0a12c040f6e2
(vc-mtn-diff-switches): New option.
Glenn Morris <rgm@gnu.org>
parents:
96213
diff
changeset
|
224 (if rev1 (list "-r" rev1)) (if rev2 (list "-r" rev2))))) |
78791 | 225 |
226 (defun vc-mtn-annotate-command (file buf &optional rev) | |
105011
8acc6fb9ffc9
* vc-mtn.el (vc-mtn-annotate-command):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
105010
diff
changeset
|
227 (apply 'vc-mtn-command buf 'async file "annotate" |
78791 | 228 (if rev (list "-r" rev)))) |
229 | |
96213
09da7727f35f
* vc-hg.el (vc-annotate-convert-time, vc-default-status-printer):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96125
diff
changeset
|
230 (declare-function vc-annotate-convert-time "vc-annotate" (time)) |
09da7727f35f
* vc-hg.el (vc-annotate-convert-time, vc-default-status-printer):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96125
diff
changeset
|
231 |
78791 | 232 (defconst vc-mtn-annotate-full-re |
233 "^ *\\([0-9a-f]+\\)\\.* by [^ ]+ \\([0-9]+\\)-\\([0-9]+\\)-\\([0-9]+\\): ") | |
234 (defconst vc-mtn-annotate-any-re | |
235 (concat "^\\(?: +: \\|" vc-mtn-annotate-full-re "\\)")) | |
236 | |
237 (defun vc-mtn-annotate-time () | |
238 (when (looking-at vc-mtn-annotate-any-re) | |
239 (goto-char (match-end 0)) | |
240 (let ((year (match-string 2))) | |
241 (if (not year) | |
242 ;; Look for the date on a previous line. | |
243 (save-excursion | |
244 (get-text-property (1- (previous-single-property-change | |
245 (point) 'vc-mtn-time nil (point-min))) | |
246 'vc-mtn-time)) | |
247 (let ((time (vc-annotate-convert-time | |
248 (encode-time 0 0 0 | |
249 (string-to-number (match-string 4)) | |
250 (string-to-number (match-string 3)) | |
251 (string-to-number year) | |
252 t)))) | |
253 (let ((inhibit-read-only t) | |
254 (inhibit-modification-hooks t)) | |
255 (put-text-property (match-beginning 0) (match-end 0) | |
256 'vc-mtn-time time)) | |
257 time))))) | |
258 | |
259 (defun vc-mtn-annotate-extract-revision-at-line () | |
260 (save-excursion | |
261 (when (or (looking-at vc-mtn-annotate-full-re) | |
262 (re-search-backward vc-mtn-annotate-full-re nil t)) | |
263 (match-string 1)))) | |
264 | |
265 ;;; Revision completion. | |
266 | |
267 (defun vc-mtn-list-tags () | |
268 (with-temp-buffer | |
269 (vc-mtn-command t 0 nil "list" "tags") | |
270 (goto-char (point-min)) | |
271 (let ((tags ())) | |
272 (while (re-search-forward "^[^ ]+" nil t) | |
273 (push (match-string 0) tags)) | |
274 tags))) | |
275 | |
276 (defun vc-mtn-list-branches () | |
277 (with-temp-buffer | |
278 (vc-mtn-command t 0 nil "list" "branches") | |
279 (goto-char (point-min)) | |
280 (let ((branches ())) | |
281 (while (re-search-forward "^.+" nil t) | |
282 (push (match-string 0) branches)) | |
283 branches))) | |
284 | |
285 (defun vc-mtn-list-revision-ids (prefix) | |
286 (with-temp-buffer | |
287 (vc-mtn-command t 0 nil "complete" "revision" prefix) | |
288 (goto-char (point-min)) | |
289 (let ((ids ())) | |
290 (while (re-search-forward "^.+" nil t) | |
291 (push (match-string 0) ids)) | |
292 ids))) | |
293 | |
85461
abd6fdb45765
(vc-mtn-revision-completion-table):Make it work when the arg is a list of files.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
294 (defun vc-mtn-revision-completion-table (files) |
78791 | 295 ;; TODO: Implement completion for for selectors |
296 ;; 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>
parents:
85141
diff
changeset
|
297 (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>
parents:
85141
diff
changeset
|
298 ;; What about using `files'?!? --Stef |
78791 | 299 (lambda (string pred action) |
300 (cond | |
301 ;; "Tag" selectors. | |
302 ((string-match "\\`t:" string) | |
303 (complete-with-action action | |
304 (mapcar (lambda (tag) (concat "t:" tag)) | |
305 (vc-mtn-list-tags)) | |
306 string pred)) | |
307 ;; "Branch" selectors. | |
308 ((string-match "\\`b:" string) | |
309 (complete-with-action action | |
310 (mapcar (lambda (tag) (concat "b:" tag)) | |
311 (vc-mtn-list-branches)) | |
312 string pred)) | |
313 ;; "Head" selectors. Not sure how they differ from "branch" selectors. | |
314 ((string-match "\\`h:" string) | |
315 (complete-with-action action | |
316 (mapcar (lambda (tag) (concat "h:" tag)) | |
317 (vc-mtn-list-branches)) | |
318 string pred)) | |
319 ;; "ID" selectors. | |
320 ((string-match "\\`i:" string) | |
321 (complete-with-action action | |
322 (mapcar (lambda (tag) (concat "i:" tag)) | |
323 (vc-mtn-list-revision-ids | |
324 (substring string (match-end 0)))) | |
325 string pred)) | |
326 (t | |
327 (complete-with-action action | |
328 '("t:" "b:" "h:" "i:" | |
329 ;; Completion not implemented for these. | |
330 "a:" "c:" "d:" "e:" "l:") | |
331 string pred)))))) | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
332 |
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94563
diff
changeset
|
333 |
78791 | 334 |
335 (provide 'vc-mtn) | |
336 | |
337 ;; arch-tag: 2b89ffbc-cbb8-405a-9080-2eafd4becb70 | |
338 ;;; vc-mtn.el ends here |