Search code examples
mercurialrevision

Get revision number without clone/pull


How can I just get the revision number of a mercurial repository, without using "pull", or, if possible, without cloning it from the server? Or if, as I guess, it's impossible, can I get the revision number without "update the files" ? An update like a "hg clone -U" ?

Thanks


Solution

  • If you have access to the repository over the file system, you can use hg tip or hg log:

    hg log -l 1 -R /path/to/repo
    

    Otherwise you can go into any repository (maybe make an empty one for the purpose) and use hg in, telling it to run even though the repositories are unrelated:

    hg init tmp
    cd tmp
    hg in -f -n -l 1 url-of-repo
    

    The -f ("force") makes it work with an unrelated repo; -n means "newest revision first"; -l 1 limits the number of revisions printed to 1. The net effect is to print out the newest revision that's in the repo and not in your local one. Since there are no revisions in your local one, that just gives the newest revision.