How to view previous version of a file in Mercurial

mercurial

I am using mercurial for version control of a few files in a directory. Suppose I have 10 commits (10 changesets or revisions). I want to just view how a particular file, say thisFile.py, looked in its 7th revision. I don't want to revert back to this older version. I don't want to go and make any changes or fix any bugs in this previous version. I simply want to see it, without affecting the latest version of the file or the mercurial history in any way. Is there a simple way to do it?

Best Answer

Use the hg cat command with the -r (revision) argument.

hg cat path_to/myfile.cpp -r 46

where 46 is the revision number (use hg log to see revision history)