* progmodes/meta-mode.el (meta-complete-symbol):
[emacs.git] / lisp / vc-hg.el
blobab4bdab8c500408caa851b92e80fa649c87051ae
1 ;;; vc-hg.el --- VC backend for the mercurial version control system
3 ;; Copyright (C) 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
5 ;; Author: Ivan Kanis
6 ;; Keywords: tools
8 ;; This file is part of GNU Emacs.
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
12 ;; the Free Software Foundation, either version 3 of the License, or
13 ;; (at your option) any later version.
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.
20 ;; You should have received a copy of the GNU General Public License
21 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
23 ;;; Commentary:
25 ;; This is a mercurial version control backend
27 ;;; Thanks:
29 ;;; Bugs:
31 ;;; Installation:
33 ;;; Todo:
35 ;; 1) Implement the rest of the vc interface. See the comment at the
36 ;; beginning of vc.el. The current status is:
38 ;; FUNCTION NAME STATUS
39 ;; BACKEND PROPERTIES
40 ;; * revision-granularity OK
41 ;; STATE-QUERYING FUNCTIONS
42 ;; * registered (file) OK
43 ;; * state (file) OK
44 ;; - state-heuristic (file) NOT NEEDED
45 ;; - dir-status (dir update-function) OK
46 ;; - dir-status-files (dir files ds uf) OK
47 ;; - dir-extra-headers (dir) OK
48 ;; - dir-printer (fileinfo) OK
49 ;; * working-revision (file) OK
50 ;; - latest-on-branch-p (file) ??
51 ;; * checkout-model (files) OK
52 ;; - workfile-unchanged-p (file) OK
53 ;; - mode-line-string (file) NOT NEEDED
54 ;; STATE-CHANGING FUNCTIONS
55 ;; * register (files &optional rev comment) OK
56 ;; * create-repo () OK
57 ;; - init-revision () NOT NEEDED
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
62 ;; * checkin (files rev comment) OK
63 ;; * find-revision (file rev buffer) OK
64 ;; * checkout (file &optional editable rev) OK
65 ;; * revert (file &optional contents-done) OK
66 ;; - rollback (files) ?? PROBABLY NOT NEEDED
67 ;; - merge (file rev1 rev2) NEEDED
68 ;; - merge-news (file) NEEDED
69 ;; - steal-lock (file &optional revision) NOT NEEDED
70 ;; HISTORY FUNCTIONS
71 ;; * print-log (files buffer &optional shortlog) OK
72 ;; - log-view-mode () OK
73 ;; - show-log-entry (revision) NOT NEEDED, DEFAULT IS GOOD
74 ;; - comment-history (file) NOT NEEDED
75 ;; - update-changelog (files) NOT NEEDED
76 ;; * diff (files &optional rev1 rev2 buffer) OK
77 ;; - revision-completion-table (files) OK?
78 ;; - annotate-command (file buf &optional rev) OK
79 ;; - annotate-time () OK
80 ;; - annotate-current-time () NOT NEEDED
81 ;; - annotate-extract-revision-at-line () OK
82 ;; TAG SYSTEM
83 ;; - create-tag (dir name branchp) NEEDED
84 ;; - retrieve-tag (dir name update) NEEDED
85 ;; MISCELLANEOUS
86 ;; - make-version-backups-p (file) ??
87 ;; - repository-hostname (dirname) ??
88 ;; - previous-revision (file rev) OK
89 ;; - next-revision (file rev) OK
90 ;; - check-headers () ??
91 ;; - clear-headers () ??
92 ;; - delete-file (file) TEST IT
93 ;; - rename-file (old new) OK
94 ;; - find-file-hook () PROBABLY NOT NEEDED
96 ;; 2) Implement Stefan Monnier's advice:
97 ;; vc-hg-registered and vc-hg-state
98 ;; Both of those functions should be super extra careful to fail gracefully in
99 ;; unexpected circumstances. The reason this is important is that any error
100 ;; there will prevent the user from even looking at the file :-(
101 ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under
102 ;; mercurial's control and extracting the current revision should be done
103 ;; without even using `hg' (this way even if you don't have `hg' installed,
104 ;; Emacs is able to tell you this file is under mercurial's control).
106 ;;; History:
109 ;;; Code:
111 (eval-when-compile
112 (require 'cl)
113 (require 'vc)
114 (require 'vc-dir))
116 ;;; Customization options
118 (defcustom vc-hg-global-switches nil
119 "Global switches to pass to any Hg command."
120 :type '(choice (const :tag "None" nil)
121 (string :tag "Argument String")
122 (repeat :tag "Argument List" :value ("") string))
123 :version "22.2"
124 :group 'vc)
126 (defcustom vc-hg-diff-switches t ; Hg doesn't support common args like -u
127 "String or list of strings specifying switches for Hg diff under VC.
128 If nil, use the value of `vc-diff-switches'. If t, use no switches."
129 :type '(choice (const :tag "Unspecified" nil)
130 (const :tag "None" t)
131 (string :tag "Argument String")
132 (repeat :tag "Argument List" :value ("") string))
133 :version "23.1"
134 :group 'vc)
137 ;;; Properties of the backend
139 (defun vc-hg-revision-granularity () 'repository)
140 (defun vc-hg-checkout-model (files) 'implicit)
142 ;;; State querying functions
144 ;;;###autoload (defun vc-hg-registered (file)
145 ;;;###autoload "Return non-nil if FILE is registered with hg."
146 ;;;###autoload (if (vc-find-root file ".hg") ; short cut
147 ;;;###autoload (progn
148 ;;;###autoload (load "vc-hg")
149 ;;;###autoload (vc-hg-registered file))))
151 ;; Modeled after the similar function in vc-bzr.el
152 (defun vc-hg-registered (file)
153 "Return non-nil if FILE is registered with hg."
154 (when (vc-hg-root file) ; short cut
155 (let ((state (vc-hg-state file))) ; expensive
156 (and state (not (memq state '(ignored unregistered)))))))
158 (defun vc-hg-state (file)
159 "Hg-specific version of `vc-state'."
160 (let*
161 ((status nil)
162 (default-directory (file-name-directory file))
163 (out
164 (with-output-to-string
165 (with-current-buffer
166 standard-output
167 (setq status
168 (condition-case nil
169 ;; Ignore all errors.
170 (process-file
171 "hg" nil t nil
172 "status" "-A" (file-relative-name file))
173 ;; Some problem happened. E.g. We can't find an `hg'
174 ;; executable.
175 (error nil)))))))
176 (when (eq 0 status)
177 (when (null (string-match ".*: No such file or directory$" out))
178 (let ((state (aref out 0)))
179 (cond
180 ((eq state ?=) 'up-to-date)
181 ((eq state ?A) 'added)
182 ((eq state ?M) 'edited)
183 ((eq state ?I) 'ignored)
184 ((eq state ?R) 'removed)
185 ((eq state ?!) 'missing)
186 ((eq state ??) 'unregistered)
187 ((eq state ?C) 'up-to-date) ;; Older mercurials use this
188 (t 'up-to-date)))))))
190 (defun vc-hg-working-revision (file)
191 "Hg-specific version of `vc-working-revision'."
192 (let*
193 ((status nil)
194 (default-directory (file-name-directory file))
195 (out
196 (with-output-to-string
197 (with-current-buffer
198 standard-output
199 (setq status
200 (condition-case nil
201 ;; Ignore all errors.
202 (process-file
203 "hg" nil t nil
204 "log" "-l1" (file-relative-name file))
205 ;; Some problem happened. E.g. We can't find an `hg'
206 ;; executable.
207 (error nil)))))))
208 (when (eq 0 status)
209 (if (string-match "changeset: *\\([0-9]*\\)" out)
210 (match-string 1 out)
211 "0"))))
213 ;;; History functions
215 (defcustom vc-hg-log-switches nil
216 "String or list of strings specifying switches for hg log under VC."
217 :type '(choice (const :tag "None" nil)
218 (string :tag "Argument String")
219 (repeat :tag "Argument List" :value ("") string))
220 :group 'vc-hg)
222 (defun vc-hg-print-log (files buffer &optional shortlog limit)
223 "Get change log associated with FILES."
224 ;; `vc-do-command' creates the buffer, but we need it before running
225 ;; the command.
226 (vc-setup-buffer buffer)
227 ;; If the buffer exists from a previous invocation it might be
228 ;; read-only.
229 (let ((inhibit-read-only t))
230 (with-current-buffer
231 buffer
232 (apply 'vc-hg-command buffer 0 files "log"
233 (append
234 (when limit (list "-l" (format "%s" limit)))
235 (when shortlog '("--style" "compact"))
236 vc-hg-log-switches)))))
238 (defvar log-view-message-re)
239 (defvar log-view-file-re)
240 (defvar log-view-font-lock-keywords)
241 (defvar log-view-per-file-logs)
242 (defvar vc-short-log)
244 (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View"
245 (require 'add-log) ;; we need the add-log faces
246 (set (make-local-variable 'log-view-file-re) "\\`a\\`")
247 (set (make-local-variable 'log-view-per-file-logs) nil)
248 (set (make-local-variable 'log-view-message-re)
249 (if vc-short-log
250 "^\\([0-9]+\\)\\(?:\\[.*\\]\\)? +\\([0-9a-z]\\{12\\}\\) +\\(\\(?:[0-9]+\\)-\\(?:[0-9]+\\)-\\(?:[0-9]+\\) \\(?:[0-9]+\\):\\(?:[0-9]+\\) \\(?:[-+0-9]+\\)\\) +\\(.*\\)$"
251 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)"))
252 (set (make-local-variable 'log-view-font-lock-keywords)
253 (if vc-short-log
254 (append `((,log-view-message-re
255 (1 'log-view-message-face)
256 (2 'log-view-message-face)
257 (3 'change-log-date)
258 (4 'change-log-name))))
259 (append
260 log-view-font-lock-keywords
262 ;; Handle the case:
263 ;; user: FirstName LastName <foo@bar>
264 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
265 (1 'change-log-name)
266 (2 'change-log-email))
267 ;; Handle the cases:
268 ;; user: foo@bar
269 ;; and
270 ;; user: foo
271 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
272 (1 'change-log-email))
273 ("^date: \\(.+\\)" (1 'change-log-date))
274 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message)))))))
276 (defun vc-hg-diff (files &optional oldvers newvers buffer)
277 "Get a difference report using hg between two revisions of FILES."
278 (let* ((firstfile (car files))
279 (working (and firstfile (vc-working-revision firstfile))))
280 (when (and (equal oldvers working) (not newvers))
281 (setq oldvers nil))
282 (when (and (not oldvers) newvers)
283 (setq oldvers working))
284 (apply #'vc-hg-command (or buffer "*vc-diff*") nil files "diff"
285 (append
286 (vc-switches 'hg 'diff)
287 (when oldvers
288 (if newvers
289 (list "-r" oldvers "-r" newvers)
290 (list "-r" oldvers)))))))
292 (defun vc-hg-revision-table (files)
293 (let ((default-directory (file-name-directory (car files))))
294 (with-temp-buffer
295 (vc-hg-command t nil files "log" "--template" "{rev} ")
296 (split-string
297 (buffer-substring-no-properties (point-min) (point-max))))))
299 ;; Modeled after the similar function in vc-cvs.el
300 (defun vc-hg-revision-completion-table (files)
301 (lexical-let ((files files)
302 table)
303 (setq table (lazy-completion-table
304 table (lambda () (vc-hg-revision-table files))))
305 table))
307 (defun vc-hg-annotate-command (file buffer &optional revision)
308 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
309 Optional arg REVISION is a revision to annotate from."
310 (vc-hg-command buffer 0 file "annotate" "-d" "-n" "--follow"
311 (when revision (concat "-r" revision))))
313 (declare-function vc-annotate-convert-time "vc-annotate" (time))
315 ;; The format for one line output by "hg annotate -d -n" looks like this:
316 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS
317 ;; i.e: VERSION_NUMBER DATE: CONTENTS
318 ;; If the user has set the "--follow" option, the output looks like:
319 ;;215 Wed Jun 20 21:22:58 2007 -0700 foo.c: CONTENTS
320 ;; i.e. VERSION_NUMBER DATE FILENAME: CONTENTS
321 (defconst vc-hg-annotate-re
322 "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\)\\(?:\\(: \\)\\|\\(?: +\\(.+\\): \\)\\)")
324 (defun vc-hg-annotate-time ()
325 (when (looking-at vc-hg-annotate-re)
326 (goto-char (match-end 0))
327 (vc-annotate-convert-time
328 (date-to-time (match-string-no-properties 2)))))
330 (defun vc-hg-annotate-extract-revision-at-line ()
331 (save-excursion
332 (beginning-of-line)
333 (when (looking-at vc-hg-annotate-re)
334 (if (match-beginning 3)
335 (match-string-no-properties 1)
336 (cons (match-string-no-properties 1)
337 (expand-file-name (match-string-no-properties 4)))))))
339 (defun vc-hg-previous-revision (file rev)
340 (let ((newrev (1- (string-to-number rev))))
341 (when (>= newrev 0)
342 (number-to-string newrev))))
344 (defun vc-hg-next-revision (file rev)
345 (let ((newrev (1+ (string-to-number rev)))
346 (tip-revision
347 (with-temp-buffer
348 (vc-hg-command t 0 nil "tip")
349 (goto-char (point-min))
350 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
351 (string-to-number (match-string-no-properties 1)))))
352 ;; We don't want to exceed the maximum possible revision number, ie
353 ;; the tip revision.
354 (when (<= newrev tip-revision)
355 (number-to-string newrev))))
357 ;; Modeled after the similar function in vc-bzr.el
358 (defun vc-hg-delete-file (file)
359 "Delete FILE and delete it in the hg repository."
360 (condition-case ()
361 (delete-file file)
362 (file-error nil))
363 (vc-hg-command nil 0 file "remove" "--after" "--force"))
365 ;; Modeled after the similar function in vc-bzr.el
366 (defun vc-hg-rename-file (old new)
367 "Rename file from OLD to NEW using `hg mv'."
368 (vc-hg-command nil 0 new "mv" old))
370 (defun vc-hg-register (files &optional rev comment)
371 "Register FILES under hg.
372 REV is ignored.
373 COMMENT is ignored."
374 (vc-hg-command nil 0 files "add"))
376 (defun vc-hg-create-repo ()
377 "Create a new Mercurial repository."
378 (vc-hg-command nil 0 nil "init"))
380 (defalias 'vc-hg-responsible-p 'vc-hg-root)
382 ;; Modeled after the similar function in vc-bzr.el
383 (defun vc-hg-could-register (file)
384 "Return non-nil if FILE could be registered under hg."
385 (and (vc-hg-responsible-p file) ; shortcut
386 (condition-case ()
387 (with-temp-buffer
388 (vc-hg-command t nil file "add" "--dry-run"))
389 ;; The command succeeds with no output if file is
390 ;; registered.
391 (error))))
393 ;; FIXME: This would remove the file. Is that correct?
394 ;; (defun vc-hg-unregister (file)
395 ;; "Unregister FILE from hg."
396 ;; (vc-hg-command nil nil file "remove"))
398 (defun vc-hg-checkin (files rev comment)
399 "Hg-specific version of `vc-backend-checkin'.
400 REV is ignored."
401 (vc-hg-command nil 0 files "commit" "-m" comment))
403 (defun vc-hg-find-revision (file rev buffer)
404 (let ((coding-system-for-read 'binary)
405 (coding-system-for-write 'binary))
406 (if rev
407 (vc-hg-command buffer 0 file "cat" "-r" rev)
408 (vc-hg-command buffer 0 file "cat"))))
410 ;; Modeled after the similar function in vc-bzr.el
411 (defun vc-hg-checkout (file &optional editable rev)
412 "Retrieve a revision of FILE.
413 EDITABLE is ignored.
414 REV is the revision to check out into WORKFILE."
415 (let ((coding-system-for-read 'binary)
416 (coding-system-for-write 'binary))
417 (with-current-buffer (or (get-file-buffer file) (current-buffer))
418 (if rev
419 (vc-hg-command t 0 file "cat" "-r" rev)
420 (vc-hg-command t 0 file "cat")))))
422 ;; Modeled after the similar function in vc-bzr.el
423 (defun vc-hg-workfile-unchanged-p (file)
424 (eq 'up-to-date (vc-hg-state file)))
426 ;; Modeled after the similar function in vc-bzr.el
427 (defun vc-hg-revert (file &optional contents-done)
428 (unless contents-done
429 (with-temp-buffer (vc-hg-command t 0 file "revert"))))
431 ;;; Hg specific functionality.
433 (defvar vc-hg-extra-menu-map
434 (let ((map (make-sparse-keymap)))
435 (define-key map [incoming] '(menu-item "Show incoming" vc-hg-incoming))
436 (define-key map [outgoing] '(menu-item "Show outgoing" vc-hg-outgoing))
437 map))
439 (defun vc-hg-extra-menu () vc-hg-extra-menu-map)
441 (defun vc-hg-extra-status-menu () vc-hg-extra-menu-map)
443 (defvar log-view-vc-backend)
445 (define-derived-mode vc-hg-outgoing-mode vc-hg-log-view-mode "Hg-Outgoing"
446 "Mode for browsing Hg outgoing changes."
447 (set (make-local-variable 'log-view-vc-backend) 'Hg))
449 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming"
450 "Mode for browsing Hg incoming changes."
451 (set (make-local-variable 'log-view-vc-backend) 'Hg))
453 (defstruct (vc-hg-extra-fileinfo
454 (:copier nil)
455 (:constructor vc-hg-create-extra-fileinfo (rename-state extra-name))
456 (:conc-name vc-hg-extra-fileinfo->))
457 rename-state ;; rename or copy state
458 extra-name) ;; original name for copies and rename targets, new name for
460 (declare-function vc-default-dir-printer "vc-dir" (backend fileentry))
462 (defun vc-hg-dir-printer (info)
463 "Pretty-printer for the vc-dir-fileinfo structure."
464 (let ((extra (vc-dir-fileinfo->extra info)))
465 (vc-default-dir-printer 'Hg info)
466 (when extra
467 (insert (propertize
468 (format " (%s %s)"
469 (case (vc-hg-extra-fileinfo->rename-state extra)
470 ('copied "copied from")
471 ('renamed-from "renamed from")
472 ('renamed-to "renamed to"))
473 (vc-hg-extra-fileinfo->extra-name extra))
474 'face 'font-lock-comment-face)))))
476 (defun vc-hg-after-dir-status (update-function)
477 (let ((status-char nil)
478 (file nil)
479 (translation '((?= . up-to-date)
480 (?C . up-to-date)
481 (?A . added)
482 (?R . removed)
483 (?M . edited)
484 (?I . ignored)
485 (?! . missing)
486 (? . copy-rename-line)
487 (?? . unregistered)))
488 (translated nil)
489 (result nil)
490 (last-added nil)
491 (last-line-copy nil))
492 (goto-char (point-min))
493 (while (not (eobp))
494 (setq translated (cdr (assoc (char-after) translation)))
495 (setq file
496 (buffer-substring-no-properties (+ (point) 2)
497 (line-end-position)))
498 (cond ((not translated)
499 (setq last-line-copy nil))
500 ((eq translated 'up-to-date)
501 (setq last-line-copy nil))
502 ((eq translated 'copy-rename-line)
503 ;; For copied files the output looks like this:
504 ;; A COPIED_FILE_NAME
505 ;; ORIGINAL_FILE_NAME
506 (setf (nth 2 last-added)
507 (vc-hg-create-extra-fileinfo 'copied file))
508 (setq last-line-copy t))
509 ((and last-line-copy (eq translated 'removed))
510 ;; For renamed files the output looks like this:
511 ;; A NEW_FILE_NAME
512 ;; ORIGINAL_FILE_NAME
513 ;; R ORIGINAL_FILE_NAME
514 ;; We need to adjust the previous entry to not think it is a copy.
515 (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added))
516 'renamed-from)
517 (push (list file translated
518 (vc-hg-create-extra-fileinfo
519 'renamed-to (nth 0 last-added))) result)
520 (setq last-line-copy nil))
522 (setq last-added (list file translated nil))
523 (push last-added result)
524 (setq last-line-copy nil)))
525 (forward-line))
526 (funcall update-function result)))
528 (defun vc-hg-dir-status (dir update-function)
529 (vc-hg-command (current-buffer) 'async dir "status" "-C")
530 (vc-exec-after
531 `(vc-hg-after-dir-status (quote ,update-function))))
533 (defun vc-hg-dir-status-files (dir files default-state update-function)
534 (apply 'vc-hg-command (current-buffer) 'async dir "status" "-C" files)
535 (vc-exec-after
536 `(vc-hg-after-dir-status (quote ,update-function))))
538 (defun vc-hg-dir-extra-header (name &rest commands)
539 (concat (propertize name 'face 'font-lock-type-face)
540 (propertize
541 (with-temp-buffer
542 (apply 'vc-hg-command (current-buffer) 0 nil commands)
543 (buffer-substring-no-properties (point-min) (1- (point-max))))
544 'face 'font-lock-variable-name-face)))
546 (defun vc-hg-dir-extra-headers (dir)
547 "Generate extra status headers for a Mercurial tree."
548 (let ((default-directory dir))
549 (concat
550 (vc-hg-dir-extra-header "Root : " "root") "\n"
551 (vc-hg-dir-extra-header "Branch : " "id" "-b") "\n"
552 (vc-hg-dir-extra-header "Tags : " "id" "-t") ; "\n"
553 ;; these change after each commit
554 ;; (vc-hg-dir-extra-header "Local num : " "id" "-n") "\n"
555 ;; (vc-hg-dir-extra-header "Global id : " "id" "-i")
558 ;; FIXME: this adds another top level menu, instead figure out how to
559 ;; replace the Log-View menu.
560 (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map
561 "Hg-outgoing Display Menu"
562 `("Hg-outgoing"
563 ["Push selected" vc-hg-push]))
565 (easy-menu-define log-view-mode-menu vc-hg-incoming-mode-map
566 "Hg-incoming Display Menu"
567 `("Hg-incoming"
568 ["Pull selected" vc-hg-pull]))
570 (defun vc-hg-outgoing ()
571 (interactive)
572 (let ((bname "*Hg outgoing*")
573 (vc-short-log nil))
574 (vc-hg-command bname 1 nil "outgoing" "-n")
575 (pop-to-buffer bname)
576 (vc-hg-outgoing-mode)))
578 (defun vc-hg-incoming ()
579 (interactive)
580 (let ((bname "*Hg incoming*")
581 (vc-short-log nil))
582 (vc-hg-command bname 0 nil "incoming" "-n")
583 (pop-to-buffer bname)
584 (vc-hg-incoming-mode)))
586 (declare-function log-view-get-marked "log-view" ())
588 ;; XXX maybe also add key bindings for these functions.
589 (defun vc-hg-push ()
590 (interactive)
591 (let ((marked-list (log-view-get-marked)))
592 (if marked-list
593 (vc-hg-command
594 nil 0 nil
595 (cons "push"
596 (apply 'nconc
597 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
598 (error "No log entries selected for push"))))
600 (defun vc-hg-pull ()
601 (interactive)
602 (let ((marked-list (log-view-get-marked)))
603 (if marked-list
604 (vc-hg-command
605 nil 0 nil
606 (cons "pull"
607 (apply 'nconc
608 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
609 (error "No log entries selected for pull"))))
611 ;;; Internal functions
613 (defun vc-hg-command (buffer okstatus file-or-list &rest flags)
614 "A wrapper around `vc-do-command' for use in vc-hg.el.
615 The difference to vc-do-command is that this function always invokes `hg',
616 and that it passes `vc-hg-global-switches' to it before FLAGS."
617 (apply 'vc-do-command (or buffer "*vc*") okstatus "hg" file-or-list
618 (if (stringp vc-hg-global-switches)
619 (cons vc-hg-global-switches flags)
620 (append vc-hg-global-switches
621 flags))))
623 (defun vc-hg-root (file)
624 (vc-find-root file ".hg"))
626 (provide 'vc-hg)
628 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954
629 ;;; vc-hg.el ends here