Mercurial > emacs
annotate lisp/vc-hg.el @ 85737:0999d33b3bac
Fix typo.
author | Glenn Morris <rgm@gnu.org> |
---|---|
date | Mon, 29 Oct 2007 00:27:55 +0000 |
parents | e2eac01cf548 |
children | 860a7a8e779e |
rev | line source |
---|---|
78075 | 1 ;;; vc-hg.el --- VC backend for the mercurial version control system |
2 | |
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc. | |
4 | |
5 ;; Author: Ivan Kanis | |
6 ;; Keywords: tools | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
10 ;; GNU Emacs is free software; you can redistribute it and/or modify | |
11 ;; it under the terms of the GNU General Public License as published by | |
78236
9355f9b7bbff
Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents:
78211
diff
changeset
|
12 ;; the Free Software Foundation; either version 3, or (at your option) |
78075 | 13 ;; any later version. |
14 | |
15 ;; GNU Emacs is distributed in the hope that it will be useful, | |
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 | |
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the | |
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | |
23 ;; Boston, MA 02110-1301, USA. | |
24 | |
25 ;;; Commentary: | |
26 | |
27 ;; This is a mercurial version control backend | |
28 | |
29 ;;; Thanks: | |
30 | |
31 ;;; Bugs: | |
32 | |
33 ;;; Installation: | |
34 | |
35 ;;; Todo: | |
36 | |
37 ;; Implement the rest of the vc interface. See the comment at the | |
38 ;; beginning of vc.el. The current status is: | |
39 | |
40 ;; FUNCTION NAME STATUS | |
81982
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
41 ;; BACKEND PROPERTIES |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
42 ;; * revision-granularity OK |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
43 ;; STATE-QUERYING FUNCTIONS |
78075 | 44 ;; * registered (file) OK |
45 ;; * state (file) OK | |
46 ;; - state-heuristic (file) ?? PROBABLY NOT NEEDED | |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
47 ;; - dir-state (dir) OK |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
48 ;; * working-revision (file) OK |
78075 | 49 ;; - latest-on-branch-p (file) ?? |
50 ;; * checkout-model (file) OK | |
78167
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
51 ;; - workfile-unchanged-p (file) OK |
78075 | 52 ;; - mode-line-string (file) NOT NEEDED |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
53 ;; - dired-state-info (file) OK |
78075 | 54 ;; STATE-CHANGING FUNCTIONS |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
55 ;; * register (files &optional rev comment) OK |
81982
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
56 ;; * create-repo () OK |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
57 ;; - init-revision () NOT NEEDED |
78075 | 58 ;; - responsible-p (file) OK |
59 ;; - could-register (file) OK | |
60 ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED | |
61 ;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
62 ;; * checkin (files rev comment) OK |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
63 ;; * find-revision (file rev buffer) OK |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
64 ;; * checkout (file &optional editable rev) OK |
78075 | 65 ;; * revert (file &optional contents-done) OK |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
66 ;; - rollback (files) ?? PROBABLY NOT NEEDED |
78075 | 67 ;; - merge (file rev1 rev2) NEEDED |
68 ;; - merge-news (file) NEEDED | |
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
|
69 ;; - steal-lock (file &optional revision) NOT NEEDED |
78075 | 70 ;; HISTORY FUNCTIONS |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
71 ;; * print-log (files &optional buffer) OK |
78075 | 72 ;; - log-view-mode () OK |
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
|
73 ;; - show-log-entry (revision) NOT NEEDED, DEFAULT IS GOOD |
78075 | 74 ;; - wash-log (file) ?? |
75 ;; - logentry-check () NOT NEEDED | |
76 ;; - comment-history (file) NOT NEEDED | |
77 ;; - update-changelog (files) NOT NEEDED | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
78 ;; * diff (files &optional rev1 rev2 buffer) OK |
85462
43a9834cf1a6
* vc-bzr.el (vc-bzr-diff-tree):
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85460
diff
changeset
|
79 ;; - revision-completion-table (files) OK? |
78075 | 80 ;; - annotate-command (file buf &optional rev) OK |
81 ;; - annotate-time () OK | |
82 ;; - annotate-current-time () ?? NOT NEEDED | |
83 ;; - annotate-extract-revision-at-line () OK | |
84 ;; SNAPSHOT SYSTEM | |
85 ;; - create-snapshot (dir name branchp) NEEDED (probably branch?) | |
86 ;; - assign-name (file name) NOT NEEDED | |
87 ;; - retrieve-snapshot (dir name update) ?? NEEDED?? | |
88 ;; MISCELLANEOUS | |
89 ;; - make-version-backups-p (file) ?? | |
90 ;; - repository-hostname (dirname) ?? | |
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
|
91 ;; - previous-revision (file rev) OK |
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
|
92 ;; - next-revision (file rev) OK |
78075 | 93 ;; - check-headers () ?? |
94 ;; - clear-headers () ?? | |
95 ;; - delete-file (file) TEST IT | |
96 ;; - rename-file (old new) OK | |
97 ;; - find-file-hook () PROBABLY NOT NEEDED | |
98 ;; - find-file-not-found-hook () PROBABLY NOT NEEDED | |
99 | |
100 ;; Implement Stefan Monnier's advice: | |
101 ;; vc-hg-registered and vc-hg-state | |
102 ;; Both of those functions should be super extra careful to fail gracefully in | |
103 ;; unexpected circumstances. The reason this is important is that any error | |
104 ;; there will prevent the user from even looking at the file :-( | |
105 ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under | |
106 ;; mercurial's control and extracting the current revision should be done | |
107 ;; without even using `hg' (this way even if you don't have `hg' installed, | |
108 ;; Emacs is able to tell you this file is under mercurial's control). | |
109 | |
110 ;;; History: | |
111 ;; | |
112 | |
113 ;;; Code: | |
114 | |
115 (eval-when-compile | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
116 (require 'cl) |
78075 | 117 (require 'vc)) |
118 | |
119 ;;; Customization options | |
120 | |
121 (defcustom vc-hg-global-switches nil | |
122 "*Global switches to pass to any Hg command." | |
123 :type '(choice (const :tag "None" nil) | |
124 (string :tag "Argument String") | |
125 (repeat :tag "Argument List" | |
126 :value ("") | |
127 string)) | |
128 :version "22.2" | |
129 :group 'vc) | |
130 | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
131 |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
132 ;;; Properties of the backend |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
133 |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
134 (defun vc-hg-revision-granularity () |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
135 'repository) |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
136 |
78075 | 137 ;;; State querying functions |
138 | |
139 ;;;###autoload (defun vc-hg-registered (file) | |
140 ;;;###autoload "Return non-nil if FILE is registered with hg." | |
141 ;;;###autoload (if (vc-find-root file ".hg") ; short cut | |
142 ;;;###autoload (progn | |
143 ;;;###autoload (load "vc-hg") | |
144 ;;;###autoload (vc-hg-registered file)))) | |
145 | |
146 ;; Modelled after the similar function in vc-bzr.el | |
147 (defun vc-hg-registered (file) | |
148 "Return non-nil if FILE is registered with hg." | |
78166
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
149 (when (vc-hg-root file) ; short cut |
78363
9b9e30a9b135
* vc-hg.el (vc-hg-registered): Set the vc-state property.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78359
diff
changeset
|
150 (vc-file-setprop file 'vc-state (vc-hg-state file)))) ; expensive |
78075 | 151 |
152 (defun vc-hg-state (file) | |
153 "Hg-specific version of `vc-state'." | |
154 (let* | |
155 ((status nil) | |
156 (out | |
157 (with-output-to-string | |
158 (with-current-buffer | |
159 standard-output | |
160 (setq status | |
161 (condition-case nil | |
162 ;; Ignore all errors. | |
163 (call-process | |
164 "hg" nil t nil "--cwd" (file-name-directory file) | |
165 "status" (file-name-nondirectory file)) | |
166 ;; Some problem happened. E.g. We can't find an `hg' | |
167 ;; executable. | |
168 (error nil))))))) | |
169 (when (eq 0 status) | |
170 (if (eq 0 (length out)) 'up-to-date | |
78166
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
171 (when (null (string-match ".*: No such file or directory$" out)) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
172 (let ((state (aref out 0))) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
173 (cond |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
174 ((eq state ?A) 'edited) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
175 ((eq state ?M) 'edited) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
176 ((eq state ?R) nil) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
177 ((eq state ??) nil) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
178 (t 'up-to-date)))))))) |
78075 | 179 |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
180 (defun vc-hg-dir-state (dir) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
181 (with-temp-buffer |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
182 (vc-hg-command (current-buffer) nil nil "status") |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
183 (goto-char (point-min)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
184 (let ((status-char nil) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
185 (file nil)) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
186 (while (not (eobp)) |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
187 (setq status-char (char-after)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
188 (setq file |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
189 (expand-file-name |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
190 (buffer-substring-no-properties (+ (point) 2) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
191 (line-end-position)))) |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
192 (cond |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
193 ;; The rest of the possible states in "hg status" output: |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
194 ;; R = removed |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
195 ;; ! = deleted, but still tracked |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
196 ;; ? = not tracked |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
197 ;; should not show up in vc-dired, so don't deal with them |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
198 ;; here. |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
199 ((eq status-char ?A) |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
200 (vc-file-setprop file 'vc-working-revision "0") |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
201 (vc-file-setprop file 'vc-state 'edited)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
202 ((eq status-char ?M) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
203 (vc-file-setprop file 'vc-state 'edited)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
204 ((eq status-char ??) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
205 (vc-file-setprop file 'vc-backend 'none) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
206 (vc-file-setprop file 'vc-state 'nil))) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
207 (forward-line))))) |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
208 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
209 (defun vc-hg-working-revision (file) |
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
210 "Hg-specific version of `vc-working-revision'." |
78075 | 211 (let* |
212 ((status nil) | |
213 (out | |
214 (with-output-to-string | |
215 (with-current-buffer | |
216 standard-output | |
217 (setq status | |
218 (condition-case nil | |
219 ;; Ignore all errors. | |
220 (call-process | |
221 "hg" nil t nil "--cwd" (file-name-directory file) | |
222 "log" "-l1" (file-name-nondirectory file)) | |
223 ;; Some problem happened. E.g. We can't find an `hg' | |
224 ;; executable. | |
225 (error nil))))))) | |
226 (when (eq 0 status) | |
227 (if (string-match "changeset: *\\([0-9]*\\)" out) | |
228 (match-string 1 out) | |
229 "0")))) | |
230 | |
231 ;;; History functions | |
232 | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
233 (defun vc-hg-print-log(files &optional buffer) |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
234 "Get change log associated with FILES." |
78075 | 235 ;; `log-view-mode' needs to have the file name in order to function |
236 ;; correctly. "hg log" does not print it, so we insert it here by | |
237 ;; hand. | |
238 | |
239 ;; `vc-do-command' creates the buffer, but we need it before running | |
240 ;; the command. | |
241 (vc-setup-buffer buffer) | |
242 ;; If the buffer exists from a previous invocation it might be | |
243 ;; read-only. | |
244 (let ((inhibit-read-only t)) | |
81982
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
245 ;; We need to loop and call "hg log" on each file separately. |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
246 ;; "hg log" with multiple file arguments mashes all the logs |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
247 ;; together. |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
248 (dolist (file files) |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
249 (with-current-buffer |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
250 buffer |
d4b8336cd8f5
* vc-hg.el (vc-hg-print-log): Deal with multiple file arguments.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81964
diff
changeset
|
251 (insert "File: " (file-name-nondirectory file) "\n")) |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
252 (vc-hg-command buffer 0 file "log")))) |
78075 | 253 |
254 (defvar log-view-message-re) | |
255 (defvar log-view-file-re) | |
256 (defvar log-view-font-lock-keywords) | |
257 | |
82245
36893fdf92ab
Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents:
82221
diff
changeset
|
258 (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View" |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
259 (require 'add-log) ;; we need the add-log faces |
78075 | 260 (set (make-local-variable 'log-view-file-re) "^File:[ \t]+\\(.+\\)") |
261 (set (make-local-variable 'log-view-message-re) | |
262 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)") | |
263 (set (make-local-variable 'log-view-font-lock-keywords) | |
264 (append | |
265 log-view-font-lock-keywords | |
266 ;; Handle the case: | |
267 ;; user: foo@bar | |
268 '(("^user:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)" | |
269 (1 'change-log-email)) | |
270 ;; Handle the case: | |
271 ;; user: FirstName LastName <foo@bar> | |
272 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" | |
273 (1 'change-log-name) | |
274 (2 'change-log-email)) | |
275 ("^date: \\(.+\\)" (1 'change-log-date)) | |
276 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) | |
277 | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
278 (defun vc-hg-diff (files &optional oldvers newvers buffer) |
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
|
279 "Get a difference report using hg between two revisions of FILES." |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
280 (let ((working (vc-working-revision (car files)))) |
78075 | 281 (if (and (equal oldvers working) (not newvers)) |
282 (setq oldvers nil)) | |
283 (if (and (not oldvers) newvers) | |
284 (setq oldvers working)) | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
285 (apply #'vc-hg-command (or buffer "*vc-diff*") nil |
81998
52950d8efd2b
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81986
diff
changeset
|
286 (mapcar (lambda (file) (file-name-nondirectory file)) files) |
52950d8efd2b
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81986
diff
changeset
|
287 "--cwd" (file-name-directory (car files)) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
288 "diff" |
78075 | 289 (append |
290 (if oldvers | |
291 (if newvers | |
292 (list "-r" oldvers "-r" newvers) | |
293 (list "-r" oldvers)) | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
294 (list "")))))) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
295 |
85460
d36b2b98840f
(vc-hg-revision-completion-table, vc-hg-revision-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
296 (defun vc-hg-revision-table (files) |
d36b2b98840f
(vc-hg-revision-completion-table, vc-hg-revision-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
297 (let ((default-directory (file-name-directory (car files)))) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
298 (with-temp-buffer |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
299 (vc-hg-command t nil file "log" "--template" "{rev} ") |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
300 (split-string |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
301 (buffer-substring-no-properties (point-min) (point-max)))))) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
302 |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
303 ;; Modelled after the similar function in vc-cvs.el |
85460
d36b2b98840f
(vc-hg-revision-completion-table, vc-hg-revision-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
304 (defun vc-hg-revision-completion-table (files) |
d36b2b98840f
(vc-hg-revision-completion-table, vc-hg-revision-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
305 (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
|
306 table) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
307 (setq table (lazy-completion-table |
85460
d36b2b98840f
(vc-hg-revision-completion-table, vc-hg-revision-table): Make it work when the
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
85141
diff
changeset
|
308 table (lambda () (vc-hg-revision-table files)))) |
78359
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
309 table)) |
78075 | 310 |
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
|
311 (defun vc-hg-annotate-command (file buffer &optional revision) |
78075 | 312 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. |
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
|
313 Optional arg REVISION is a revision to annotate from." |
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
|
314 (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if revision (concat "-r" revision))) |
78075 | 315 (with-current-buffer buffer |
316 (goto-char (point-min)) | |
317 (re-search-forward "^[0-9]") | |
318 (delete-region (point-min) (1- (point))))) | |
319 | |
320 | |
321 ;; The format for one line output by "hg annotate -d -n" looks like this: | |
322 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS | |
323 ;; i.e: VERSION_NUMBER DATE: CONTENTS | |
324 (defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ") | |
325 | |
326 (defun vc-hg-annotate-time () | |
327 (when (looking-at vc-hg-annotate-re) | |
328 (goto-char (match-end 0)) | |
329 (vc-annotate-convert-time | |
330 (date-to-time (match-string-no-properties 2))))) | |
331 | |
332 (defun vc-hg-annotate-extract-revision-at-line () | |
333 (save-excursion | |
334 (beginning-of-line) | |
335 (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) | |
336 | |
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
|
337 (defun vc-hg-previous-revision (file rev) |
78075 | 338 (let ((newrev (1- (string-to-number rev)))) |
339 (when (>= newrev 0) | |
340 (number-to-string newrev)))) | |
341 | |
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
|
342 (defun vc-hg-next-revision (file rev) |
78075 | 343 (let ((newrev (1+ (string-to-number rev))) |
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
|
344 (tip-revision |
78075 | 345 (with-temp-buffer |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
346 (vc-hg-command t 0 nil "tip") |
78075 | 347 (goto-char (point-min)) |
348 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") | |
349 (string-to-number (match-string-no-properties 1))))) | |
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
|
350 ;; We don't want to exceed the maximum possible revision number, ie |
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
|
351 ;; the tip revision. |
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
|
352 (when (<= newrev tip-revision) |
78075 | 353 (number-to-string newrev)))) |
354 | |
355 ;; Modelled after the similar function in vc-bzr.el | |
356 (defun vc-hg-delete-file (file) | |
357 "Delete FILE and delete it in the hg repository." | |
358 (condition-case () | |
359 (delete-file file) | |
360 (file-error nil)) | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
361 (vc-hg-command nil 0 file "remove" "--after" "--force")) |
78075 | 362 |
363 ;; Modelled after the similar function in vc-bzr.el | |
364 (defun vc-hg-rename-file (old new) | |
365 "Rename file from OLD to NEW using `hg mv'." | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
366 (vc-hg-command nil 0 new old "mv")) |
78075 | 367 |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
368 (defun vc-hg-register (files &optional rev comment) |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
369 "Register FILES under hg. |
78075 | 370 REV is ignored. |
371 COMMENT is ignored." | |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
372 (vc-hg-command nil 0 files "add")) |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
373 |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
374 (defun vc-hg-create-repo () |
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
375 "Create a new Mercurial repository." |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
376 (vc-hg-command nil 0 nil "init")) |
78075 | 377 |
378 (defalias 'vc-hg-responsible-p 'vc-hg-root) | |
379 | |
380 ;; Modelled after the similar function in vc-bzr.el | |
381 (defun vc-hg-could-register (file) | |
382 "Return non-nil if FILE could be registered under hg." | |
383 (and (vc-hg-responsible-p file) ; shortcut | |
384 (condition-case () | |
385 (with-temp-buffer | |
386 (vc-hg-command t nil file "add" "--dry-run")) | |
387 ;; The command succeeds with no output if file is | |
388 ;; registered. | |
389 (error)))) | |
390 | |
391 ;; XXX This would remove the file. Is that correct? | |
392 ;; (defun vc-hg-unregister (file) | |
393 ;; "Unregister FILE from hg." | |
394 ;; (vc-hg-command nil nil file "remove")) | |
395 | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
396 (defun vc-hg-checkin (files rev comment) |
82245
36893fdf92ab
Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents:
82221
diff
changeset
|
397 "Hg-specific version of `vc-backend-checkin'. |
78075 | 398 REV is ignored." |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
399 (vc-hg-command nil 0 files "commit" "-m" comment)) |
78075 | 400 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
401 (defun vc-hg-find-revision (file rev buffer) |
78075 | 402 (let ((coding-system-for-read 'binary) |
403 (coding-system-for-write 'binary)) | |
404 (if rev | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
405 (vc-hg-command buffer 0 file "cat" "-r" rev) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
406 (vc-hg-command buffer 0 file "cat")))) |
78075 | 407 |
408 ;; Modelled after the similar function in vc-bzr.el | |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
409 (defun vc-hg-checkout (file &optional editable rev) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
410 "Retrieve a revision of FILE. |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
411 EDITABLE is ignored. |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
412 REV is the revision to check out into WORKFILE." |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
413 (let ((coding-system-for-read 'binary) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
414 (coding-system-for-write 'binary)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
415 (with-current-buffer (or (get-file-buffer file) (current-buffer)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
416 (if rev |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
417 (vc-hg-command t 0 file "cat" "-r" rev) |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
418 (vc-hg-command t 0 file "cat"))))) |
78075 | 419 |
420 (defun vc-hg-checkout-model (file) | |
421 'implicit) | |
422 | |
78167
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
423 ;; Modelled after the similar function in vc-bzr.el |
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
424 (defun vc-hg-workfile-unchanged-p (file) |
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
425 (eq 'up-to-date (vc-hg-state file))) |
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
426 |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
427 (defun vc-hg-dired-state-info (file) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
428 "Hg-specific version of `vc-dired-state-info'." |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
429 (let ((hg-state (vc-state file))) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
430 (if (eq hg-state 'edited) |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
431 (if (equal (vc-working-revision file) "0") |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
432 "(added)" "(modified)") |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
433 ;; fall back to the default VC representation |
82245
36893fdf92ab
Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents:
82221
diff
changeset
|
434 (vc-default-dired-state-info 'Hg file)))) |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
435 |
78075 | 436 ;; Modelled after the similar function in vc-bzr.el |
437 (defun vc-hg-revert (file &optional contents-done) | |
438 (unless contents-done | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
439 (with-temp-buffer (vc-hg-command t 0 file "revert")))) |
78075 | 440 |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
441 ;;; Hg specific functionality. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
442 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
443 ;;; XXX This functionality is experimental/work in progress. It might |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
444 ;;; change without notice. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
445 (defvar vc-hg-extra-menu-map |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
446 (let ((map (make-sparse-keymap))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
447 (define-key map [incoming] '(menu-item "Show incoming" vc-hg-incoming)) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
448 (define-key map [outgoing] '(menu-item "Show outgoing" vc-hg-outgoing)) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
449 map)) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
450 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
451 (defun vc-hg-extra-menu () vc-hg-extra-menu-map) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
452 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
453 (define-derived-mode vc-hg-outgoing-mode vc-hg-log-view-mode "Hg-Outgoing") |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
454 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
455 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming") |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
456 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
457 ;; XXX this adds another top level menu, instead figure out how to |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
458 ;; replace the Log-View menu. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
459 (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
460 "Hg-outgoing Display Menu" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
461 `("Hg-outgoing" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
462 ["Push selected" vc-hg-push])) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
463 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
464 (easy-menu-define log-view-mode-menu vc-hg-incoming-mode-map |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
465 "Hg-incoming Display Menu" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
466 `("Hg-incoming" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
467 ["Pull selected" vc-hg-pull])) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
468 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
469 (defun vc-hg-outgoing () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
470 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
471 (let ((bname "*Hg outgoing*")) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
472 (vc-hg-command bname 0 nil "outgoing" "-n") |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
473 (pop-to-buffer bname) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
474 (vc-hg-outgoing-mode))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
475 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
476 (defun vc-hg-incoming () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
477 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
478 (let ((bname "*Hg incoming*")) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
479 (vc-hg-command bname 0 nil "incoming" "-n") |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
480 (pop-to-buffer bname) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
481 (vc-hg-incoming-mode))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
482 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
483 ;; XXX maybe also add key bindings for these functions. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
484 (defun vc-hg-push () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
485 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
486 (let ((marked-list (log-view-get-marked))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
487 (if marked-list |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
488 (vc-hg-command |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
489 nil 0 nil |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
490 (cons "push" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
491 (apply 'nconc |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
492 (mapcar (lambda (arg) (list "-r" arg)) marked-list)))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
493 (error "No log entries selected for push")))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
494 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
495 (defun vc-hg-pull () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
496 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
497 (let ((marked-list (log-view-get-marked))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
498 (if marked-list |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
499 (vc-hg-command |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
500 nil 0 nil |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
501 (cons "pull" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
502 (apply 'nconc |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
503 (mapcar (lambda (arg) (list "-r" arg)) marked-list)))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
504 (error "No log entries selected for pull")))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
505 |
78075 | 506 ;;; Internal functions |
507 | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
508 (defun vc-hg-command (buffer okstatus file-or-list &rest flags) |
78075 | 509 "A wrapper around `vc-do-command' for use in vc-hg.el. |
510 The difference to vc-do-command is that this function always invokes `hg', | |
511 and that it passes `vc-hg-global-switches' to it before FLAGS." | |
81964
ba5a7f46413b
Put the lower half (the back-end) of NewVC in place. This commit
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
81757
diff
changeset
|
512 (apply 'vc-do-command buffer okstatus "hg" file-or-list |
78075 | 513 (if (stringp vc-hg-global-switches) |
514 (cons vc-hg-global-switches flags) | |
515 (append vc-hg-global-switches | |
516 flags)))) | |
517 | |
518 (defun vc-hg-root (file) | |
519 (vc-find-root file ".hg")) | |
520 | |
521 (provide 'vc-hg) | |
522 | |
78086 | 523 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954 |
78075 | 524 ;;; vc-hg.el ends here |