clone an hg directory from a particular date

mercurial

Solution

(EDIT: My love of revsets has caused me to overlook the obvious answer: `hg update --date 2012-04-04` should get you the tipmost revision as of that date.)

If you have the whole repository cloned already (date specifications don't seem to work with `clone`), you can do

hg update --rev "date('< 2012-04-04')"

If there's a possibility that the repository had multiple heads/branches at the date you want, you'll have to AND in some more conditions to narrow it down to the right changeset:

hg update --rev "date('< 2012-04-04') and branch(v1.1)"

Check out `hg help revsets` and `hg help dates` for more information.

Later, if you want to go back to the tip, just

hg update

Problem

Is there a way to get a copy of a hg repository as it was at a particular date? For example, in subversion I would use: ``` svn checkout -r {2012-04-04} ... ``` And it would check out a revision as it appeared on the fourth of April. In git its a little more complicated, but can be done: ``` git checkout `git rev-list -n 1 --before="2012-04-04" master` ``` Can you do the same thing in hg?

Original source