Mercurial - View all changesets that modify specific line in file

Use Tortoisehg:

  1. View -> Manifest
  2. Right click on file interested in and click "File History"
  3. click "annotate with revision numbers"

The top panel allows you to quickly see the history of the file in terms of commits, the bottom panel shows the annotated file based upon the selected version in the top panel.


Using the response of arielf without an extra script:

UNIX:

  • command:

      hg log --template '{rev}\n' <FILE> | 
           xargs -I @ hg grep <PATTERN> -r @ <FILE>
    
  • you can use this to add an alias to your configuration file (.hgrc):

      [alias]
      _grep_line_in_history = ! $HG log --template '{rev}\n' $2 | 
           xargs -I @ hg grep '$1' -r @ $2
    

WINDOWS:

  • command:

      FOR /F "usebackq" %i IN (`hg log --template "{rev}\n" <FILE>`) DO
      @(echo %i & hg grep <PATTERN> -r %i <FILE>)
    
  • alias:

      [alias]
      _grep_line_in_history = ! FOR /F "usebackq" %i IN 
           (`%HG% log --template "{rev}\n" "$2"`) DO @(echo %i & %HG% grep "$1" -r %i "$2")