]> code.delx.au - gnu-emacs/blob - lisp/vc-hg.el
* files.el (hack-one-local-variable): If the mode function is for
[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, 2009 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 of the License, or
13 ;; (at your option) 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. If not, see <http://www.gnu.org/licenses/>.
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
35 ;; 1) Implement the rest of the vc interface. See the comment at the
36 ;; beginning of vc.el. The current status is:
37
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 &optional buffer) 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
95
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).
105
106 ;;; History:
107 ;;
108
109 ;;; Code:
110
111 (eval-when-compile
112 (require 'cl)
113 (require 'vc)
114 (require 'vc-dir))
115
116 ;;; Customization options
117
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)
125
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)
135
136 \f
137 ;;; Properties of the backend
138
139 (defun vc-hg-revision-granularity () 'repository)
140 (defun vc-hg-checkout-model (files) 'implicit)
141
142 ;;; State querying functions
143
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))))
150
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)))))))
157
158 (defun vc-hg-state (file)
159 "Hg-specific version of `vc-state'."
160 (let*
161 ((status nil)
162 (out
163 (with-output-to-string
164 (with-current-buffer
165 standard-output
166 (setq status
167 (condition-case nil
168 ;; Ignore all errors.
169 (call-process
170 "hg" nil t nil "--cwd" (file-name-directory file)
171 "status" "-A" (file-name-nondirectory file))
172 ;; Some problem happened. E.g. We can't find an `hg'
173 ;; executable.
174 (error nil)))))))
175 (when (eq 0 status)
176 (when (null (string-match ".*: No such file or directory$" out))
177 (let ((state (aref out 0)))
178 (cond
179 ((eq state ?=) 'up-to-date)
180 ((eq state ?A) 'added)
181 ((eq state ?M) 'edited)
182 ((eq state ?I) 'ignored)
183 ((eq state ?R) 'removed)
184 ((eq state ?!) 'missing)
185 ((eq state ??) 'unregistered)
186 ((eq state ?C) 'up-to-date) ;; Older mercurials use this
187 (t 'up-to-date)))))))
188
189 (defun vc-hg-working-revision (file)
190 "Hg-specific version of `vc-working-revision'."
191 (let*
192 ((status nil)
193 (out
194 (with-output-to-string
195 (with-current-buffer
196 standard-output
197 (setq status
198 (condition-case nil
199 ;; Ignore all errors.
200 (call-process
201 "hg" nil t nil "--cwd" (file-name-directory file)
202 "log" "-l1" (file-name-nondirectory file))
203 ;; Some problem happened. E.g. We can't find an `hg'
204 ;; executable.
205 (error nil)))))))
206 (when (eq 0 status)
207 (if (string-match "changeset: *\\([0-9]*\\)" out)
208 (match-string 1 out)
209 "0"))))
210
211 ;;; History functions
212
213 (defcustom vc-hg-log-switches nil
214 "String or list of strings specifying switches for hg log under VC."
215 :type '(choice (const :tag "None" nil)
216 (string :tag "Argument String")
217 (repeat :tag "Argument List" :value ("") string))
218 :group 'vc-hg)
219
220 (defun vc-hg-print-log (files &optional buffer)
221 "Get change log associated with FILES."
222 ;; `log-view-mode' needs to have the file names in order to function
223 ;; correctly. "hg log" does not print it, so we insert it here by
224 ;; hand.
225
226 ;; `vc-do-command' creates the buffer, but we need it before running
227 ;; the command.
228 (vc-setup-buffer buffer)
229 ;; If the buffer exists from a previous invocation it might be
230 ;; read-only.
231 (let ((inhibit-read-only t))
232 (with-current-buffer
233 buffer
234 (apply 'vc-hg-command buffer 0 files "log" vc-hg-log-switches))))
235
236 (defvar log-view-message-re)
237 (defvar log-view-file-re)
238 (defvar log-view-font-lock-keywords)
239 (defvar log-view-per-file-logs)
240
241 (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View"
242 (require 'add-log) ;; we need the add-log faces
243 (set (make-local-variable 'log-view-file-re) "\\`a\\`")
244 (set (make-local-variable 'log-view-per-file-logs) nil)
245 (set (make-local-variable 'log-view-message-re)
246 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)")
247 (set (make-local-variable 'log-view-font-lock-keywords)
248 (append
249 log-view-font-lock-keywords
250 '(
251 ;; Handle the case:
252 ;; user: FirstName LastName <foo@bar>
253 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
254 (1 'change-log-name)
255 (2 'change-log-email))
256 ;; Handle the cases:
257 ;; user: foo@bar
258 ;; and
259 ;; user: foo
260 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
261 (1 'change-log-email))
262 ("^date: \\(.+\\)" (1 'change-log-date))
263 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
264
265 (defun vc-hg-diff (files &optional oldvers newvers buffer)
266 "Get a difference report using hg between two revisions of FILES."
267 (let* ((firstfile (car files))
268 (cwd (if firstfile (file-name-directory firstfile)
269 (expand-file-name default-directory)))
270 (working (and firstfile (vc-working-revision firstfile))))
271 (when (and (equal oldvers working) (not newvers))
272 (setq oldvers nil))
273 (when (and (not oldvers) newvers)
274 (setq oldvers working))
275 (apply #'vc-hg-command (or buffer "*vc-diff*") nil
276 (mapcar (lambda (file) (file-relative-name file cwd)) files)
277 "--cwd" cwd
278 "diff"
279 (append
280 (vc-switches 'hg 'diff)
281 (when oldvers
282 (if newvers
283 (list "-r" oldvers "-r" newvers)
284 (list "-r" oldvers)))))))
285
286 (defun vc-hg-revision-table (files)
287 (let ((default-directory (file-name-directory (car files))))
288 (with-temp-buffer
289 (vc-hg-command t nil files "log" "--template" "{rev} ")
290 (split-string
291 (buffer-substring-no-properties (point-min) (point-max))))))
292
293 ;; Modeled after the similar function in vc-cvs.el
294 (defun vc-hg-revision-completion-table (files)
295 (lexical-let ((files files)
296 table)
297 (setq table (lazy-completion-table
298 table (lambda () (vc-hg-revision-table files))))
299 table))
300
301 (defun vc-hg-annotate-command (file buffer &optional revision)
302 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
303 Optional arg REVISION is a revision to annotate from."
304 (vc-hg-command buffer 0 file "annotate" "-d" "-n"
305 (when revision (concat "-r" revision)))
306 (with-current-buffer buffer
307 (goto-char (point-min))
308 (re-search-forward "^[ \t]*[0-9]")
309 (delete-region (point-min) (match-beginning 0))))
310
311 (declare-function vc-annotate-convert-time "vc-annotate" (time))
312
313 ;; The format for one line output by "hg annotate -d -n" looks like this:
314 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS
315 ;; i.e: VERSION_NUMBER DATE: CONTENTS
316 ;; If the user has set the "--follow" option, the output looks like:
317 ;;215 Wed Jun 20 21:22:58 2007 -0700 foo.c: CONTENTS
318 ;; i.e. VERSION_NUMBER DATE FILENAME: CONTENTS
319 (defconst vc-hg-annotate-re
320 "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\)[^:\n]*\\(:[^ \n][^:\n]*\\)*: ")
321
322 (defun vc-hg-annotate-time ()
323 (when (looking-at vc-hg-annotate-re)
324 (goto-char (match-end 0))
325 (vc-annotate-convert-time
326 (date-to-time (match-string-no-properties 2)))))
327
328 (defun vc-hg-annotate-extract-revision-at-line ()
329 (save-excursion
330 (beginning-of-line)
331 (when (looking-at vc-hg-annotate-re) (match-string-no-properties 1))))
332
333 (defun vc-hg-previous-revision (file rev)
334 (let ((newrev (1- (string-to-number rev))))
335 (when (>= newrev 0)
336 (number-to-string newrev))))
337
338 (defun vc-hg-next-revision (file rev)
339 (let ((newrev (1+ (string-to-number rev)))
340 (tip-revision
341 (with-temp-buffer
342 (vc-hg-command t 0 nil "tip")
343 (goto-char (point-min))
344 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
345 (string-to-number (match-string-no-properties 1)))))
346 ;; We don't want to exceed the maximum possible revision number, ie
347 ;; the tip revision.
348 (when (<= newrev tip-revision)
349 (number-to-string newrev))))
350
351 ;; Modeled after the similar function in vc-bzr.el
352 (defun vc-hg-delete-file (file)
353 "Delete FILE and delete it in the hg repository."
354 (condition-case ()
355 (delete-file file)
356 (file-error nil))
357 (vc-hg-command nil 0 file "remove" "--after" "--force"))
358
359 ;; Modeled after the similar function in vc-bzr.el
360 (defun vc-hg-rename-file (old new)
361 "Rename file from OLD to NEW using `hg mv'."
362 (vc-hg-command nil 0 new "mv" old))
363
364 (defun vc-hg-register (files &optional rev comment)
365 "Register FILES under hg.
366 REV is ignored.
367 COMMENT is ignored."
368 (vc-hg-command nil 0 files "add"))
369
370 (defun vc-hg-create-repo ()
371 "Create a new Mercurial repository."
372 (vc-hg-command nil 0 nil "init"))
373
374 (defalias 'vc-hg-responsible-p 'vc-hg-root)
375
376 ;; Modeled after the similar function in vc-bzr.el
377 (defun vc-hg-could-register (file)
378 "Return non-nil if FILE could be registered under hg."
379 (and (vc-hg-responsible-p file) ; shortcut
380 (condition-case ()
381 (with-temp-buffer
382 (vc-hg-command t nil file "add" "--dry-run"))
383 ;; The command succeeds with no output if file is
384 ;; registered.
385 (error))))
386
387 ;; FIXME: This would remove the file. Is that correct?
388 ;; (defun vc-hg-unregister (file)
389 ;; "Unregister FILE from hg."
390 ;; (vc-hg-command nil nil file "remove"))
391
392 (defun vc-hg-checkin (files rev comment)
393 "Hg-specific version of `vc-backend-checkin'.
394 REV is ignored."
395 (vc-hg-command nil 0 files "commit" "-m" comment))
396
397 (defun vc-hg-find-revision (file rev buffer)
398 (let ((coding-system-for-read 'binary)
399 (coding-system-for-write 'binary))
400 (if rev
401 (vc-hg-command buffer 0 file "cat" "-r" rev)
402 (vc-hg-command buffer 0 file "cat"))))
403
404 ;; Modeled after the similar function in vc-bzr.el
405 (defun vc-hg-checkout (file &optional editable rev)
406 "Retrieve a revision of FILE.
407 EDITABLE is ignored.
408 REV is the revision to check out into WORKFILE."
409 (let ((coding-system-for-read 'binary)
410 (coding-system-for-write 'binary))
411 (with-current-buffer (or (get-file-buffer file) (current-buffer))
412 (if rev
413 (vc-hg-command t 0 file "cat" "-r" rev)
414 (vc-hg-command t 0 file "cat")))))
415
416 ;; Modeled after the similar function in vc-bzr.el
417 (defun vc-hg-workfile-unchanged-p (file)
418 (eq 'up-to-date (vc-hg-state file)))
419
420 ;; Modeled after the similar function in vc-bzr.el
421 (defun vc-hg-revert (file &optional contents-done)
422 (unless contents-done
423 (with-temp-buffer (vc-hg-command t 0 file "revert"))))
424
425 ;;; Hg specific functionality.
426
427 (defvar vc-hg-extra-menu-map
428 (let ((map (make-sparse-keymap)))
429 (define-key map [incoming] '(menu-item "Show incoming" vc-hg-incoming))
430 (define-key map [outgoing] '(menu-item "Show outgoing" vc-hg-outgoing))
431 map))
432
433 (defun vc-hg-extra-menu () vc-hg-extra-menu-map)
434
435 (defun vc-hg-extra-status-menu () vc-hg-extra-menu-map)
436
437 (define-derived-mode vc-hg-outgoing-mode vc-hg-log-view-mode "Hg-Outgoing")
438
439 (define-derived-mode vc-hg-incoming-mode vc-hg-log-view-mode "Hg-Incoming")
440
441 (defstruct (vc-hg-extra-fileinfo
442 (:copier nil)
443 (:constructor vc-hg-create-extra-fileinfo (rename-state extra-name))
444 (:conc-name vc-hg-extra-fileinfo->))
445 rename-state ;; rename or copy state
446 extra-name) ;; original name for copies and rename targets, new name for
447
448 (declare-function vc-default-dir-printer "vc-dir" (backend fileentry))
449
450 (defun vc-hg-dir-printer (info)
451 "Pretty-printer for the vc-dir-fileinfo structure."
452 (let ((extra (vc-dir-fileinfo->extra info)))
453 (vc-default-dir-printer 'Hg info)
454 (when extra
455 (insert (propertize
456 (format " (%s %s)"
457 (case (vc-hg-extra-fileinfo->rename-state extra)
458 ('copied "copied from")
459 ('renamed-from "renamed from")
460 ('renamed-to "renamed to"))
461 (vc-hg-extra-fileinfo->extra-name extra))
462 'face 'font-lock-comment-face)))))
463
464 (defun vc-hg-after-dir-status (update-function)
465 (let ((status-char nil)
466 (file nil)
467 (translation '((?= . up-to-date)
468 (?C . up-to-date)
469 (?A . added)
470 (?R . removed)
471 (?M . edited)
472 (?I . ignored)
473 (?! . missing)
474 (? . copy-rename-line)
475 (?? . unregistered)))
476 (translated nil)
477 (result nil)
478 (last-added nil)
479 (last-line-copy nil))
480 (goto-char (point-min))
481 (while (not (eobp))
482 (setq translated (cdr (assoc (char-after) translation)))
483 (setq file
484 (buffer-substring-no-properties (+ (point) 2)
485 (line-end-position)))
486 (cond ((not translated)
487 (setq last-line-copy nil))
488 ((eq translated 'up-to-date)
489 (setq last-line-copy nil))
490 ((eq translated 'copy-rename-line)
491 ;; For copied files the output looks like this:
492 ;; A COPIED_FILE_NAME
493 ;; ORIGINAL_FILE_NAME
494 (setf (nth 2 last-added)
495 (vc-hg-create-extra-fileinfo 'copied file))
496 (setq last-line-copy t))
497 ((and last-line-copy (eq translated 'removed))
498 ;; For renamed files the output looks like this:
499 ;; A NEW_FILE_NAME
500 ;; ORIGINAL_FILE_NAME
501 ;; R ORIGINAL_FILE_NAME
502 ;; We need to adjust the previous entry to not think it is a copy.
503 (setf (vc-hg-extra-fileinfo->rename-state (nth 2 last-added))
504 'renamed-from)
505 (push (list file translated
506 (vc-hg-create-extra-fileinfo
507 'renamed-to (nth 0 last-added))) result)
508 (setq last-line-copy nil))
509 (t
510 (setq last-added (list file translated nil))
511 (push last-added result)
512 (setq last-line-copy nil)))
513 (forward-line))
514 (funcall update-function result)))
515
516 (defun vc-hg-dir-status (dir update-function)
517 (vc-hg-command (current-buffer) 'async dir "status" "-C")
518 (vc-exec-after
519 `(vc-hg-after-dir-status (quote ,update-function))))
520
521 (defun vc-hg-dir-status-files (dir files default-state update-function)
522 (apply 'vc-hg-command (current-buffer) 'async dir "status" "-C" files)
523 (vc-exec-after
524 `(vc-hg-after-dir-status (quote ,update-function))))
525
526 (defun vc-hg-dir-extra-header (name &rest commands)
527 (concat (propertize name 'face 'font-lock-type-face)
528 (propertize
529 (with-temp-buffer
530 (apply 'vc-hg-command (current-buffer) 0 nil commands)
531 (buffer-substring-no-properties (point-min) (1- (point-max))))
532 'face 'font-lock-variable-name-face)))
533
534 (defun vc-hg-dir-extra-headers (dir)
535 "Generate extra status headers for a Mercurial tree."
536 (let ((default-directory dir))
537 (concat
538 (vc-hg-dir-extra-header "Root : " "root") "\n"
539 (vc-hg-dir-extra-header "Branch : " "id" "-b") "\n"
540 (vc-hg-dir-extra-header "Tags : " "id" "-t") ; "\n"
541 ;; these change after each commit
542 ;; (vc-hg-dir-extra-header "Local num : " "id" "-n") "\n"
543 ;; (vc-hg-dir-extra-header "Global id : " "id" "-i")
544 )))
545
546 ;; FIXME: this adds another top level menu, instead figure out how to
547 ;; replace the Log-View menu.
548 (easy-menu-define log-view-mode-menu vc-hg-outgoing-mode-map
549 "Hg-outgoing Display Menu"
550 `("Hg-outgoing"
551 ["Push selected" vc-hg-push]))
552
553 (easy-menu-define log-view-mode-menu vc-hg-incoming-mode-map
554 "Hg-incoming Display Menu"
555 `("Hg-incoming"
556 ["Pull selected" vc-hg-pull]))
557
558 (defun vc-hg-outgoing ()
559 (interactive)
560 (let ((bname "*Hg outgoing*"))
561 (vc-hg-command bname 0 nil "outgoing" "-n")
562 (pop-to-buffer bname)
563 (vc-hg-outgoing-mode)))
564
565 (defun vc-hg-incoming ()
566 (interactive)
567 (let ((bname "*Hg incoming*"))
568 (vc-hg-command bname 0 nil "incoming" "-n")
569 (pop-to-buffer bname)
570 (vc-hg-incoming-mode)))
571
572 (declare-function log-view-get-marked "log-view" ())
573
574 ;; XXX maybe also add key bindings for these functions.
575 (defun vc-hg-push ()
576 (interactive)
577 (let ((marked-list (log-view-get-marked)))
578 (if marked-list
579 (vc-hg-command
580 nil 0 nil
581 (cons "push"
582 (apply 'nconc
583 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
584 (error "No log entries selected for push"))))
585
586 (defun vc-hg-pull ()
587 (interactive)
588 (let ((marked-list (log-view-get-marked)))
589 (if marked-list
590 (vc-hg-command
591 nil 0 nil
592 (cons "pull"
593 (apply 'nconc
594 (mapcar (lambda (arg) (list "-r" arg)) marked-list))))
595 (error "No log entries selected for pull"))))
596
597 ;;; Internal functions
598
599 (defun vc-hg-command (buffer okstatus file-or-list &rest flags)
600 "A wrapper around `vc-do-command' for use in vc-hg.el.
601 The difference to vc-do-command is that this function always invokes `hg',
602 and that it passes `vc-hg-global-switches' to it before FLAGS."
603 (apply 'vc-do-command (or buffer "*vc*") okstatus "hg" file-or-list
604 (if (stringp vc-hg-global-switches)
605 (cons vc-hg-global-switches flags)
606 (append vc-hg-global-switches
607 flags))))
608
609 (defun vc-hg-root (file)
610 (vc-find-root file ".hg"))
611
612 (provide 'vc-hg)
613
614 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954
615 ;;; vc-hg.el ends here