@item C-x v O
Display the changes that will be sent by the next ``push'' operation
(@code{vc-log-outgoing}).
+
+@item C-x v h
+Display the history of changes made in the region of file visited by
+the current buffer (@code{vc-region-history}).
@end table
@kindex C-x v l
@kindex C-x v h
@findex vc-region-history
-A useful variant of examining changes is provided by the command
+A useful variant of examining history of changes is provided by the command
@kbd{vc-region-history} (by default bound to @kbd{C-x v h}), which shows
-a @file{*VC-history*} buffer with the history of changes to the region
-of the current file between point and the mark (@pxref{Mark}). The
+a @file{*VC-history*} buffer with the history of changes made in the region
+of the current buffer's file between point and the mark (@pxref{Mark}). The
history of changes includes the commit log messages and also the
changes themselves in the Diff format.
-Invoke this command after marking the region of the current file in
+Invoke this command after marking in the current buffer the region in
whose changes you are interested. In the @file{*VC-history*} buffer
it pops up, you can use all of the commands available in the
@file{*vc-change-log*} buffer described above, and also the commands
defined by Diff mode (@pxref{Diff Mode}).
-This command is currently available only with Git.
+This command is currently available only with Git and Mercurial (hg).
@node VC Undo
@subsection Undoing Version Control Actions
never detected a conflict due to invalid assumptions about cached
values.
++++
+*** The Hg (Mercurial) back-end now supports 'vc-region-history'.
+The 'C-x v h' command now works in buffers that visit files controlled
+by Hg.
+
+++
*** 'C-u C-x v D' ('vc-root-version-diff') prompts for two revisions
and compares their entire trees.
;; to the HEAD version of the file, not to the current state of the file.
;; So we need to look at all the local changes and adjust lfrom/lto
;; accordingly.
- ;; FIXME: Maybe this should be done in vc.el (i.e. for all backends), but
- ;; since Git is the only backend to support this operation so far, it's hard
- ;; to tell.
+ ;; FIXME: Maybe this should be done in vc.el (i.e. for other backends),
+ ;; but since Git is one of the two backends that support this operation
+ ;; so far, it's hard to tell; hg doesn't need this.
(with-temp-buffer
(vc-call-backend 'git 'diff file "HEAD" nil (current-buffer))
(goto-char (point-min))
(autoload 'vc-switches "vc")
+(defun vc-hg-region-history (file buffer lfrom lto)
+ "Insert into BUFFER the history of FILE for lines LFROM to LTO.
+This requires hg 4.4 or later, for the \"-L\" option of \"hg log\"."
+ (vc-hg-command buffer 'async nil "log" "-f" "-p" "-L"
+ (format "%s,%d:%d" (file-relative-name file) lfrom lto)))
+
+(require 'diff-mode)
+
+(defvar vc-hg-region-history-mode-map
+ (let ((map (make-composed-keymap
+ nil (make-composed-keymap
+ (list diff-mode-map vc-hg-log-view-mode-map)))))
+ map))
+
+(defvar vc-hg--log-view-long-font-lock-keywords nil)
+(defvar font-lock-keywords)
+(defvar vc-hg-region-history-font-lock-keywords
+ '((vc-hg-region-history-font-lock)))
+
+(defun vc-hg-region-history-font-lock (limit)
+ (let ((in-diff (save-excursion
+ (beginning-of-line)
+ (or (looking-at "^\\(?:diff\\|changeset\\)\\>")
+ (re-search-backward "^\\(?:diff\\|changeset\\)\\>"
+ nil t))
+ (eq ?d (char-after (match-beginning 0))))))
+ (while
+ (let ((end (save-excursion
+ (if (re-search-forward "\n\\(diff\\|changeset\\)\\>"
+ limit t)
+ (match-beginning 1)
+ limit))))
+ (let ((font-lock-keywords (if in-diff diff-font-lock-keywords
+ vc-hg--log-view-long-font-lock-keywords)))
+ (font-lock-fontify-keywords-region (point) end))
+ (goto-char end)
+ (prog1 (< (point) limit)
+ (setq in-diff (eq ?d (char-after))))))
+ nil))
+
+(define-derived-mode vc-hg-region-history-mode
+ vc-hg-log-view-mode "Hg-Region-History"
+ "Major mode to browse Hg's \"log -p\" output."
+ (setq-local vc-hg--log-view-long-font-lock-keywords
+ log-view-font-lock-keywords)
+ (setq-local font-lock-defaults
+ (cons 'vc-hg-region-history-font-lock-keywords
+ (cdr font-lock-defaults))))
+
(defun vc-hg-diff (files &optional oldvers newvers buffer _async)
"Get a difference report using hg between two revisions of FILES."
(let* ((firstfile (car files))