views:

48

answers:

2

I want to do the equivalent of svn export REMOTE_URL with a mercurial repository. What I want at the end is an unversioned snapshot of the repository at the remote URL, but without cloning all of the changesets over to my local machine.

Also, I want to be able to specify a tag in the remote repository to pick this from. If it's not obvious, I'm building a release management tool that pulls from a canonical mercurial repository to build a release file, and it's slow right now because some projects have large, multiple-version binary files committed.

Is this possible? How would one go about it?

+2  A: 

Its usually easier (if the remote HG is using the hgweb interface) to just visit the repo in your browser and download a .tgz / .zip / .bz2 of the tip revision. You'll see the links if the remote HG supports this.

If you want the repository, you need all of the revisions that went into the current tip for it to be at all functional.

There are options to hg clone that allow you to fetch a repository up to a certain revision, but none (that I could find) that allow you to get just the tip revision. What you are essentially asking for is a snapshot of the repo.

Edit: To Get A Snapshot

hg clone http[s]://url.to.repo repo.hg
cd repo.hg
hg archive ../repo-snapshot
cd ..
rm -rf repo.hg

The snapshot is now in repo-snapshot.

Yes, this does entail cloning the repo first, which is why I suggested seeing if the remote hgweb supports on the fly downloads of any particular revision. If it does, your problem is solved with something like curl or wget instead of HG.

If not, its good to let the original repo 'live' since you can update it again later via hg pull, then create another snapshot of a future release. This saves having to start over from scratch when cloning, especially for large repositories with lots of changes.

Also, Linux centric, but you get the gist. Of course, replace http[s] with the desired protocol as needed.

Tim Post
That's exactly what I want; a snapshot of the remote repository, at a particular tag / revision hash. I have no desire for the repository itself; that's never going to be in the release package :)
Chris R
@Chris R - see my edits. Ideally, the remote hgweb supports on the fly downloading of snapshots of any revision. Else .. you have to make a disposable clone to create one.
Tim Post
I see 'em; I'm specifically looking to avoid the local clone, so that's a non-starter. The http archive download seems the most likely.
Chris R
+1  A: 

Is there any reason you can't maintain a mirror (updated in the background however often you want) of the remote repository on your local machine, then have the release management tool on your local machine run hg archive out of the local clone as necessary? If your concern is user-responsiveness, and not total bandwidth/storage consumed, this offsets the "slow" part to where you won't see it.

Tim Post noted that if you do have the hgweb CGI interface available, you can configure it to pull compressed archives down and unpack them (and the interface is consistent enough that you could script that via wget), but if you don't, core Mercurial doesn't have a lot of tools to help you, and the developers have expressed an opposition to trying to turn Mercurial into a general rsync-type client.

If you aren't afraid of playing with unofficial add-ons, you could have a look at the FTP Extension. That will force you to push from the server, however.

Zed
hgweb might be the ticket, although I'm pretty sure we'd planned on using the ssh access model. Nonetheless, that might turn out to be the best way to do it. Thanks, I'll have to see if it can be made to work.
Chris R