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