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