Reputation: 6788
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:
shows commits from unmerged branches
hg log -l 1 filename
empty output if the file remains unchanged after branch creation
hg log -l 1 -b . filename
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
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