Mercurial > emacs
annotate lisp/vc-hg.el @ 96341:37dc31300d17
* xdisp.c (extend_face_to_end_of_line): Fix last change.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Thu, 26 Jun 2008 21:37:32 +0000 |
parents | d011b21b3f08 |
children | 65532b2a1819 |
rev | line source |
---|---|
78075 | 1 ;;; vc-hg.el --- VC backend for the mercurial version control system |
2 | |
79721 | 3 ;; Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. |
78075 | 4 |
5 ;; Author: Ivan Kanis | |
6 ;; Keywords: tools | |
7 | |
8 ;; This file is part of GNU Emacs. | |
9 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94572
diff
changeset
|
10 ;; GNU Emacs is free software: you can redistribute it and/or modify |
78075 | 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:
94572
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:
94572
diff
changeset
|
13 ;; (at your option) any later version. |
78075 | 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 | |
94678
ee5932bf781d
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
94572
diff
changeset
|
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
78075 | 22 |
23 ;;; Commentary: | |
24 | |
25 ;; This is a mercurial version control backend | |
26 | |
27 ;;; Thanks: | |
28 | |
29 ;;; Bugs: | |
30 | |
31 ;;; Installation: | |
32 | |
33 ;;; Todo: | |
34 | |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
35 ;; 1) Implement the rest of the vc interface. See the comment at the |
78075 | 36 ;; beginning of vc.el. The current status is: |
37 | |
38 ;; 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
|
39 ;; 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
|
40 ;; * 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
|
41 ;; STATE-QUERYING FUNCTIONS |
78075 | 42 ;; * registered (file) OK |
43 ;; * state (file) OK | |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
44 ;; - state-heuristic (file) NOT NEEDED |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
45 ;; * working-revision (file) OK |
78075 | 46 ;; - latest-on-branch-p (file) ?? |
94563
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
47 ;; * checkout-model (files) OK |
78167
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
48 ;; - workfile-unchanged-p (file) OK |
78075 | 49 ;; - mode-line-string (file) NOT NEEDED |
94539
fee32a11924d
Name change in preparation for ripping out vc-dired.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94522
diff
changeset
|
50 ;; - prettify-state-info (file) OK |
78075 | 51 ;; 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
|
52 ;; * 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
|
53 ;; * create-repo () OK |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
54 ;; - init-revision () NOT NEEDED |
78075 | 55 ;; - responsible-p (file) OK |
56 ;; - could-register (file) OK | |
57 ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED | |
58 ;; - 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
|
59 ;; * checkin (files rev comment) OK |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
60 ;; * find-revision (file rev buffer) OK |
78148
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
61 ;; * checkout (file &optional editable rev) OK |
78075 | 62 ;; * revert (file &optional contents-done) OK |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
63 ;; - rollback (files) ?? PROBABLY NOT NEEDED |
78075 | 64 ;; - merge (file rev1 rev2) NEEDED |
65 ;; - merge-news (file) NEEDED | |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
66 ;; - steal-lock (file &optional revision) NOT NEEDED |
78075 | 67 ;; 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
|
68 ;; * print-log (files &optional buffer) OK |
78075 | 69 ;; - log-view-mode () OK |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
70 ;; - show-log-entry (revision) NOT NEEDED, DEFAULT IS GOOD |
78075 | 71 ;; - comment-history (file) NOT NEEDED |
72 ;; - 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
|
73 ;; * 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
|
74 ;; - revision-completion-table (files) OK? |
78075 | 75 ;; - annotate-command (file buf &optional rev) OK |
76 ;; - annotate-time () OK | |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
77 ;; - annotate-current-time () NOT NEEDED |
78075 | 78 ;; - annotate-extract-revision-at-line () OK |
95020
4da572dc4992
Snapshot primitives globally renamed to refer to tags, documentation updated.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94853
diff
changeset
|
79 ;; TAG SYSTEM |
4da572dc4992
Snapshot primitives globally renamed to refer to tags, documentation updated.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94853
diff
changeset
|
80 ;; - create-tag (dir name branchp) NEEDED |
4da572dc4992
Snapshot primitives globally renamed to refer to tags, documentation updated.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94853
diff
changeset
|
81 ;; - retrieve-tag (dir name update) NEEDED |
78075 | 82 ;; MISCELLANEOUS |
83 ;; - make-version-backups-p (file) ?? | |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
84 ;; - repository-hostname (dirname) ?? |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
85 ;; - previous-revision (file rev) OK |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
86 ;; - next-revision (file rev) OK |
78075 | 87 ;; - check-headers () ?? |
88 ;; - clear-headers () ?? | |
89 ;; - delete-file (file) TEST IT | |
90 ;; - rename-file (old new) OK | |
91 ;; - find-file-hook () PROBABLY NOT NEEDED | |
92 ;; - find-file-not-found-hook () PROBABLY NOT NEEDED | |
93 | |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
94 ;; 2) Implement Stefan Monnier's advice: |
78075 | 95 ;; vc-hg-registered and vc-hg-state |
96 ;; Both of those functions should be super extra careful to fail gracefully in | |
97 ;; unexpected circumstances. The reason this is important is that any error | |
98 ;; there will prevent the user from even looking at the file :-( | |
99 ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under | |
100 ;; mercurial's control and extracting the current revision should be done | |
101 ;; without even using `hg' (this way even if you don't have `hg' installed, | |
102 ;; Emacs is able to tell you this file is under mercurial's control). | |
103 | |
104 ;;; History: | |
105 ;; | |
106 | |
107 ;;; Code: | |
108 | |
109 (eval-when-compile | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
110 (require 'cl) |
96260 | 111 (require 'vc) |
112 (require 'vc-dir)) | |
78075 | 113 |
114 ;;; Customization options | |
115 | |
116 (defcustom vc-hg-global-switches nil | |
117 "*Global switches to pass to any Hg command." | |
118 :type '(choice (const :tag "None" nil) | |
119 (string :tag "Argument String") | |
120 (repeat :tag "Argument List" | |
121 :value ("") | |
122 string)) | |
123 :version "22.2" | |
124 :group 'vc) | |
125 | |
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
|
126 |
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
|
127 ;;; 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
|
128 |
94563
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
129 (defun vc-hg-revision-granularity () 'repository) |
a0bb8ca25a33
Clean up vc*-revision-granularity and vc*-checkout-model.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94542
diff
changeset
|
130 (defun vc-hg-checkout-model (files) 'implicit) |
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 |
78075 | 132 ;;; State querying functions |
133 | |
134 ;;;###autoload (defun vc-hg-registered (file) | |
135 ;;;###autoload "Return non-nil if FILE is registered with hg." | |
136 ;;;###autoload (if (vc-find-root file ".hg") ; short cut | |
137 ;;;###autoload (progn | |
138 ;;;###autoload (load "vc-hg") | |
139 ;;;###autoload (vc-hg-registered file)))) | |
140 | |
141 ;; Modelled after the similar function in vc-bzr.el | |
142 (defun vc-hg-registered (file) | |
143 "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
|
144 (when (vc-hg-root file) ; short cut |
87455
06f57a4af48c
(vc-hg-registered): Return the false when vc-hg-state
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87450
diff
changeset
|
145 (let ((state (vc-hg-state file))) ; expensive |
06f57a4af48c
(vc-hg-registered): Return the false when vc-hg-state
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87450
diff
changeset
|
146 (vc-file-setprop file 'vc-state state) |
87865
1a3c90d4d8fa
* vc-hg.el (vc-hg-registered): Make it work for non-existent
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87844
diff
changeset
|
147 (and state (not (memq state '(ignored unregistered))))))) |
78075 | 148 |
149 (defun vc-hg-state (file) | |
150 "Hg-specific version of `vc-state'." | |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
151 (let* |
78075 | 152 ((status nil) |
153 (out | |
154 (with-output-to-string | |
155 (with-current-buffer | |
156 standard-output | |
157 (setq status | |
158 (condition-case nil | |
159 ;; Ignore all errors. | |
160 (call-process | |
161 "hg" nil t nil "--cwd" (file-name-directory file) | |
87455
06f57a4af48c
(vc-hg-registered): Return the false when vc-hg-state
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87450
diff
changeset
|
162 "status" "-A" (file-name-nondirectory file)) |
78075 | 163 ;; Some problem happened. E.g. We can't find an `hg' |
164 ;; executable. | |
165 (error nil))))))) | |
166 (when (eq 0 status) | |
78166
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
167 (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
|
168 (let ((state (aref out 0))) |
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
169 (cond |
87574
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87480
diff
changeset
|
170 ((eq state ?=) 'up-to-date) |
93118
01d3fd1a2cfe
* vc-hg.el (vc-hg-state):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92345
diff
changeset
|
171 ((eq state ?A) 'added) |
78166
516805bc7988
(vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78148
diff
changeset
|
172 ((eq state ?M) 'edited) |
87450
71fc7b1db920
* vc-hooks.el (vc-state): Document new 'ignored and 'unregistered
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
87442
diff
changeset
|
173 ((eq state ?I) 'ignored) |
93163
521810ff0616
(vc-hg-state): Return 'removed for removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93162
diff
changeset
|
174 ((eq state ?R) 'removed) |
93327
f6aa1bf031f5
(vc-hg-state, vc-hg-dir-state): Deal with 'missing
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93176
diff
changeset
|
175 ((eq state ?!) 'missing) |
87450
71fc7b1db920
* vc-hooks.el (vc-state): Document new 'ignored and 'unregistered
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
87442
diff
changeset
|
176 ((eq state ??) 'unregistered) |
87574
21fcd219fd6e
* mouse.el (mouse-popup-menubar): Fix typo.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87480
diff
changeset
|
177 ((eq state ?C) 'up-to-date) ;; Older mercurials use this |
87455
06f57a4af48c
(vc-hg-registered): Return the false when vc-hg-state
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87450
diff
changeset
|
178 (t 'up-to-date))))))) |
78075 | 179 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
180 (defun vc-hg-working-revision (file) |
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
181 "Hg-specific version of `vc-working-revision'." |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
182 (let* |
78075 | 183 ((status nil) |
184 (out | |
185 (with-output-to-string | |
186 (with-current-buffer | |
187 standard-output | |
188 (setq status | |
189 (condition-case nil | |
190 ;; Ignore all errors. | |
191 (call-process | |
192 "hg" nil t nil "--cwd" (file-name-directory file) | |
193 "log" "-l1" (file-name-nondirectory file)) | |
194 ;; Some problem happened. E.g. We can't find an `hg' | |
195 ;; executable. | |
196 (error nil))))))) | |
197 (when (eq 0 status) | |
198 (if (string-match "changeset: *\\([0-9]*\\)" out) | |
199 (match-string 1 out) | |
200 "0")))) | |
201 | |
202 ;;; History functions | |
203 | |
87427
1aea302af710
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
86234
diff
changeset
|
204 (defun vc-hg-print-log (files &optional buffer) |
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
|
205 "Get change log associated with FILES." |
87427
1aea302af710
*** empty log message ***
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
86234
diff
changeset
|
206 ;; `log-view-mode' needs to have the file names in order to function |
78075 | 207 ;; correctly. "hg log" does not print it, so we insert it here by |
208 ;; hand. | |
209 | |
210 ;; `vc-do-command' creates the buffer, but we need it before running | |
211 ;; the command. | |
212 (vc-setup-buffer buffer) | |
213 ;; If the buffer exists from a previous invocation it might be | |
214 ;; read-only. | |
215 (let ((inhibit-read-only t)) | |
95966
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
216 (with-current-buffer |
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
217 buffer |
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
218 (vc-hg-command buffer 0 files "log")))) |
78075 | 219 |
220 (defvar log-view-message-re) | |
221 (defvar log-view-file-re) | |
222 (defvar log-view-font-lock-keywords) | |
95966
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
223 (defvar log-view-per-file-logs) |
78075 | 224 |
78404
27f00e50116a
Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents:
78363
diff
changeset
|
225 (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
|
226 (require 'add-log) ;; we need the add-log faces |
95966
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
227 (set (make-local-variable 'log-view-file-re) "\\`a\\`") |
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
228 (set (make-local-variable 'log-view-per-file-logs) nil) |
78075 | 229 (set (make-local-variable 'log-view-message-re) |
230 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)") | |
231 (set (make-local-variable 'log-view-font-lock-keywords) | |
232 (append | |
233 log-view-font-lock-keywords | |
79725
4ceae4ec8fb2
(vc-hg-log-view-mode): Handle the user field better.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79722
diff
changeset
|
234 '( |
78075 | 235 ;; Handle the case: |
236 ;; user: FirstName LastName <foo@bar> | |
237 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]" | |
238 (1 'change-log-name) | |
239 (2 'change-log-email)) | |
79725
4ceae4ec8fb2
(vc-hg-log-view-mode): Handle the user field better.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79722
diff
changeset
|
240 ;; Handle the cases: |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
241 ;; user: foo@bar |
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
242 ;; and |
79725
4ceae4ec8fb2
(vc-hg-log-view-mode): Handle the user field better.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79722
diff
changeset
|
243 ;; user: foo |
4ceae4ec8fb2
(vc-hg-log-view-mode): Handle the user field better.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79722
diff
changeset
|
244 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)" |
4ceae4ec8fb2
(vc-hg-log-view-mode): Handle the user field better.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79722
diff
changeset
|
245 (1 'change-log-email)) |
78075 | 246 ("^date: \\(.+\\)" (1 'change-log-date)) |
247 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))) | |
248 | |
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
|
249 (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
|
250 "Get a difference report using hg between two revisions of FILES." |
95966
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
251 (let* ((firstfile (car files)) |
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
252 (working (and firstfile (vc-working-revision firstfile)))) |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
253 (when (and (equal oldvers working) (not newvers)) |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
254 (setq oldvers nil)) |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
255 (when (and (not oldvers) newvers) |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
256 (setq oldvers working)) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
257 (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
|
258 (mapcar (lambda (file) (file-name-nondirectory file)) files) |
95966
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
259 "--cwd" (or (when firstfile (file-name-directory firstfile)) |
054335cbee3d
* log-view.el (log-view-diff-changeset): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95542
diff
changeset
|
260 (expand-file-name default-directory)) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
261 "diff" |
78075 | 262 (append |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
263 (when oldvers |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
264 (if newvers |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
265 (list "-r" oldvers "-r" newvers) |
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
266 (list "-r" oldvers))))))) |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
267 |
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
|
268 (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
|
269 (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
|
270 (with-temp-buffer |
86234
860a7a8e779e
* progmodes/octave-mod.el (inferior-octave-send-list-and-digest):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85510
diff
changeset
|
271 (vc-hg-command t nil files "log" "--template" "{rev} ") |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
272 (split-string |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
273 (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
|
274 |
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
275 ;; 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
|
276 (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
|
277 (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
|
278 table) |
2dd5d799a16d
* vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78236
diff
changeset
|
279 (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
|
280 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
|
281 table)) |
78075 | 282 |
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
|
283 (defun vc-hg-annotate-command (file buffer &optional revision) |
78075 | 284 "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
|
285 Optional arg REVISION is a revision to annotate from." |
95542
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
286 (vc-hg-command buffer 0 file "annotate" "-d" "-n" |
94853
1c9a3c7fa4f1
(vc-hg-diff, vc-hg-annotate-command): Use when not if.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94847
diff
changeset
|
287 (when revision (concat "-r" revision))) |
78075 | 288 (with-current-buffer buffer |
289 (goto-char (point-min)) | |
80582
7c7ae81f80df
(vc-hg-annotate-command): Allow white space before version number.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79800
diff
changeset
|
290 (re-search-forward "^[ \t]*[0-9]") |
7c7ae81f80df
(vc-hg-annotate-command): Allow white space before version number.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
79800
diff
changeset
|
291 (delete-region (point-min) (match-beginning 0)))) |
78075 | 292 |
96213
09da7727f35f
* vc-hg.el (vc-annotate-convert-time, vc-default-status-printer):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95966
diff
changeset
|
293 (declare-function vc-annotate-convert-time "vc-annotate" (time)) |
78075 | 294 |
295 ;; The format for one line output by "hg annotate -d -n" looks like this: | |
296 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS | |
297 ;; i.e: VERSION_NUMBER DATE: CONTENTS | |
80585
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
298 ;; If the user has set the "--follow" option, the output looks like: |
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
299 ;;215 Wed Jun 20 21:22:58 2007 -0700 foo.c: CONTENTS |
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
300 ;; i.e. VERSION_NUMBER DATE FILENAME: CONTENTS |
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
301 (defconst vc-hg-annotate-re |
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
302 "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\)[^:\n]*\\(:[^ \n][^:\n]*\\)*: ") |
78075 | 303 |
304 (defun vc-hg-annotate-time () | |
305 (when (looking-at vc-hg-annotate-re) | |
306 (goto-char (match-end 0)) | |
307 (vc-annotate-convert-time | |
308 (date-to-time (match-string-no-properties 2))))) | |
309 | |
310 (defun vc-hg-annotate-extract-revision-at-line () | |
311 (save-excursion | |
312 (beginning-of-line) | |
80585
8c0cc53e8234
(vc-hg-annotate-re): Recognize the output of --follow.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
80582
diff
changeset
|
313 (when (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) |
78075 | 314 |
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
|
315 (defun vc-hg-previous-revision (file rev) |
78075 | 316 (let ((newrev (1- (string-to-number rev)))) |
317 (when (>= newrev 0) | |
318 (number-to-string newrev)))) | |
319 | |
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
|
320 (defun vc-hg-next-revision (file rev) |
78075 | 321 (let ((newrev (1+ (string-to-number rev))) |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
322 (tip-revision |
78075 | 323 (with-temp-buffer |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
324 (vc-hg-command t 0 nil "tip") |
78075 | 325 (goto-char (point-min)) |
326 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") | |
327 (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
|
328 ;; 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
|
329 ;; 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
|
330 (when (<= newrev tip-revision) |
78075 | 331 (number-to-string newrev)))) |
332 | |
333 ;; Modelled after the similar function in vc-bzr.el | |
334 (defun vc-hg-delete-file (file) | |
335 "Delete FILE and delete it in the hg repository." | |
336 (condition-case () | |
337 (delete-file file) | |
338 (file-error nil)) | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
339 (vc-hg-command nil 0 file "remove" "--after" "--force")) |
78075 | 340 |
341 ;; Modelled after the similar function in vc-bzr.el | |
342 (defun vc-hg-rename-file (old new) | |
343 "Rename file from OLD to NEW using `hg mv'." | |
94439
d6a121c992e3
(vc-hg-rename-file): Fix argument order.
Sam Steingold <sds@gnu.org>
parents:
94003
diff
changeset
|
344 (vc-hg-command nil 0 new "mv" old)) |
78075 | 345 |
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
|
346 (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
|
347 "Register FILES under hg. |
78075 | 348 REV is ignored. |
349 COMMENT is ignored." | |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
350 (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
|
351 |
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
|
352 (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
|
353 "Create a new Mercurial repository." |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
354 (vc-hg-command nil 0 nil "init")) |
78075 | 355 |
356 (defalias 'vc-hg-responsible-p 'vc-hg-root) | |
357 | |
358 ;; Modelled after the similar function in vc-bzr.el | |
359 (defun vc-hg-could-register (file) | |
360 "Return non-nil if FILE could be registered under hg." | |
361 (and (vc-hg-responsible-p file) ; shortcut | |
362 (condition-case () | |
363 (with-temp-buffer | |
364 (vc-hg-command t nil file "add" "--dry-run")) | |
365 ;; The command succeeds with no output if file is | |
366 ;; registered. | |
367 (error)))) | |
368 | |
369 ;; XXX This would remove the file. Is that correct? | |
370 ;; (defun vc-hg-unregister (file) | |
371 ;; "Unregister FILE from hg." | |
372 ;; (vc-hg-command nil nil file "remove")) | |
373 | |
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
|
374 (defun vc-hg-checkin (files rev comment) |
78404
27f00e50116a
Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents:
78363
diff
changeset
|
375 "Hg-specific version of `vc-backend-checkin'. |
78075 | 376 REV is ignored." |
82012
878cfe0c0c5a
(vc-hg-dir-state): Fix loop.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81998
diff
changeset
|
377 (vc-hg-command nil 0 files "commit" "-m" comment)) |
78075 | 378 |
85139
8ba0e30716a5
Terminology cleanup.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
83759
diff
changeset
|
379 (defun vc-hg-find-revision (file rev buffer) |
78075 | 380 (let ((coding-system-for-read 'binary) |
381 (coding-system-for-write 'binary)) | |
382 (if rev | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
383 (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
|
384 (vc-hg-command buffer 0 file "cat")))) |
78075 | 385 |
386 ;; 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
|
387 (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
|
388 "Retrieve a revision of FILE. |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
389 EDITABLE is ignored. |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
390 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
|
391 (let ((coding-system-for-read 'binary) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
392 (coding-system-for-write 'binary)) |
9cbb2ce8ec8c
(vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78086
diff
changeset
|
393 (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
|
394 (if rev |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
395 (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
|
396 (vc-hg-command t 0 file "cat"))))) |
78075 | 397 |
78167
252b7f091c04
(vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78166
diff
changeset
|
398 ;; 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
|
399 (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
|
400 (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
|
401 |
78075 | 402 ;; Modelled after the similar function in vc-bzr.el |
403 (defun vc-hg-revert (file &optional contents-done) | |
404 (unless contents-done | |
78182
86c8d81f944f
(vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
78167
diff
changeset
|
405 (with-temp-buffer (vc-hg-command t 0 file "revert")))) |
78075 | 406 |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
407 ;;; Hg specific functionality. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
408 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
409 (defvar vc-hg-extra-menu-map |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
410 (let ((map (make-sparse-keymap))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
411 (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
|
412 (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
|
413 map)) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
414 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
415 (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
|
416 |
92122
74bf6df13b6c
* vc.el (vc-find-revision): Make vc-parent-buffer local before
Dan Nicolaescu <dann@ics.uci.edu>
parents:
92093
diff
changeset
|
417 (defun vc-hg-extra-status-menu () vc-hg-extra-menu-map) |
91951
d42fe75822fe
* vc.el (vc-status-menu, vc-status-menu-map-filter): New functions.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87903
diff
changeset
|
418 |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
419 (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
|
420 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
421 (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
|
422 |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
423 (defstruct (vc-hg-extra-fileinfo |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
424 (:copier nil) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
425 (:constructor vc-hg-create-extra-fileinfo (rename-state extra-name)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
426 (:conc-name vc-hg-extra-fileinfo->)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
427 rename-state ;; rename or copy state |
95542
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
428 extra-name) ;; original name for copies and rename targets, new name for |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
429 |
96213
09da7727f35f
* vc-hg.el (vc-annotate-convert-time, vc-default-status-printer):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95966
diff
changeset
|
430 (declare-function vc-default-status-printer "vc-dir" (backend fileentry)) |
09da7727f35f
* vc-hg.el (vc-annotate-convert-time, vc-default-status-printer):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
95966
diff
changeset
|
431 |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
432 (defun vc-hg-status-printer (info) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
433 "Pretty-printer for the vc-dir-fileinfo structure." |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
434 (let ((extra (vc-dir-fileinfo->extra info))) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
435 (vc-default-status-printer 'Hg info) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
436 (when extra |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
437 (insert (propertize |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
438 (format " (%s %s)" |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
439 (case (vc-hg-extra-fileinfo->rename-state extra) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
440 ('copied "copied from") |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
441 ('renamed-from "renamed from") |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
442 ('renamed-to "renamed to")) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
443 (vc-hg-extra-fileinfo->extra-name extra)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
444 'face 'font-lock-comment-face))))) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
445 |
94003
2ecb2ea8d5b5
Change `dir-status' to not take (and pass) status-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93957
diff
changeset
|
446 (defun vc-hg-after-dir-status (update-function) |
87844
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
447 (let ((status-char nil) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
448 (file nil) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
449 (translation '((?= . up-to-date) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
450 (?C . up-to-date) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
451 (?A . added) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
452 (?R . removed) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
453 (?M . edited) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
454 (?I . ignored) |
93176
c985261aee9c
* vc-hg.el (vc-hg-after-dir-status):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93163
diff
changeset
|
455 (?! . missing) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
456 (? . copy-rename-line) |
87844
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
457 (?? . unregistered))) |
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
458 (translated nil) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
459 (result nil) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
460 (last-added nil) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
461 (last-line-copy nil)) |
87844
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
462 (goto-char (point-min)) |
87599
efe45ef69877
* vc.el (vc-status-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87574
diff
changeset
|
463 (while (not (eobp)) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
464 (setq translated (cdr (assoc (char-after) translation))) |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
465 (setq file |
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
466 (buffer-substring-no-properties (+ (point) 2) |
87844
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
467 (line-end-position))) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
468 (cond ((not translated) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
469 (setq last-line-copy nil)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
470 ((eq translated 'up-to-date) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
471 (setq last-line-copy nil)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
472 ((eq translated 'copy-rename-line) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
473 ;; For copied files the output looks like this: |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
474 ;; A COPIED_FILE_NAME |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
475 ;; ORIGINAL_FILE_NAME |
95542
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
476 (setf (nth 2 last-added) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
477 (vc-hg-create-extra-fileinfo 'copied file)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
478 (setq last-line-copy t)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
479 ((and last-line-copy (eq translated 'removed)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
480 ;; For renamed files the output looks like this: |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
481 ;; A NEW_FILE_NAME |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
482 ;; ORIGINAL_FILE_NAME |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
483 ;; R ORIGINAL_FILE_NAME |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
484 ;; We need to adjust the previous entry to not think it is a copy. |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
485 (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
486 'renamed-from) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
487 (push (list file translated |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
488 (vc-hg-create-extra-fileinfo |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
489 'renamed-to (nth 0 last-added))) result) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
490 (setq last-line-copy nil)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
491 (t |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
492 (setq last-added (list file translated nil)) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
493 (push last-added result) |
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
494 (setq last-line-copy nil))) |
87599
efe45ef69877
* vc.el (vc-status-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87574
diff
changeset
|
495 (forward-line)) |
94003
2ecb2ea8d5b5
Change `dir-status' to not take (and pass) status-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93957
diff
changeset
|
496 (funcall update-function result))) |
87844
3bd7c8c8bbe7
* vc.el: Make vc-status asynchronous.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87674
diff
changeset
|
497 |
94003
2ecb2ea8d5b5
Change `dir-status' to not take (and pass) status-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93957
diff
changeset
|
498 (defun vc-hg-dir-status (dir update-function) |
94511
40171abb3041
(vc-hg-extra-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
94481
diff
changeset
|
499 (vc-hg-command (current-buffer) 'async dir "status" "-C") |
93382
8e46096e0cb3
* vc.el (vc-status-menu-map, vc-status-mode-map): Bind vc-revert.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
93327
diff
changeset
|
500 (vc-exec-after |
94003
2ecb2ea8d5b5
Change `dir-status' to not take (and pass) status-buffer.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
93957
diff
changeset
|
501 `(vc-hg-after-dir-status (quote ,update-function)))) |
87599
efe45ef69877
* vc.el (vc-status-fileinfo): New defstruct.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87574
diff
changeset
|
502 |
95542
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
503 (defun vc-hg-status-extra-header (name &rest commands) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
504 (concat (propertize name 'face 'font-lock-type-face) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
505 (propertize |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
506 (with-temp-buffer |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
507 (apply 'vc-hg-command (current-buffer) 0 nil commands) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
508 (buffer-substring-no-properties (point-min) (1- (point-max)))) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
509 'face 'font-lock-variable-name-face))) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
510 |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
511 (defun vc-hg-status-extra-headers (dir) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
512 "Generate extra status headers for a Mercurial tree." |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
513 (let ((default-directory dir)) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
514 (concat |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
515 (vc-hg-status-extra-header "Root : " "root") "\n" |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
516 (vc-hg-status-extra-header "Branch : " "id" "-b") "\n" |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
517 (vc-hg-status-extra-header "Tags : " "id" "-t") ; "\n" |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
518 ;; these change after each commit |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
519 ;; (vc-hg-status-extra-header "Local num : " "id" "-n") "\n" |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
520 ;; (vc-hg-status-extra-header "Global id : " "id" "-i") |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
521 ))) |
dfffc14d8182
(vc-hg-status-extra-header, vc-hg-status-extra-headers):
Sam Steingold <sds@gnu.org>
parents:
95087
diff
changeset
|
522 |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
523 ;; 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
|
524 ;; replace the Log-View menu. |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
525 (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
|
526 "Hg-outgoing Display Menu" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
527 `("Hg-outgoing" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
528 ["Push selected" vc-hg-push])) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
529 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
530 (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
|
531 "Hg-incoming Display Menu" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
532 `("Hg-incoming" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
533 ["Pull selected" vc-hg-pull])) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
534 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
535 (defun vc-hg-outgoing () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
536 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
537 (let ((bname "*Hg outgoing*")) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
538 (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
|
539 (pop-to-buffer bname) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
540 (vc-hg-outgoing-mode))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
541 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
542 (defun vc-hg-incoming () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
543 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
544 (let ((bname "*Hg incoming*")) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
545 (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
|
546 (pop-to-buffer bname) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
547 (vc-hg-incoming-mode))) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
548 |
86234
860a7a8e779e
* progmodes/octave-mod.el (inferior-octave-send-list-and-digest):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85510
diff
changeset
|
549 (declare-function log-view-get-marked "log-view" ()) |
860a7a8e779e
* progmodes/octave-mod.el (inferior-octave-send-list-and-digest):
Dan Nicolaescu <dann@ics.uci.edu>
parents:
85510
diff
changeset
|
550 |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
551 ;; 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
|
552 (defun vc-hg-push () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
553 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
554 (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
|
555 (if marked-list |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
556 (vc-hg-command |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
557 nil 0 nil |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
558 (cons "push" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
559 (apply 'nconc |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
560 (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
|
561 (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
|
562 |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
563 (defun vc-hg-pull () |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
564 (interactive) |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
565 (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
|
566 (if marked-list |
91991
f40c311f15ac
Kill eol whitespace; nfc.
Thien-Thi Nguyen <ttn@gnuvola.org>
parents:
91953
diff
changeset
|
567 (vc-hg-command |
83759
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
568 nil 0 nil |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
569 (cons "pull" |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
570 (apply 'nconc |
493b2df20f41
(vc-hg-extra-menu-map): New variable.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
82245
diff
changeset
|
571 (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
|
572 (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
|
573 |
78075 | 574 ;;; Internal functions |
575 | |
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
|
576 (defun vc-hg-command (buffer okstatus file-or-list &rest flags) |
78075 | 577 "A wrapper around `vc-do-command' for use in vc-hg.el. |
578 The difference to vc-do-command is that this function always invokes `hg', | |
579 and that it passes `vc-hg-global-switches' to it before FLAGS." | |
94847
5e64dca662f0
Remove assumption about what nil means as a first arument to vc-do-command.
Eric S. Raymond <esr@snark.thyrsus.com>
parents:
94806
diff
changeset
|
580 (apply 'vc-do-command (or buffer "*vc*") okstatus "hg" file-or-list |
78075 | 581 (if (stringp vc-hg-global-switches) |
582 (cons vc-hg-global-switches flags) | |
583 (append vc-hg-global-switches | |
584 flags)))) | |
585 | |
586 (defun vc-hg-root (file) | |
587 (vc-find-root file ".hg")) | |
588 | |
589 (provide 'vc-hg) | |
590 | |
78086 | 591 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954 |
78075 | 592 ;;; vc-hg.el ends here |