0

I need to walk the history of Mercurial using the commandline (no GUI tools) for a single line number all the way back through history to the starting point. As an example, I used this for Git (using git blame) for line 2:

git blame -L2,2 --porcelain --incremental Filename.txt HEAD

d1b92f3a9e31ca3e3ee56f0965609314fc192f22 2 2 1  (<- the first 2 listed is the previous line number)
author Firstname Lastname
author-mail <author@domain.com>
author-time 1140197028
author-tz +0000
committer Firstname Lastname
committer-mail <author@domain.com>
committer-time 1140197028
committer-tz +0000
summary commit message here
previous 6bbaa283b326cde510ea3146a5fc6edd8956489a Filename.txt
filename Filename.txt

I need the following information:

  • committer/author name
  • previous line number
  • date and time
  • previous hash

With git blame, I can then use this information and call it again for the specific hash and previous line number, thus traversing the entire history of that line all the way back.

For Mercurial, I found hg annotate. I have the following:

hg annotate -unlcv -r tip Filename.txt | cat -n | sed -n 2,2p

2 Firstname Lastname <author@domain.com> 24741 7c36d9284795: 2: commit message here

So this is good. I can get all the information I need, including the last hash, except I'm unsure about the previous line number. The first 2 listed above in that line is from "cat", but the second 2 listed... is that the previous line number that I should be following? I want to make absolutely sure I'm following this back through history correctly.

firefly2442
  • 557
  • 8
  • 18

0 Answers0