Search code examples
mercurialhgserve

How to use mercurial built-in templates?


Mercurial comes with some templates bundled. They may be stored in /usr/local/lib/python2.7/dist-packages/mercurial/templates/ or in /usr/share/mercurial/templates.

In this folder there are few files:

map-cmdline.bisect
map-cmdline.changelog
map-cmdline.compact
map-cmdline.default
map-cmdline.xml

They're styles to use in command line e.g. hg log -l 10 --style changelog.

Alse there are folders:

atom
coal
gitweb
monoblue
paper
raw
rss
spartan

Each of them contains files like:

bookmarkentry.tmpl
bookmarks.tmpl
changelogentry.tmpl
changelog.tmpl
error.tmpl
filelog.tmpl
header.tmpl
map
tagentry.tmpl
tags.tmpl

I'm guessing these are templates to use with hg serve. While trying run hgweb with -t option i get following error:

$ hg serve -t paper
listening at http://127.0.0.1:8000/ (bound to *:8000)
127.0.0.1 - - [14/May/2012 14:16:38] "GET / HTTP/1.1" 500 -
127.0.0.1 - - [14/May/2012 14:16:38] Exception happened during processing request '/':
Traceback (most recent call last):
   [traceback here]
RuntimeError: No hgweb templates found in ['paper']

Does anyone know what are this folders/files and how to run hg serve with different templates?

ps.: I use Mercurial 2.1.1


Solution

  • You need to use the --style flag to specify a template style such as gitweb or paper.

    hg serve --style paper
    

    This will look in the shared templates folder and use the set of templates there. The -t option expects a path pointing to a set of templates.