help on mercurial API usage
Arne Babenhauserheide
arne_bab at web.de
Thu Jul 24 03:18:07 CDT 2008
Am Mittwoch 23 Juli 2008 20:56:43 schrieb Manlio Perillo:
> These ht files are formatted to html files and stored on filesystem.
> GET access is done using a standard web server.
> DELETE, POST and PUT access, instead, are handled by the application:
> they operate on the Mercurial repository and update the html file.
>
> Is Mercurial appropriate for this task?
> Where can I find help about the API usage?
It can definitely be used for that, and it gives you the additional benefit of
being able to work on pages offline in a clone of the repository and pushing
them to the site once you're finished.
If you want to use it directly from python, you can have a look at the commits
I did in the group extension:
- http://freehg.org/u/ArneBab/hgext_group/file/306eb32bfe6b/group.py
Most interesting parts (somewhat adapted to be easier to understand out of
context):
line 129:
def group(ui, repo, *pats, **opts):
"""Creates a new commit with information in a file.
@param ui: Class to interact with the user. Gets passed to every mercurial
command issued on the command line.
@param repo: Class to interact with the repository. Gets passed to every
mercurial command issued on the command line.
"""
lines 202:208
# Get the change context of the current revision
#: Change context
ctx = repo.changectx()
# Check if the file is tracked and make it tracked if not.
if not FILE_NAME in [i for i in ctx.manifest()]:
# No groups where there, yet, so we add .hggroups to the tracked files.
repo.add([FILE_NAME])
line 211:
# commit the file.
repo.commit(files=[FILENAME], text=text)
To realize the system, you could just edit the files in the working directory
and commit them.
Then just add a commit-hook, which compiles them into static html and puts
them into some subdirectory (best also add a changegroup hook, so people can
work offline and push their changes via Mercurial).
- hooks: http://hgbook.red-bean.com/hgbookch10.html
For this exact code to work, you'd have to call the command via the
commandline (using a custom mercurial extension).
Besides: ikiwiki does something similar with using perl.
Best wishes,
Arne
PS: Should I rather join mercurial-devel?
-- Weblog: http://blog.draketo.de
-- Infinite Hands: http://infinite-hands.draketo.de - singing a part of the
history of free software.
-- Ein Würfel System: http://1w6.org - einfach saubere (Rollenspiel-) Regeln
-- PGP/GnuPG: http://draketo.de/inhalt/ich/pubkey.txt
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://selenic.com/pipermail/mercurial/attachments/20080724/85699964/attachment.pgp
More information about the Mercurial
mailing list