On Mercurial API

TK Soh teekaysoh at gmail.com
Thu Aug 2 18:50:21 CDT 2007


On 7/31/07, Thomas Arendsen Hein <thomas at intevation.de> wrote:
> * 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'])

What I noticed is that mercurial will remember the options for the
subsequent call to 'serve' (or any commands that were called). I had
to put in some sort of dirty hack in TortoiseHg to workaround this
problem. Is this an oversight in the design?



More information about the Mercurial mailing list