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