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