1 ;;; vc-hg.el --- VC backend for the mercurial version control system
3 ;; Copyright (C) 2006-2012 Free Software Foundation, Inc.
9 ;; This file is part of GNU Emacs.
11 ;; GNU Emacs is free software: you can redistribute it and/or modify
12 ;; it under the terms of the GNU General Public License as published by
13 ;; the Free Software Foundation, either version 3 of the License, or
14 ;; (at your option) any later version.
16 ;; GNU Emacs is distributed in the hope that it will be useful,
17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 ;; GNU General Public License for more details.
21 ;; You should have received a copy of the GNU General Public License
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
26 ;; This is a mercurial version control backend
36 ;; 1) Implement the rest of the vc interface. See the comment at the
37 ;; beginning of vc.el. The current status is:
39 ;; FUNCTION NAME STATUS
41 ;; * revision-granularity OK
42 ;; STATE-QUERYING FUNCTIONS
43 ;; * registered (file) OK
45 ;; - state-heuristic (file) NOT NEEDED
46 ;; - dir-status (dir update-function) OK
47 ;; - dir-status-files (dir files ds uf) OK
48 ;; - dir-extra-headers (dir) OK
49 ;; - dir-printer (fileinfo) OK
50 ;; * working-revision (file) OK
51 ;; - latest-on-branch-p (file) ??
52 ;; * checkout-model (files) OK
53 ;; - workfile-unchanged-p (file) OK
54 ;; - mode-line-string (file) NOT NEEDED
55 ;; STATE-CHANGING FUNCTIONS
56 ;; * register (files &optional rev comment) OK
57 ;; * create-repo () OK
58 ;; - init-revision () NOT NEEDED
59 ;; - responsible-p (file) OK
60 ;; - could-register (file) OK
61 ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED
62 ;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT
63 ;; * checkin (files rev comment) OK
64 ;; * find-revision (file rev buffer) OK
65 ;; * checkout (file &optional editable rev) OK
66 ;; * revert (file &optional contents-done) OK
67 ;; - rollback (files) ?? PROBABLY NOT NEEDED
68 ;; - merge (file rev1 rev2) NEEDED
69 ;; - merge-news (file) NEEDED
70 ;; - steal-lock (file &optional revision) NOT NEEDED
72 ;; * print-log (files buffer &optional shortlog start-revision limit) OK
73 ;; - log-view-mode () OK
74 ;; - show-log-entry (revision) NOT NEEDED, DEFAULT IS GOOD
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
84 ;; - create-tag (dir name branchp) NEEDED
85 ;; - retrieve-tag (dir name update) NEEDED
87 ;; - make-version-backups-p (file) ??
88 ;; - repository-hostname (dirname) ??
89 ;; - previous-revision (file rev) OK
90 ;; - next-revision (file rev) OK
91 ;; - check-headers () ??
92 ;; - clear-headers () ??
93 ;; - delete-file (file) TEST IT
94 ;; - rename-file (old new) OK
95 ;; - find-file-hook () PROBABLY NOT NEEDED
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).
117 ;;; Customization options
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" :value
("") string
))
127 (defcustom vc-hg-diff-switches t
; Hg doesn't support common args like -u
128 "String or list of strings specifying switches for Hg diff under VC.
129 If nil, use the value of `vc-diff-switches'. If t, use no switches."
130 :type
'(choice (const :tag
"Unspecified" nil
)
131 (const :tag
"None" t
)
132 (string :tag
"Argument String")
133 (repeat :tag
"Argument List" :value
("") string
))
137 (defcustom vc-hg-program
"hg"
138 "Name of the Mercurial executable (excluding any arguments)."
142 (defcustom vc-hg-root-log-format
143 '("{rev}:{tags}: {author|person} {date|shortdate} {desc|firstline}\\n"
144 "^\\([0-9]+\\):\\([^:]*\\): \\(.*?\\)[ \t]+\\([0-9]\\{4\\}-[0-9]\\{2\\}-[0-9]\\{2\\}\\)"
145 ((1 'log-view-message-face
)
148 (4 'change-log-date
)))
149 "Mercurial log template for `vc-print-root-log'.
150 This should be a list (TEMPLATE REGEXP KEYWORDS), where TEMPLATE
151 is the \"--template\" argument string to pass to Mercurial,
152 REGEXP is a regular expression matching the resulting Mercurial
153 output, and KEYWORDS is a list of `font-lock-keywords' for
154 highlighting the Log View buffer."
155 :type
'(list string string
(repeat sexp
))
160 ;;; Properties of the backend
162 (defvar vc-hg-history nil
)
164 (defun vc-hg-revision-granularity () 'repository
)
165 (defun vc-hg-checkout-model (files) 'implicit
)
167 ;;; State querying functions
169 ;;;###autoload (defun vc-hg-registered (file)
170 ;;;###autoload "Return non-nil if FILE is registered with hg."
171 ;;;###autoload (if (vc-find-root file ".hg") ; short cut
172 ;;;###autoload (progn
173 ;;;###autoload (load "vc-hg")
174 ;;;###autoload (vc-hg-registered file))))
176 ;; Modeled after the similar function in vc-bzr.el
177 (defun vc-hg-registered (file)
178 "Return non-nil if FILE is registered with hg."
179 (when (vc-hg-root file
) ; short cut
180 (let ((state (vc-hg-state file
))) ; expensive
181 (and state
(not (memq state
'(ignored unregistered
)))))))
183 (defun vc-hg-state (file)
184 "Hg-specific version of `vc-state'."
187 (default-directory (file-name-directory file
))
189 (with-output-to-string
194 ;; Ignore all errors.
195 (let ((process-environment
196 ;; Avoid localization of messages so we
197 ;; can parse the output.
198 (append (list "TERM=dumb" "LANGUAGE=C")
199 process-environment
)))
201 vc-hg-program nil t nil
202 "--config" "alias.status=status"
203 "--config" "defaults.status="
204 "status" "-A" (file-relative-name file
)))
205 ;; Some problem happened. E.g. We can't find an `hg'
209 (when (null (string-match ".*: No such file or directory$" out
))
210 (let ((state (aref out
0)))
212 ((eq state ?
=) 'up-to-date
)
213 ((eq state ?A
) 'added
)
214 ((eq state ?M
) 'edited
)
215 ((eq state ?I
) 'ignored
)
216 ((eq state ?R
) 'removed
)
217 ((eq state ?
!) 'missing
)
218 ((eq state ??
) 'unregistered
)
219 ((eq state ?C
) 'up-to-date
) ;; Older mercurial versions use this.
220 (t 'up-to-date
)))))))
222 (defun vc-hg-working-revision (file)
223 "Hg-specific version of `vc-working-revision'."
226 (default-directory (file-name-directory file
))
227 ;; Avoid localization of messages so we can parse the output.
228 (avoid-local-env (append (list "TERM=dumb" "LANGUAGE=C")
229 process-environment
))
231 (with-output-to-string
236 (let ((process-environment avoid-local-env
))
237 ;; Ignore all errors.
239 vc-hg-program nil t nil
240 "--config" "alias.parents=parents"
241 "--config" "defaults.parents="
242 "parents" "--template" "{rev}" (file-relative-name file
)))
243 ;; Some problem happened. E.g. We can't find an `hg'
248 ;; Check if the file is in the 'added state, the above hg
249 ;; command does not distinguish between 'added and 'unregistered.
252 (let ((process-environment avoid-local-env
))
254 vc-hg-program nil nil nil
255 ;; We use "log" here, if there's a faster command
256 ;; that returns true for an 'added file and false
257 ;; for an 'unregistered one, we could use that.
258 "log" "-l1" (file-relative-name file
)))
259 ;; Some problem happened. E.g. We can't find an `hg'
262 (when (eq 0 status
) "0"))))
264 ;;; History functions
266 (defcustom vc-hg-log-switches nil
267 "String or list of strings specifying switches for hg log under VC."
268 :type
'(choice (const :tag
"None" nil
)
269 (string :tag
"Argument String")
270 (repeat :tag
"Argument List" :value
("") string
))
273 (defun vc-hg-print-log (files buffer
&optional shortlog start-revision limit
)
274 "Get change log associated with FILES."
275 ;; `vc-do-command' creates the buffer, but we need it before running
277 (vc-setup-buffer buffer
)
278 ;; If the buffer exists from a previous invocation it might be
280 (let ((inhibit-read-only t
))
283 (apply 'vc-hg-command buffer
0 files
"log"
285 (when start-revision
(list (format "-r%s:" start-revision
)))
286 (when limit
(list "-l" (format "%s" limit
)))
287 (when shortlog
(list "--template" (car vc-hg-root-log-format
)))
288 vc-hg-log-switches
)))))
290 (defvar log-view-message-re
)
291 (defvar log-view-file-re
)
292 (defvar log-view-font-lock-keywords
)
293 (defvar log-view-per-file-logs
)
294 (defvar log-view-expanded-log-entry-function
)
296 (define-derived-mode vc-hg-log-view-mode log-view-mode
"Hg-Log-View"
297 (require 'add-log
) ;; we need the add-log faces
298 (set (make-local-variable 'log-view-file-re
) "\\`a\\`")
299 (set (make-local-variable 'log-view-per-file-logs
) nil
)
300 (set (make-local-variable 'log-view-message-re
)
301 (if (eq vc-log-view-type
'short
)
302 (cadr vc-hg-root-log-format
)
303 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)"))
304 ;; Allow expanding short log entries
305 (when (eq vc-log-view-type
'short
)
306 (setq truncate-lines t
)
307 (set (make-local-variable 'log-view-expanded-log-entry-function
)
308 'vc-hg-expanded-log-entry
))
309 (set (make-local-variable 'log-view-font-lock-keywords
)
310 (if (eq vc-log-view-type
'short
)
311 (list (cons (nth 1 vc-hg-root-log-format
)
312 (nth 2 vc-hg-root-log-format
)))
314 log-view-font-lock-keywords
317 ;; user: FirstName LastName <foo@bar>
318 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
320 (2 'change-log-email
))
325 ("^user:[ \t]+\\([A-Za-z0-9_.+-]+\\(?:@[A-Za-z0-9_.-]+\\)?\\)"
326 (1 'change-log-email
))
327 ("^date: \\(.+\\)" (1 'change-log-date
))
328 ("^tag: +\\([^ ]+\\)$" (1 'highlight
))
329 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message
)))))))
331 (defun vc-hg-diff (files &optional oldvers newvers buffer
)
332 "Get a difference report using hg between two revisions of FILES."
333 (let* ((firstfile (car files
))
334 (working (and firstfile
(vc-working-revision firstfile
))))
335 (when (and (equal oldvers working
) (not newvers
))
337 (when (and (not oldvers
) newvers
)
338 (setq oldvers working
))
339 (apply #'vc-hg-command
(or buffer
"*vc-diff*") nil files
"diff"
341 (vc-switches 'hg
'diff
)
344 (list "-r" oldvers
"-r" newvers
)
345 (list "-r" oldvers
)))))))
347 (defun vc-hg-expanded-log-entry (revision)
349 (vc-hg-command t nil nil
"log" "-r" revision
)
350 (goto-char (point-min))
352 ;; Indent the expanded log entry.
353 (indent-region (point-min) (point-max) 2)
354 (goto-char (point-max))
357 (defun vc-hg-revision-table (files)
358 (let ((default-directory (file-name-directory (car files
))))
360 (vc-hg-command t nil files
"log" "--template" "{rev} ")
362 (buffer-substring-no-properties (point-min) (point-max))))))
364 ;; Modeled after the similar function in vc-cvs.el
365 (defun vc-hg-revision-completion-table (files)
366 (lexical-let ((files files
)
368 (setq table
(lazy-completion-table
369 table
(lambda () (vc-hg-revision-table files
))))
372 (defun vc-hg-annotate-command (file buffer
&optional revision
)
373 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
374 Optional arg REVISION is a revision to annotate from."
375 (vc-hg-command buffer
0 file
"annotate" "-d" "-n" "--follow"
376 (when revision
(concat "-r" revision
))))
378 (declare-function vc-annotate-convert-time
"vc-annotate" (time))
380 ;; The format for one line output by "hg annotate -d -n" looks like this:
381 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS
382 ;; i.e: VERSION_NUMBER DATE: CONTENTS
383 ;; If the user has set the "--follow" option, the output looks like:
384 ;;215 Wed Jun 20 21:22:58 2007 -0700 foo.c: CONTENTS
385 ;; i.e. VERSION_NUMBER DATE FILENAME: CONTENTS
386 (defconst vc-hg-annotate-re
387 "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\)\\(?:\\(: \\)\\|\\(?: +\\(.+\\): \\)\\)")
389 (defun vc-hg-annotate-time ()
390 (when (looking-at vc-hg-annotate-re
)
391 (goto-char (match-end 0))
392 (vc-annotate-convert-time
393 (date-to-time (match-string-no-properties 2)))))
395 (defun vc-hg-annotate-extract-revision-at-line ()
398 (when (looking-at vc-hg-annotate-re
)
399 (if (match-beginning 3)
400 (match-string-no-properties 1)
401 (cons (match-string-no-properties 1)
402 (expand-file-name (match-string-no-properties 4)
403 (vc-hg-root default-directory
)))))))
405 (defun vc-hg-previous-revision (file rev
)
406 (let ((newrev (1- (string-to-number rev
))))
408 (number-to-string newrev
))))
410 (defun vc-hg-next-revision (file rev
)
411 (let ((newrev (1+ (string-to-number rev
)))
414 (vc-hg-command t
0 nil
"tip")
415 (goto-char (point-min))
416 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
417 (string-to-number (match-string-no-properties 1)))))
418 ;; We don't want to exceed the maximum possible revision number, ie
420 (when (<= newrev tip-revision
)
421 (number-to-string newrev
))))
423 ;; Modeled after the similar function in vc-bzr.el
424 (defun vc-hg-delete-file (file)
425 "Delete FILE and delete it in the hg repository."
429 (vc-hg-command nil
0 file
"remove" "--after" "--force"))
431 ;; Modeled after the similar function in vc-bzr.el
432 (defun vc-hg-rename-file (old new
)
433 "Rename file from OLD to NEW using `hg mv'."
434 (vc-hg-command nil
0 new
"mv" old
))
436 (defun vc-hg-register (files &optional rev comment
)
437 "Register FILES under hg.
440 (vc-hg-command nil
0 files
"add"))
442 (defun vc-hg-create-repo ()
443 "Create a new Mercurial repository."
444 (vc-hg-command nil
0 nil
"init"))
446 (defalias 'vc-hg-responsible-p
'vc-hg-root
)
448 ;; Modeled after the similar function in vc-bzr.el
449 (defun vc-hg-could-register (file)
450 "Return non-nil if FILE could be registered under hg."
451 (and (vc-hg-responsible-p file
) ; shortcut
454 (vc-hg-command t nil file
"add" "--dry-run"))
455 ;; The command succeeds with no output if file is
459 ;; FIXME: This would remove the file. Is that correct?
460 ;; (defun vc-hg-unregister (file)
461 ;; "Unregister FILE from hg."
462 ;; (vc-hg-command nil nil file "remove"))
464 (declare-function log-edit-extract-headers
"log-edit" (headers string
))
466 (defun vc-hg-checkin (files rev comment
)
467 "Hg-specific version of `vc-backend-checkin'.
469 (apply 'vc-hg-command nil
0 files
470 (nconc (list "commit" "-m")
471 (log-edit-extract-headers '(("Author" .
"--user")
475 (defun vc-hg-find-revision (file rev buffer
)
476 (let ((coding-system-for-read 'binary
)
477 (coding-system-for-write 'binary
))
479 (vc-hg-command buffer
0 file
"cat" "-r" rev
)
480 (vc-hg-command buffer
0 file
"cat"))))
482 ;; Modeled after the similar function in vc-bzr.el
483 (defun vc-hg-checkout (file &optional editable rev
)
484 "Retrieve a revision of FILE.
486 REV is the revision to check out into WORKFILE."
487 (let ((coding-system-for-read 'binary
)
488 (coding-system-for-write 'binary
))
489 (with-current-buffer (or (get-file-buffer file
) (current-buffer))
491 (vc-hg-command t
0 file
"cat" "-r" rev
)
492 (vc-hg-command t
0 file
"cat")))))
494 ;; Modeled after the similar function in vc-bzr.el
495 (defun vc-hg-workfile-unchanged-p (file)
496 (eq 'up-to-date
(vc-hg-state file
)))
498 ;; Modeled after the similar function in vc-bzr.el
499 (defun vc-hg-revert (file &optional contents-done
)
500 (unless contents-done
501 (with-temp-buffer (vc-hg-command t
0 file
"revert"))))
503 ;;; Hg specific functionality.
505 (defvar vc-hg-extra-menu-map
506 (let ((map (make-sparse-keymap)))
509 (defun vc-hg-extra-menu () vc-hg-extra-menu-map
)
511 (defun vc-hg-extra-status-menu () vc-hg-extra-menu-map
)
513 (defvar log-view-vc-backend
)
515 (defstruct (vc-hg-extra-fileinfo
517 (:constructor vc-hg-create-extra-fileinfo
(rename-state extra-name
))
518 (:conc-name vc-hg-extra-fileinfo-
>))
519 rename-state
;; rename or copy state
520 extra-name
) ;; original name for copies and rename targets, new name for
522 (declare-function vc-default-dir-printer
"vc-dir" (backend fileentry
))
524 (defun vc-hg-dir-printer (info)
525 "Pretty-printer for the vc-dir-fileinfo structure."
526 (let ((extra (vc-dir-fileinfo->extra info
)))
527 (vc-default-dir-printer 'Hg info
)
531 (case (vc-hg-extra-fileinfo->rename-state extra
)
532 (copied "copied from")
533 (renamed-from "renamed from")
534 (renamed-to "renamed to"))
535 (vc-hg-extra-fileinfo->extra-name extra
))
536 'face
'font-lock-comment-face
)))))
538 (defun vc-hg-after-dir-status (update-function)
539 (let ((status-char nil
)
541 (translation '((?
= . up-to-date
)
548 (? . copy-rename-line
)
549 (?? . unregistered
)))
553 (last-line-copy nil
))
554 (goto-char (point-min))
556 (setq translated
(cdr (assoc (char-after) translation
)))
558 (buffer-substring-no-properties (+ (point) 2)
559 (line-end-position)))
560 (cond ((not translated
)
561 (setq last-line-copy nil
))
562 ((eq translated
'up-to-date
)
563 (setq last-line-copy nil
))
564 ((eq translated
'copy-rename-line
)
565 ;; For copied files the output looks like this:
566 ;; A COPIED_FILE_NAME
567 ;; ORIGINAL_FILE_NAME
568 (setf (nth 2 last-added
)
569 (vc-hg-create-extra-fileinfo 'copied file
))
570 (setq last-line-copy t
))
571 ((and last-line-copy
(eq translated
'removed
))
572 ;; For renamed files the output looks like this:
574 ;; ORIGINAL_FILE_NAME
575 ;; R ORIGINAL_FILE_NAME
576 ;; We need to adjust the previous entry to not think it is a copy.
577 (setf (vc-hg-extra-fileinfo->rename-state
(nth 2 last-added
))
579 (push (list file translated
580 (vc-hg-create-extra-fileinfo
581 'renamed-to
(nth 0 last-added
))) result
)
582 (setq last-line-copy nil
))
584 (setq last-added
(list file translated nil
))
585 (push last-added result
)
586 (setq last-line-copy nil
)))
588 (funcall update-function result
)))
590 (defun vc-hg-dir-status (dir update-function
)
591 (vc-hg-command (current-buffer) 'async dir
"status" "-C")
593 `(vc-hg-after-dir-status (quote ,update-function
))))
595 (defun vc-hg-dir-status-files (dir files default-state update-function
)
596 (apply 'vc-hg-command
(current-buffer) 'async dir
"status" "-C" files
)
598 `(vc-hg-after-dir-status (quote ,update-function
))))
600 (defun vc-hg-dir-extra-header (name &rest commands
)
601 (concat (propertize name
'face
'font-lock-type-face
)
604 (apply 'vc-hg-command
(current-buffer) 0 nil commands
)
605 (buffer-substring-no-properties (point-min) (1- (point-max))))
606 'face
'font-lock-variable-name-face
)))
608 (defun vc-hg-dir-extra-headers (dir)
609 "Generate extra status headers for a Mercurial tree."
610 (let ((default-directory dir
))
612 (vc-hg-dir-extra-header "Root : " "root") "\n"
613 (vc-hg-dir-extra-header "Branch : " "id" "-b") "\n"
614 (vc-hg-dir-extra-header "Tags : " "id" "-t") ; "\n"
615 ;; these change after each commit
616 ;; (vc-hg-dir-extra-header "Local num : " "id" "-n") "\n"
617 ;; (vc-hg-dir-extra-header "Global id : " "id" "-i")
620 (defun vc-hg-log-incoming (buffer remote-location
)
621 (vc-hg-command buffer
1 nil
"incoming" "-n" (unless (string= remote-location
"")
624 (defun vc-hg-log-outgoing (buffer remote-location
)
625 (vc-hg-command buffer
1 nil
"outgoing" "-n" (unless (string= remote-location
"")
628 (declare-function log-view-get-marked
"log-view" ())
630 ;; XXX maybe also add key bindings for these functions.
633 (let ((marked-list (log-view-get-marked)))
635 (apply #'vc-hg-command
639 (mapcar (lambda (arg) (list "-r" arg
)) marked-list
)))
640 (error "No log entries selected for push"))))
642 (defun vc-hg-pull (prompt)
643 "Issue a Mercurial pull command.
644 If called interactively with a set of marked Log View buffers,
645 call \"hg pull -r REVS\" to pull in the specified revisions REVS.
647 With a prefix argument or if PROMPT is non-nil, prompt for a
648 specific Mercurial pull command. The default is \"hg pull -u\",
649 which fetches changesets from the default remote repository and
650 then attempts to update the working directory."
653 ;; The `vc-hg-pull' command existed before the `pull' VC action
654 ;; was implemented. Keep it for backward compatibility.
655 (if (and (called-interactively-p 'interactive
)
656 (setq marked-list
(log-view-get-marked)))
657 (apply #'vc-hg-command
661 (mapcar (lambda (arg) (list "-r" arg
))
663 (let* ((root (vc-hg-root default-directory
))
664 (buffer (format "*vc-hg : %s*" (expand-file-name root
)))
666 (hg-program vc-hg-program
)
667 ;; Fixme: before updating the working copy to the latest
668 ;; state, should check if it's visiting an old revision.
670 ;; If necessary, prompt for the exact command.
672 (setq args
(split-string
673 (read-shell-command "Run Hg (like this): "
674 (format "%s pull -u" hg-program
)
677 (setq hg-program
(car args
)
680 (apply 'vc-do-async-command buffer root hg-program
682 (vc-set-async-update buffer
)))))
684 (defun vc-hg-merge-branch ()
685 "Merge incoming changes into the current working directory.
686 This runs the command \"hg merge\"."
687 (let* ((root (vc-hg-root default-directory
))
688 (buffer (format "*vc-hg : %s*" (expand-file-name root
))))
689 (apply 'vc-do-async-command buffer root vc-hg-program
'("merge"))
690 (vc-set-async-update buffer
)))
692 ;;; Internal functions
694 (defun vc-hg-command (buffer okstatus file-or-list
&rest flags
)
695 "A wrapper around `vc-do-command' for use in vc-hg.el.
696 This function differs from vc-do-command in that it invokes
697 `vc-hg-program', and passes `vc-hg-global-switches' to it before FLAGS."
698 (apply 'vc-do-command
(or buffer
"*vc*") okstatus vc-hg-program file-or-list
699 (if (stringp vc-hg-global-switches
)
700 (cons vc-hg-global-switches flags
)
701 (append vc-hg-global-switches
704 (defun vc-hg-root (file)
705 (vc-find-root file
".hg"))
709 ;;; vc-hg.el ends here