How can you clone a Mercurial repository as of a specific changeset?

29,414

This command tells to use -r / --rev switch:

hg help clone

So :

hg clone -r 7
Share:
29,414
Marcus Leon
Author by

Marcus Leon

Director Clearing Technology, Intercontinental Exchange. Develop the clearing systems that power ICE/NYSE's derivatives markets.

Updated on November 11, 2020

Comments

  • Marcus Leon
    Marcus Leon over 3 years

    How can you clone a Mercurial repository as of a specific changeset?

    Ie: If the master repo has changesets 1-10, how can get a copy of the source as it existed in changeset #7?

  • rationull
    rationull over 10 years
    Note this will clone the specified revision and all ancestors, but will NOT clone revisions that are not related to the specified revision but come earlier in the source repository's revlog (e.g. old divergent branches).
  • Brian Swift
    Brian Swift almost 9 years
    Note: If you're using bitbucket, you can use the specific hash key from any given commit as the revision number when cloning or pulling from a bitbucket repository. Example, for a user fakeuser, project fakeproject, commit hash a123456: hg clone https://bitbucket.org/fakeuser/fakeproject -r a123456
  • markgalassi
    markgalassi over 8 years
    @rationull your comment is important. I have typically gotten around that by using a script to do a bunch of "pull"s. Do you know of a better way? I.e. a more complete answer to the OP's question?
  • rationull
    rationull over 8 years
    @markgalassi Specifically the OP asked about getting the source as of changeset 7, and the clone command as given does achieve that. I don't know of a way to get all changesets up to the requested one without resorting to writing python code using Mercurial's APIs to look at the actual changesets/revlog in order and push/pull each to the target repo. A co-worker of mine did have to write a script to do that very thing at one point but I don't know the details.