On Mercurial API
Thomas Arendsen Hein
thomas at intevation.de
Tue Jul 31 06:23:36 CDT 2007
* Sébastien Pierre <sebastien-lists at type-z.org> [20070730 17:00]:
> Just wanted to share a snippet from my Mercurial extensions with you:
>
> # Mercurial 0.9.1
> if hasattr(mercurial.commands, 'find'):
> findcmd = mercurial.commands.find
> # Mercurial 0.9.3
> elif hasattr(mercurial.commands, 'findcmd'):
> findcmd = mercurial.commands.findcmd
> # Mercurial 0.9.4
> else:
> import mercurial.cmdutil
> findcmd = mercurial.cmdutil.findcmd
>
> I think this kinds of sums up how I feel towards the current API.
> It's difficult to use, it changes all the time, the code is the only
> documentation, and in the end, it requires constant version-specific
> patches like that.
>
> Right now, the only viable solution for me is to use the command-line
> as an interface, instead of the Python interface, but it comes with a
> severe performance penalty.
contrib/hg-ssh uses:
from mercurial import commands
commands.dispatch(['-R', repo, 'serve', '--stdio'])
Which is basically just calling the command line, but without the
performance penalty. And this should work unchanged from Mercurial 0.6
until now.
A similar interface will exist in future versions, too, though it
might be not in the commands module.
> So I was wondering if you guys had some plans about an API redesign/
> update/consolidation ?
Currently some restructuring happens which causes the problems
you're seeing. The result should be that exatly this will be easier.
Thomas
--
thomas at intevation.de - http://intevation.de/~thomas/ - OpenPGP key: 0x5816791A
Intevation GmbH, Osnabrueck - Register: Amtsgericht Osnabrueck, HR B 18998
Geschaeftsfuehrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
More information about the Mercurial
mailing list