Frank Schwieterman
Frank Schwieterman

Reputation: 24480

how to see all revisions related to a particular string in a file with mercurial?

Is there a way to generate a list of changesets that affected a particular line of a file? Annotate will let me see the last changeset to affect a particular line, I would like to chain annotations for a particular line back until it was first added.

Upvotes: 2

Views: 118

Answers (2)

Ry4an Brase
Ry4an Brase

Reputation: 78330

What about:

hg grep --all symbolBeingWatched

or if you really just want the list of revisions

hg grep --all symbolBeingwatched | cut -d : -f 2 | sort -u -n

Upvotes: 3

Lazy Badger
Lazy Badger

Reputation: 97280

Extended (and slightly alternated) version of pyfunc comment, without "ready-to-use" solution, only draft, with samples from my repo

  • Define all changesets, which affect file (I'm lazy to write final gawk-code)

    hg log --template "{rev}\n" functions.php

    3 2 1 0

  • For each revision from set:

    hg ann -r $REV functions.php | grep "load_theme_" >> string.txt

string.txt will be after all hg ann | (none for rev 0 was grepped)

2: load_theme_textdomain('fiver', get_template_directory() . '/languages');
2: load_theme_textdomain('fiver', get_template_directory() . '/languages');
1: load_theme_textdomain('fiver', get_template_directory() . '/translation');
  • Remove duplicates with uniq pipe and get final result

Frank says: thanks, that got me started, I ended up using the following from Powershell to watch what changesets affected a particular symbol:

$history = hg log --template "{rev}\n" $filename
$history | % { $_; hg log -vpr $_ $filename | select-string $symbolBeingWatched } 

Upvotes: 1

Related Questions