2
votes

does Mercurial have an HTTP protocol we could browse files/folders/branches instead of clone/pull changesets?

I've seen something using TortoiseHG WebServer and access http://localhost:8080/ using browser but completely different HTML is served when you use project on https://bitbucket.org/ (at least I could not find the same representation).

Update the HttpCommandProtocol document describes only changesets but not files/folders. So, the task is to download only few files only for particular revision (for example with tip 'stable') and a list of files. However I do not want to download a complete repository for this.

Non HTTP protocols are welcome but conditions are the same: do not download a complete repository.

Update 2 hgweb serves static HTML and files. Is it always the same HTML fromat for different hgweb versions? What about bitbucket.org? Is there any common protocol?

3

3 Answers

3
votes

As you noticed already, the HttpCommandProtocol defines the exchange of repository information and changesets - it ensures that you can clone/push/pull from/to any repo served by HTTP. But AFAIK there's no standard for how to browse a repo (e.g. getting a single file of a certain revision).

You'll have to adapt to whatever URL scheme your hosting system of choice uses (as you also noticed, hgweb and bitbucket have different schemes). Depending on your use case you could define your own file access protocol and feed it to an converter.

For instance you might want to access files with this scheme:

<repo-url>/<rev>/<path>

Where <repo-url> is the URL you use to clone/push/pull. In practice you would then use URLs like that:

https://bitbucket.org/user/repo/<rev>/<path>
https://hgwebhost.org/.../repo/<rev>/<path>

Obviously these are virtual URLs which do not exist. That's where your converter comes in: check the hosting system type and convert URLs accordingly:

https://bitbucket.org/user/repo/raw/<rev>/<path>
https://hgwebhost.org/.../repo/raw-file/<rev>/<path>

If your converter knows bitbucket and hgweb, then it already works with a good deal of repositories out there.

2
votes

Mercurial has hgweb. It can be deployed via any wsgi container and I think it even has CGI support.

2
votes

If you just go to any hg repo and type

hg serve

you will have a webserver listening at a url that you can point a browser at. The formatting of the webpages generated by hg can be changed via templates. It is very likely bitbucket.org has their own fancier templates, hence they have a prettier webpages.

Further the listening url can be used to push and pull from as well using hg. This is in fact the same website that is channeled via hgweb.cgi and also the underlying mechanism for doing push/pull over SSH.