Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to view previous version of a file in Mercurial

Tags:

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?

like image 551
Curious2learn Avatar asked Dec 24 '10 02:12

Curious2learn


People also ask

How do I revert a file in Mercurial?

Revert changes already committed To backout a specific changeset use hg backout -r CHANGESET . This will prompt you directly with a request for the commit message to use in the backout. To revert a file to a specific changeset, use hg revert -r CHANGESET FILENAME . This will revert the file without committing it.

What is hg revert?

hg revert changes the file content only and leaves the working copy parent revision alone.

How to remove file from hg?

Once you decide that a file no longer belongs in your repository, use the hg remove command. This deletes the file, and tells Mercurial to stop tracking it (which will occur at the next commit). A removed file is represented in the output of hg status with a “ R ”.


1 Answers

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)

like image 117
Joel Spolsky Avatar answered Sep 22 '22 18:09

Joel Spolsky