Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I improve emacs' vc-mode annotation?

I find hg annotate very useful in tracking the provenance of code, but I'm seeing that in emacs' vc-mode, vc-annotate is ... not so good. Here's a snippet:

297 Wed Oct 06 15:21:30 2010 -0600 aws/lib/survey/creator/dbTemplates/web/views.sql: $$,$$
687 Mon Dec 20 10:25:41 2010 -0700 aws/lib/survey/creator/dbTemplates/web/views.sql: GRANT SELECT ON survey_length_view TO reportuser,surveyuser,sampleserver,sampleloader;
687 Mon Dec 20 10:25:41 2010 -0700 aws/lib/survey/creator/dbTemplates/web/views.sql: GRANT ALL ON survey_length_view TO adminuser, GROUP staff;
297 Wed Oct 06 15:21:30 2010 -0600 aws/lib/survey/creator/dbTemplates/web/views.sql: $$);

As you can see, there's a lot of preamble there, and a fair amount of redundant information. I don't need to know the full ISO timestamp (most of the time, anyway) and the path to the file is covered by the fact that I was in the file when I chose to annotate. I do need to know who made the change, which is notably absent here.

How can I fix this annotation tool so that it becomes useful?

like image 986
Chris R Avatar asked Jan 12 '11 15:01

Chris R


2 Answers

vc-hg.el seems to hardcode the arguments to hg annotate, so you would need to redefine the command after loading vc-hg:

(require 'vc-hg)
(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."
  (vc-hg-command buffer 0 file "annotate" "-d" "-n" "--follow"
                 (when revision (concat "-r" revision))))

Simply removing the arguments will probably cause you to lose functionality due to the missing information, so a better solution would be to follow the example in vc-bzr.el where some of the information is stripped out and put into a tooltip instead. If you go down that route, consider contributing your improvements back to Emacs.

like image 86
JSON Avatar answered Oct 16 '22 06:10

JSON


This is solved in Emacs 25.

;; One line printed by "hg annotate -dq -n -u --follow" looks like this:
;;   b56girard 114590 2012-03-13 CLOBBER: Lorem ipsum dolor sit
;; i.e. AUTHOR REVISION DATE FILENAME: CONTENTS
;; The user can omit options "-u" and/or "--follow".  Then it'll look like:
;;   114590 2012-03-13 CLOBBER:
;; or
;;   b56girard 114590 2012-03-13:
like image 24
santiagopim Avatar answered Oct 16 '22 05:10

santiagopim