How do you get a copy of an earlier revision of a file in Mercurial without making that the new default working copy of the file in your workspace?
I've found the hg revert
command and I think it does what I want but I'm not sure.
I need to get a copy of an earlier revision of my code to work with for a few minutes. But I don't want to disturb the current version which is working fine.
So I was going to do this:
hg revert -r 10 myfile.pls
Is there a way to output it to a different directory so my current working version of the file is not disturbed? Something like:
hg revert -r 10 myfile.pls > c:\temp\dump\myfile_revision10.pls
The command you use is this:
Knowing a bit of Unix helps with Mercurial commands. Perhaps
cat
should have a built in aliasprint
or something similar.The cat command can be used to retrieve any revision of a file:
You can redirect the output to another file with
or by using the
--output
flag. If you need to do this for several files, then take a look at the archive command, which can do this for an entire project, e.g.,This creates the folder
revision-10
which contains a snapshot of your repository as it looked in revision 10.However, most of the time you should just use the update command to checkout an earlier revision. Update is the command you use to bring the working copy up to date after pulling in new changes, but the command can also be used to make your working copy outdated if needed. So