Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mercurial: annotate / blame current line number

Tags:

mercurial

hg annotate -unl aFile

Shows:

jim 1519:477:     a = 4
bob 1518:468:     b = 5
joe 1496:402:     return a

How do I get it to show

jim 401:     a = 4
bob 402:     b = 5
joe 403:     return a

Where 401, 402, 403 are the current line numbers. Better yet would be something like git has with git blame -L 401,403 aFile.

like image 496
AJP Avatar asked Dec 27 '22 02:12

AJP


2 Answers

To show current line numbers:

hg annotate -u aFile | cat -n

To also select only a certain range of line numbers:

hg annotate -u aFile | cat -n | sed -n 401,403p
like image 60
Reimer Behrends Avatar answered Jan 13 '23 04:01

Reimer Behrends


I always use the annotate view in hg serve or from TortoiseHg. I find the command line annotate pretty poor since I cannot quickly jump to a parent revision. The hgweb annotate can be seen here:

  • https://www.mercurial-scm.org/repo/hg/annotate/tip/README

It includes (current) line numbers.

like image 40
Martin Geisler Avatar answered Jan 13 '23 03:01

Martin Geisler