From 91db34868ab374195c5639e4cb3a88fa1cbee16d Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Mon, 27 Apr 2026 13:23:30 +0100 Subject: [PATCH] VC Annotate for Mercurial repositories shows changeset hashes * lisp/vc/vc-hg.el (vc-hg-annotate-show-revision-numbers): New option. (vc-hg-annotate-command): If it's nil, show changeset hashes not revision numbers by passing "-c" not "-n" to 'hg annotate'. (vc-hg-annotate-re): Update. * etc/NEWS: Document the change. --- etc/NEWS | 6 ++++++ lisp/vc/vc-hg.el | 15 +++++++++++---- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/etc/NEWS b/etc/NEWS index c6f7ffe2a1e..4f6dec10e99 100644 --- a/etc/NEWS +++ b/etc/NEWS @@ -2802,6 +2802,12 @@ To undo this change you can use This command prints the log of VC changes to the current fileset on another branch. +--- +*** VC Annotate for Mercurial repositories shows changeset hashes. +To restore showing revision numbers instead of changeset hashes, +customize the new option vc-hg-annotate-show-revision-numbers to +non-nil. + +++ *** New commands to handle repositories with multiple working trees. Some VCS support more than one working tree with the same backing diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 8d0239604a7..588d24e36d6 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -601,10 +601,17 @@ This requires hg 4.4 or later, for the \"-L\" option of \"hg log\"." table (lambda () (vc-hg-revision-table files))))) table)) +(defcustom vc-hg-annotate-show-revision-numbers nil + "If non-nil, \\[vc-annotate] shows revision numbers for Hg repositories. +The default when this is nil is to show changeset hashes." + :type 'boolean + :version "31.1") + (defun vc-hg-annotate-command (file buffer &optional revision) "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. Optional arg REVISION is a revision to annotate from." - (apply #'vc-hg-command buffer 'async file "annotate" "-dq" "-n" + (apply #'vc-hg-command buffer 'async file "annotate" "-dq" + (if vc-hg-annotate-show-revision-numbers "-n" "-c") (append (vc-switches 'hg 'annotate) (if revision (list (concat "-r" revision)))))) @@ -619,9 +626,9 @@ Optional arg REVISION is a revision to annotate from." ;; b56girard 114590 2012-03-13: (defconst vc-hg-annotate-re (concat - "^\\(?: *[^ ]+ +\\)?\\([0-9]+\\) " ;User and revision. - "\\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\\)" ;Date. - "\\(?: +\\([^:]+\\)\\)?:")) ;Filename. + "^\\(?: *[^ ]+ +\\)?\\([[:xdigit:]]+\\) " ; User and revision. + "\\([0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]\\)" ; Date. + "\\(?: +\\([^:]+\\)\\)?:")) ; Filename. (defun vc-hg-annotate-time () (when (looking-at vc-hg-annotate-re)