Created
June 14, 2013 20:02
-
-
Save sbocq/5784828 to your computer and use it in GitHub Desktop.
Enable ediff support in the *hg-log-view* of emacs.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;; Assuming you have already installed the 'mercurial' package in | |
;; emacs, follow the steps below to enable 'ediff' support in | |
;; the *hg-log-view*: | |
;; | |
;; 1) Add the following lines to your '.hgrc' such that the *hg-log-view* | |
;; of emacs shows the files that have changed in the detailed information | |
;; of a changeset: | |
;; | |
;; [ui] | |
;; verbose = True | |
;; | |
;; This step above is necessary until it the 'hg' command can be customized with | |
;; the '-v' option in emacs. Right now this seems broken. Let me know if you | |
;; find a better way. | |
;; | |
;; 2) Copy the elisp functions below to your emacs init file (e.g. '.emacs'). | |
;; | |
;; Then, to launch 'ediff' on a versioned file: | |
;; | |
;; 1) Do 'M-x vc-dir' and type the path to your hg repo. | |
;; 2) In the *vc-dir* buffer, type 'l' to list | |
;; the revisions of that directory in the *hg-log-view*. | |
;; 3) In the *hg-log-view*, move the point to a changeset and | |
;; press 'enter' to display the files that have been modified | |
; by that changeset. | |
;; 4) Move the point to on one of the files in that changeset and | |
;; press 'e' to browse the changes using 'ediff'. | |
(add-hook 'log-view-mode-hook | |
(lambda () | |
(local-set-key (kbd "e") 'log-view-ediff))) | |
(defun vc-hg-parent-revision (file rev) | |
(with-temp-buffer | |
(vc-hg-command t 0 nil "parent" "-r" rev file) | |
(goto-char (point-min)) | |
(re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") | |
(match-string-no-properties 1))) | |
(defun log-view-ediff (&optional startup-hooks) | |
(interactive) | |
(let* ((file (thing-at-point 'filename)) | |
(to-rev (log-view-current-tag)) | |
(from-rev (vc-hg-parent-revision file to-rev))) | |
(save-excursion | |
(set-buffer (find-file-noselect file)) | |
(require 'ediff-vers) | |
(let ((control-buffer (ediff-vc-internal from-rev to-rev startup-hooks))) | |
(set-buffer control-buffer) | |
(ediff-next-difference)) | |
(mapc (lambda (f) (funcall f)) startup-hooks)))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment