Helmut Grohne
Helmut Grohne

Reputation: 6788

How to determine the last Mercurial commit that changed file X?

Given a checkout of a Mercurial repository and a filename. How does one determine the last commit that changed that file? Unlike git, care must be taken with branches. The intended semantic here is to follow the history of the branch. Where branches fork from other branches, follow parent branches.

Non-solutions:

Arguably, this question highlights misuse of branches and bookmarks should be used instead. However that may be, existing history necessiates taking branches into account.

Upvotes: 0

Views: 62

Answers (1)

Mark Tolonen
Mark Tolonen

Reputation: 178179

The -f flag tells hg log to follow history of the current or selected changeset, so this should find the first change of a file without looking at changesets that aren't direct ancestors:

hg log -f -l 1 filename

Upvotes: 1

Related Questions